From e13fc3253f81a9cfbd3f1fc2d3db2a4094dc0acc Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 14 Nov 2024 12:11:18 +0000 Subject: [PATCH 1/2] add workflow to run tests against release-2.8 --- .github/workflows/build-extension-catalog.yml | 36 ++++++++++++++++-- .github/workflows/build-extension-charts.yml | 37 +++++++++++++++++-- .github/workflows/release-shell-pkg.yaml | 34 +++++++++++++++-- shell/scripts/extension/parse-tag-name | 2 + shell/scripts/publish-shell.sh | 7 ++++ 5 files changed, 105 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-extension-catalog.yml b/.github/workflows/build-extension-catalog.yml index e96eaec9f8d..1e0abd921d2 100644 --- a/.github/workflows/build-extension-catalog.yml +++ b/.github/workflows/build-extension-catalog.yml @@ -12,22 +12,44 @@ on: tagged_release: required: false type: string + is_test: + required: false + type: string + test_ext_repo: + required: false + type: string + test_ext_branch: + required: false + type: string secrets: registry_token: required: true + outputs: + build-extension-catalog-job-status: + value: ${{ jobs.build-extension-catalog.outputs.build-status }} jobs: build-extension-catalog: name: Build container image - if: github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') + if: github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') || inputs.is_test == 'true' runs-on: ubuntu-latest permissions: actions: write contents: read packages: write + outputs: + build-status: ${{ job.status }} steps: - - name: Checkout repository + - if: inputs.is_test == 'true' + name: Checkout repository (test flow) + uses: actions/checkout@v4 + with: + repository: rancher/${{ inputs.test_ext_repo }} + ref: ${{ inputs.test_ext_branch }} + + - if: inputs.is_test != 'true' + name: Checkout repository (normal flow) uses: actions/checkout@v4 - name: Setup Nodejs for corepack @@ -64,7 +86,7 @@ jobs: run: yarn - name: Parse Extension Name - if: github.ref_type == 'tag' + if: github.ref_type == 'tag' || inputs.is_test == 'true' id: parsed-name env: GH_TOKEN: ${{ github.token }} @@ -73,7 +95,13 @@ jobs: - name: Build and push UI image run: | - publish="yarn publish-pkgs -cp -r ${{ inputs.registry_target }} -o ${{ github.repository_owner }}" + publish="yarn publish-pkgs -c" + + if [[ "${{ inputs.is_test }}" != "true" ]]; then + publish="$publish -p" + fi + + publish="$publish -r ${{ inputs.registry_target }} -o ${{ github.repository_owner }}" if [[ -n "${{ inputs.tagged_release }}" ]]; then publish="$publish -t ${{ inputs.tagged_release }}" diff --git a/.github/workflows/build-extension-charts.yml b/.github/workflows/build-extension-charts.yml index 0908b2e2ccc..dde73e3268b 100644 --- a/.github/workflows/build-extension-charts.yml +++ b/.github/workflows/build-extension-charts.yml @@ -9,6 +9,20 @@ on: tagged_release: required: false type: string + is_test: + required: false + type: string + test_ext_repo: + required: false + type: string + test_ext_branch: + required: false + type: string + outputs: + build-job-status: + value: ${{ jobs.build-extension-artifact.outputs.build-status }} + release-job-status: + value: ${{ jobs.release.outputs.release-status }} env: ACTIONS_RUNNER_DEBUG: false @@ -26,8 +40,19 @@ jobs: permissions: actions: write contents: read + outputs: + build-status: ${{ job.status }} steps: - - name: Checkout + - if: inputs.is_test == 'true' + name: Checkout (test flow) + uses: actions/checkout@v4 + with: + repository: rancher/${{ inputs.test_ext_repo }} + ref: ${{ inputs.test_ext_branch }} + fetch-depth: 0 + + - if: inputs.is_test != 'true' + name: Checkout (normal flow) uses: actions/checkout@v4 with: fetch-depth: 0 @@ -60,7 +85,7 @@ jobs: run: yarn - name: Parse Extension Name - if: github.ref_type == 'tag' + if: github.ref_type == 'tag' || inputs.is_test == 'true' id: parsed-name env: GH_TOKEN: ${{ github.token }} @@ -77,10 +102,14 @@ jobs: publish="$publish -t ${{ inputs.tagged_release }}" fi + if [[ "${{ inputs.is_test }}" == "true" ]]; then + publish="$publish -f" + fi + $publish - name: Upload charts artifact - if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + if: github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') || inputs.is_test == 'true' uses: actions/upload-artifact@v3 with: name: charts @@ -88,7 +117,7 @@ jobs: release: name: Release Build - if: github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') + if: github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') || inputs.is_test != 'true' needs: build-extension-artifact runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/release-shell-pkg.yaml b/.github/workflows/release-shell-pkg.yaml index 8a187443a87..f13ea7ded4c 100644 --- a/.github/workflows/release-shell-pkg.yaml +++ b/.github/workflows/release-shell-pkg.yaml @@ -5,6 +5,20 @@ on: tags: - "shell-pkg-v*" - "creators-pkg-v*" + workflow_call: + inputs: + tag: + required: false + type: string + is_test: + required: false + type: string + test_branch: + required: false + type: string + outputs: + build-release-shell-creators-status: + value: ${{ jobs.build.outputs.build-status }} jobs: build: @@ -12,8 +26,21 @@ jobs: permissions: contents: read packages: write + if: github.repository == 'rancher/dashboard' && (github.event_name == 'workflow_call' || (github.event_name == 'push' && github.event.ref == 'refs/tags/${{ github.ref_name }}')) + outputs: + build-status: ${{ job.status }} steps: - - uses: actions/checkout@v3 + - if: inputs.is_test == 'true' && inputs.test_branch != '' + name: Checkout (test flow) + uses: actions/checkout@v4 + with: + persist-credentials: false + ref: ${{ inputs.test_branch }} + fetch-depth: 0 + + - if: inputs.is_test != 'true' + name: Checkout (normal flow) + uses: actions/checkout@v4 with: fetch-depth: 0 persist-credentials: false @@ -26,7 +53,7 @@ jobs: - name: Check Tags Version Matching env: - TAG: ${{github.ref_name}} + TAG: ${{ inputs.tag || github.ref_name }} run: ./.github/workflows/scripts/check-package-tag-version.sh shell: bash @@ -57,5 +84,6 @@ jobs: - name: Publish Shell Package to npm run: ./shell/scripts/publish-shell.sh --npm env: - TAG: ${{github.ref_name}} + TAG: ${{ inputs.tag || github.ref_name }} + DRY_RUN: ${{ inputs.is_test }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/shell/scripts/extension/parse-tag-name b/shell/scripts/extension/parse-tag-name index 704d2bbc858..ce6ece3ef18 100755 --- a/shell/scripts/extension/parse-tag-name +++ b/shell/scripts/extension/parse-tag-name @@ -4,6 +4,8 @@ GITHUB_RELEASE_TAG=$1 GITHUB_RUN_ID=$2 GITHUB_WORKFLOW_TYPE=$3 +echo "Parse tag name - evaluating release tag $GITHUB_RELEASE_TAG" + # Check packages for released tag name if [[ "${GITHUB_WORKFLOW_TYPE}" == "container" ]]; then for d in pkg/*/ ; do diff --git a/shell/scripts/publish-shell.sh b/shell/scripts/publish-shell.sh index 99fdac978dd..a63ef7ab87f 100755 --- a/shell/scripts/publish-shell.sh +++ b/shell/scripts/publish-shell.sh @@ -64,6 +64,13 @@ function publish() { PUBLISH_ARGS="$PUBLISH_ARGS --tag legacy-v1" fi + # when testing the workflow, we don't want to actually do an npm publish but only a dry run + if [ ${DRY_RUN} == "true" ]; then + PUBLISH_ARGS="$PUBLISH_ARGS --dry-run" + fi + + echo "Publish to NPM - arguments ::: ${PUBLISH_ARGS}" + # Make a note of dependency versions, if required node ${SCRIPT_DIR}/record-deps.js From 8f034aff9ee5cc863a4321f05d1a6ea52333e4cd Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Mon, 25 Nov 2024 15:58:14 +0000 Subject: [PATCH 2/2] adjust workflows to not use release-status output since it will never be populated as that job doesnt run in these workflow tests --- .github/workflows/build-extension-charts.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-extension-charts.yml b/.github/workflows/build-extension-charts.yml index dde73e3268b..6233a31b2a4 100644 --- a/.github/workflows/build-extension-charts.yml +++ b/.github/workflows/build-extension-charts.yml @@ -21,8 +21,6 @@ on: outputs: build-job-status: value: ${{ jobs.build-extension-artifact.outputs.build-status }} - release-job-status: - value: ${{ jobs.release.outputs.release-status }} env: ACTIONS_RUNNER_DEBUG: false