From 6153cdf5f2edd91b15a67c4a80cd70f44138299a Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 28 Feb 2024 10:25:09 +0100 Subject: [PATCH] Initialize and update workflow-triggered workflows status along the way --- .github/workflows/application_build.yml | 39 +++++++++++- .github/workflows/application_deployment.yml | 18 +++++- .github/workflows/application_e2e_tests.yml | 63 +++++++++++++++++--- 3 files changed, 107 insertions(+), 13 deletions(-) diff --git a/.github/workflows/application_build.yml b/.github/workflows/application_build.yml index a5076662ab..c5a2c1ec16 100644 --- a/.github/workflows/application_build.yml +++ b/.github/workflows/application_build.yml @@ -24,10 +24,47 @@ on: - cron: "38 11 */3 * *" concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.event.push.head_commit.id }} cancel-in-progress: true jobs: + initialize_e2e_tests_job_check: + name: Initialize E2E Tests job checks + runs-on: ubuntu-22.04 + steps: + - name: Initialize Cypress E2E Tests job check + id: initialize_cypress_e2e_tests_job_check + uses: LouisBrunner/checks-action@v2.0.0 + with: + conclusion: action_required + details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}" + name: "Application E2E Tests (Cypress)" + sha: ${{ github.event.push.head_commit.id }} + status: queued + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Initialize Cypress E2E Tests job check + id: initialize_puppeteer_e2e_tests_job_check + uses: LouisBrunner/checks-action@v2.0.0 + with: + conclusion: action_required + details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}" + name: Application E2E Tests (Puppeteer) + sha: ${{ github.event.push.head_commit.id }} + status: queued + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Save job check IDs + run: | + mkdir -p workflow_share + echo "${{ steps.initialize_cypress_e2e_tests_job_check.outputs.check_id }}" > workflow_share/cypress_job_check_id + echo "${{ steps.initialize_puppeteer_e2e_tests_job_check.outputs.check_id }}" > workflow_share/puppeteer_job_check_id + + - uses: actions/upload-artifact@v4 + with: + name: workflow_share + path: workflow_share/* + build: name: Build and package runs-on: ubuntu-22.04 diff --git a/.github/workflows/application_deployment.yml b/.github/workflows/application_deployment.yml index 20c0c83689..be83ddd1d6 100644 --- a/.github/workflows/application_deployment.yml +++ b/.github/workflows/application_deployment.yml @@ -21,6 +21,16 @@ jobs: env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true steps: + - name: Initialize job status check + id: initialize_job_status_check + uses: LouisBrunner/checks-action@v2.0.0 + with: + details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}" + name: Application Deployment + sha: ${{ github.event.push.head_commit.id }} + status: in_progress + token: ${{ secrets.GITHUB_TOKEN }} + - name: Check Unit Tests status id: check_unit_tests_status uses: LASER-Yi/workflow-status@v0.0.2 @@ -50,6 +60,8 @@ jobs: - name: Push docker image to registry if: ${{ steps.check_unit_tests_status.outputs.conclusion == 'success' }} + continue-on-error: true + id: push_docker_image run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin make docker-tag @@ -58,9 +70,9 @@ jobs: - uses: LouisBrunner/checks-action@v2.0.0 if: ${{ always() }} with: - # check_id: application-deployment-${{ github.event.workflow_run.head_commit.id }} - conclusion: ${{ job.status }} + check_id: ${{ steps.initialize_job_status_check.outputs.check_id }} + conclusion: ${{ steps.push_docker_image.outcome }} details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}" - name: Application Deployment sha: ${{ github.event.workflow_run.head_commit.id }} + status: completed token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/application_e2e_tests.yml b/.github/workflows/application_e2e_tests.yml index 3109ad56bc..56313df71b 100644 --- a/.github/workflows/application_e2e_tests.yml +++ b/.github/workflows/application_e2e_tests.yml @@ -33,6 +33,25 @@ jobs: PUPPETEER_SKIP_DOWNLOAD: "true" VITE_CYPRESS_PORT: 8880 steps: + - name: "Download 'workflow_share' artifact" + uses: actions/download-artifact@v4 + with: + name: workflow_share + + - name: Set STATUS_CHECK_ID environment variable + run: | + echo "STATUS_CHECK_ID=$(cat workflow_share/cypress_job_check_id)" >> $GITHUB_ENV + + - name: Update job status check + uses: LouisBrunner/checks-action@v2.0.0 + if: ${{ always() }} + with: + check_id: ${{ env.STATUS_CHECK_ID }} + details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}" + sha: ${{ github.event.workflow_run.head_commit.id }} + status: in_progress + token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout uses: actions/checkout@v4 with: @@ -77,7 +96,10 @@ jobs: firefox -v which firefox - - uses: cypress-io/github-action@v6 + - name: Run Cypress E2E tests + id: run_cypress_e2e_tests + continue-on-error: true + uses: cypress-io/github-action@v6 with: browser: firefox config-file: config/cypress.config.ts @@ -89,14 +111,15 @@ jobs: wait-on: "http://localhost:8880" working-directory: ./frontend - - uses: LouisBrunner/checks-action@v2.0.0 + - name: set final job status check + uses: LouisBrunner/checks-action@v2.0.0 if: ${{ always() }} with: - # check_id: application-e2e-cypress-${{ github.event.workflow_run.head_commit.id }} - conclusion: ${{ job.status }} + check_id: ${{ env.STATUS_CHECK_ID }} + conclusion: ${{ steps.run_cypress_e2e_tests.outcome }} details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}" - name: Application E2E Tests (Cypress) sha: ${{ github.event.workflow_run.head_commit.id }} + status: completed token: ${{ secrets.GITHUB_TOKEN }} e2e_multi_windows_test: @@ -109,6 +132,25 @@ jobs: PUPPETEER_SKIP_DOWNLOAD: "true" VITE_CYPRESS_PORT: 8880 steps: + - name: "Download 'workflow_share' artifact" + uses: actions/download-artifact@v4 + with: + name: workflow_share + + - name: Set STATUS_CHECK_ID environment variable + run: | + echo "STATUS_CHECK_ID=$(cat workflow_share/puppeteer_job_check_id)" >> $GITHUB_ENV + + - name: Update job status check + uses: LouisBrunner/checks-action@v2.0.0 + if: ${{ always() }} + with: + check_id: ${{ env.STATUS_CHECK_ID }} + details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}" + sha: ${{ github.event.workflow_run.head_commit.id }} + status: in_progress + token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout uses: actions/checkout@v4 with: @@ -150,15 +192,18 @@ jobs: run: npx puppeteer browsers install firefox - name: Run multi-windows tests + id: run_puppeteer_e2e_tests + continue-on-error: true run: npm run test:multi-windows:run working-directory: ./frontend - - uses: LouisBrunner/checks-action@v2.0.0 + - name: Set final job status check + uses: LouisBrunner/checks-action@v2.0.0 if: ${{ always() }} with: - # check_id: application-e2e-puppeteer-${{ github.event.workflow_run.head_commit.id }} - conclusion: ${{ job.status }} + check_id: ${{ env.STATUS_CHECK_ID }} + conclusion: ${{ steps.run_puppeteer_e2e_tests.outcome }} details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}" - name: Application E2E Tests (Puppeteer) sha: ${{ github.event.workflow_run.head_commit.id }} + status: completed token: ${{ secrets.GITHUB_TOKEN }}