From e66a1a2c36557285d775e1e0bae883164cdf9144 Mon Sep 17 00:00:00 2001 From: vatsrahul1001 <43964496+vatsrahul1001@users.noreply.github.com> Date: Fri, 15 Mar 2024 11:09:20 -0700 Subject: [PATCH] Deploy only if RC is released (#1396) Our RC test workflow was updating the deployment and running the master DAG even if there was no RC release. This PR only initiates deployment and DAG triggers when we have an RC release. --- .../workflows/reuse-wf-check-rc-release.yaml | 36 +++++++++++-------- .github/workflows/test-rc-release.yaml | 34 +++++++++++++----- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/.github/workflows/reuse-wf-check-rc-release.yaml b/.github/workflows/reuse-wf-check-rc-release.yaml index c55112835..395bd27de 100644 --- a/.github/workflows/reuse-wf-check-rc-release.yaml +++ b/.github/workflows/reuse-wf-check-rc-release.yaml @@ -13,19 +13,19 @@ on: # yamllint disable-line rule:truthy (Either rc_testing_branch or issue_url is required, and you cannot give both.) required: false type: string - default: '' + default: "" issue_url: description: | issue_url: the GitHub issue URL that tracks the status of Providers release (Either rc_testing_branch or issue_url is required, and you cannot give both.) required: false type: string - default: '' + default: "" base_git_rev: - description: 'The base git revision to test Providers RCs' + description: "The base git revision to test Providers RCs" required: false type: string - default: 'main' + default: "main" git_email: description: "bot's email for setting up git" required: true @@ -38,19 +38,25 @@ on: # yamllint disable-line rule:truthy description: "the path to run scripts" required: false type: string - default: '' + default: "" secrets: BOT_ACCESS_TOKEN: - description: 'personal access token for the bot to push the commit and create pull request' + description: "personal access token for the bot to push the commit and create pull request" required: true outputs: rc_testing_branch: - description: 'personal access token for the bot to push the commit and create pull request' + description: "personal access token for the bot to push the commit and create pull request" value: ${{ jobs.export-rc-testing-branch-name.outputs.rc_testing_branch }} + no_provider_changed: + description: "no provider has been changed in this rc release" + value: ${{ jobs.create-branch-for-testing-rc-release.outputs.no_provider_changed }} + rc_issue_url: + description: "the newly found GitHub issue URL that tracks the status of Providers release" + value: ${{ jobs.check-rc-testing-announcement.outputs.rc_issue_url }} jobs: check-rc-testing-announcement: - runs-on: 'ubuntu-20.04' + runs-on: "ubuntu-20.04" if: github.event_name == 'schedule' env: GH_TOKEN: ${{ github.token }} @@ -58,7 +64,7 @@ jobs: - name: Checkout apache-airflow uses: actions/checkout@v3 with: - repository: 'apache/airflow' + repository: "apache/airflow" - name: Parse the latest 100 GitHub issues from apache-airflow to check providers testing announcement id: parse-airflow-gh-issues @@ -115,20 +121,20 @@ jobs: rc_issue_url: ${{ steps.export-rc-issue-url.outputs.rc_issue_url }} validate-manual-input: - runs-on: 'ubuntu-20.04' + runs-on: "ubuntu-20.04" if: github.event_name == 'workflow_dispatch' steps: - name: Validate user input if: | - (inputs.rc_testing_branch == '' && inputs.issue_url == '') || - (inputs.rc_testing_branch != '' && inputs.issue_url != '') + (inputs.rc_testing_branch == '' && inputs.issue_url == '') || + (inputs.rc_testing_branch != '' && inputs.issue_url != '') run: | echo "Either rc_testing_branch or issue_url is required, and you cannot give both." exit 1 create-branch-for-testing-rc-release: needs: [validate-manual-input, check-rc-testing-announcement] - runs-on: 'ubuntu-20.04' + runs-on: "ubuntu-20.04" if: | always() && ( @@ -182,6 +188,7 @@ jobs: echo "no_provider_changed=true" >> $GITHUB_OUTPUT else echo "$difference" + echo "no_provider_changed=false" >> $GITHUB_OUTPUT fi - name: Create RC branch @@ -215,6 +222,7 @@ jobs: echo "git_rev=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT outputs: rc_testing_branch: ${{ steps.create_rc_branch.outputs.rc_testing_branch }} + no_provider_changed: ${{ steps.check-repo-provideres-updated.outputs.no_provider_changed }} export-rc-testing-branch-name: needs: [validate-manual-input, create-branch-for-testing-rc-release] @@ -228,7 +236,7 @@ jobs: needs.validate-manual-input.result == 'success' && inputs.rc_testing_branch ) - runs-on: 'ubuntu-20.04' + runs-on: "ubuntu-20.04" steps: - name: export rc_testing_branch id: export-rc-testing-branch-name-step diff --git a/.github/workflows/test-rc-release.yaml b/.github/workflows/test-rc-release.yaml index 31acff2e6..fabede516 100644 --- a/.github/workflows/test-rc-release.yaml +++ b/.github/workflows/test-rc-release.yaml @@ -14,17 +14,17 @@ on: # yamllint disable-line rule:truthy rc_testing_branch: existing testing branch (Either rc_testing_branch or issue_url is required, and you cannot give both.) required: false - default: '' + default: "" issue_url: description: | issue_url: the GitHub issue URL that tracks the status of Providers release (Either rc_testing_branch or issue_url is required, and you cannot give both.) required: false base_git_rev: - description: 'The base git revision to test Providers RCs' + description: "The base git revision to test Providers RCs" required: false type: string - default: 'main' + default: "main" jobs: check-airflow-provider-rc-release: @@ -42,11 +42,15 @@ jobs: needs: check-airflow-provider-rc-release if: | always() && - needs.check-airflow-provider-rc-release.result == 'success' + ( + needs.check-airflow-provider-rc-release.outputs.rc_issue_url != '' || + inputs.issue_url != '' + ) && + needs.check-airflow-provider-rc-release.outputs.no_provider_changed != 'true' uses: ./.github/workflows/reuse-wf-deploy-to-astro-cloud.yaml with: git_rev: ${{ needs.check-airflow-provider-rc-release.outputs.rc_testing_branch }} - environment_to_deploy: 'providers-integration-tests' + environment_to_deploy: "providers-integration-tests" secrets: docker_registry: ${{ secrets.DOCKER_REGISTRY }} organization_id: ${{ secrets.ORGANIZATION_ID }} @@ -55,7 +59,11 @@ jobs: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} wait-for-deployment-to-be-ready-and-trigger-master-dag: - needs: [deploy-rc-testing-branch-to-astro-cloud, check-airflow-provider-rc-release] + needs: + [ + deploy-rc-testing-branch-to-astro-cloud, + check-airflow-provider-rc-release, + ] if: | always() && needs.deploy-rc-testing-branch-to-astro-cloud.result == 'success' @@ -73,11 +81,15 @@ jobs: needs: check-airflow-provider-rc-release if: | always() && - needs.check-airflow-provider-rc-release.result == 'success' + ( + needs.check-airflow-provider-rc-release.outputs.rc_issue_url != '' || + inputs.issue_url != '' + ) && + needs.check-airflow-provider-rc-release.outputs.no_provider_changed != 'true' uses: ./.github/workflows/reuse-wf-deploy-to-astro-cloud.yaml with: git_rev: ${{ needs.check-airflow-provider-rc-release.outputs.rc_testing_branch }} - environment_to_deploy: 'providers-integration-tests' + environment_to_deploy: "providers-integration-tests" secrets: docker_registry: ${{ secrets.DOCKER_REGISTRY }} organization_id: ${{ secrets.ORGANIZATION_ID }} @@ -86,7 +98,11 @@ jobs: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} wait-for-deployment-to-be-ready-and-trigger-master-dag-on-GCP: - needs: [deploy-rc-testing-branch-to-astro-cloud, check-airflow-provider-rc-release] + needs: + [ + deploy-rc-testing-branch-to-astro-cloud, + check-airflow-provider-rc-release, + ] if: | always() && needs.deploy-rc-testing-branch-to-astro-cloud.result == 'success'