From 4e9fc5a90fe40c494ac405f07f4f5deb7b3ac9b2 Mon Sep 17 00:00:00 2001 From: Adrian Moldovan Date: Tue, 2 Apr 2024 20:40:24 +0300 Subject: [PATCH] [testing workflows] Tweak conditions for Slack alerts and reports publishing jobs (#46031) --- .github/workflows/ci.yml | 45 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08d69f9fdbb..1130db61261 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -241,10 +241,10 @@ jobs: fi echo "All jobs have completed successfully." - publish-e2e-test-reports: - name: 'Publish e2e test reports' + e2e-test-reports: + name: 'Report e2e tests results' needs: [ project-e2e-test-jobs ] - if: ${{ contains( needs.*.result, 'success' ) || contains( needs.*.result, 'failure' ) }} + if: ${{ ! cancelled() && needs.project-e2e-test-jobs.result != 'skipped' }} runs-on: ubuntu-latest steps: @@ -275,49 +275,42 @@ jobs: if-no-files-found: ignore retention-days: 5 - - name: 'Publish reports' + - name: 'Send workflow dispatch' env: GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} RUN_ID: ${{ github.run_id }} - COMMIT_SHA: ${{ github.event.pull_request.head.sha }} run: | if [ "$GITHUB_EVENT_NAME" == pull_request ]; then gh workflow run publish-test-reports-pr.yml \ -f run_id=$RUN_ID \ -f e2e_artifact=e2e-test-report \ -f pr_number=$PR_NUMBER \ - -f commit_sha=$COMMIT_SHA \ + -f commit_sha=$GITHUB_SHA \ -f s3_root=public \ --repo woocommerce/woocommerce-test-reports else gh workflow run publish-test-reports-trunk-merge.yml \ -f run_id=$RUN_ID \ -f artifact=e2e-test-report \ - -f pr_number='' \ + -f pr_number=$PR_NUMBER \ + -f commit_sha=$GITHUB_SHA \ -f test_type="e2e" \ --repo woocommerce/woocommerce-test-reports fi - - - slack-alert-e2e-test: - name: 'Send Slack alert for e2e tests' - needs: [ project-e2e-test-jobs ] - if: ${{ github.event_name != 'pull_request' && ( contains( needs.*.result, 'success' ) || contains( needs.*.result, 'failure' ) ) }} - runs-on: ubuntu-latest - - steps: + - name: 'Send Slack notification' + if: github.event_name != 'pull_request' uses: automattic/action-test-results-to-slack@v0.3.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} slack_token: ${{ secrets.E2E_SLACK_TOKEN }} slack_channel: ${{ secrets.E2E_TRUNK_SLACK_CHANNEL }} - publish-api-test-reports: - name: 'Publish API test reports' + api-test-reports: + name: 'Report API tests results' needs: [ project-api-test-jobs ] - if: ${{ contains( needs.*.result, 'success' ) || contains( needs.*.result, 'failure' ) }} + if: ${{ ! cancelled() && needs.project-api-test-jobs.result != 'skipped'}} runs-on: ubuntu-latest steps: @@ -353,21 +346,29 @@ jobs: GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} RUN_ID: ${{ github.run_id }} - COMMIT_SHA: ${{ github.event.pull_request.head.sha }} run: | if [ "$GITHUB_EVENT_NAME" == pull_request ]; then gh workflow run publish-test-reports-pr.yml \ -f run_id=$RUN_ID \ -f api_artifact=api-test-report \ -f pr_number=$PR_NUMBER \ - -f commit_sha=$COMMIT_SHA \ + -f commit_sha=$GITHUB_SHA \ -f s3_root=public \ --repo woocommerce/woocommerce-test-reports else gh workflow run publish-test-reports-trunk-merge.yml \ -f run_id=$RUN_ID \ -f artifact=api-test-report \ - -f pr_number='' \ + -f pr_number=$PR_NUMBER \ + -f commit_sha=$GITHUB_SHA \ -f test_type="api" \ --repo woocommerce/woocommerce-test-reports fi + + - name: 'Send Slack notification' + if: github.event_name != 'pull_request' + uses: automattic/action-test-results-to-slack@v0.3.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + slack_token: ${{ secrets.E2E_SLACK_TOKEN }} + slack_channel: ${{ secrets.E2E_TRUNK_SLACK_CHANNEL }}