diff --git a/.github/workflows/devbuild.yml b/.github/workflows/devbuild.yml index 5dfe66664..49080b64c 100644 --- a/.github/workflows/devbuild.yml +++ b/.github/workflows/devbuild.yml @@ -373,15 +373,41 @@ jobs: name: modmesh-pilot-win64 path: modmesh-pilot-win64/ - send_email_on_failure: + fail_on_cancelled_jobs: needs: [standalone_buffer, build, build_windows] - # Run if any of the dependencies failed in master branch + # Keep this job running when a needed job fails or is cancelled. + # See: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idneeds + if: ${{ always() }} + runs-on: ubuntu-24.04 + steps: + - name: Fail on cancelled jobs + run: | + failed=0 + for job_result in \ + "standalone_buffer:${{ needs.standalone_buffer.result }}" \ + "build:${{ needs.build.result }}" \ + "build_windows:${{ needs.build_windows.result }}" + do + job_name="${job_result%%:*}" + result="${job_result#*:}" + echo "${job_name}: ${result}" + if [ "${result}" = "cancelled" ]; then + failed=1 + fi + done + exit "${failed}" + + send_email_on_failure: + needs: [standalone_buffer, build, build_windows, fail_on_cancelled_jobs] + # Run if any of the dependencies failed or timed out in master branch if: ${{ always() && contains(needs.*.result, 'failure') && github.ref_name == 'master' && github.event.repository.fork == false }} uses: ./.github/workflows/send_email_on_fail.yml with: job_results: | - standalone_buffer: ${{ needs.standalone_buffer.result }} - build: ${{ needs.build.result }} + - build_windows: ${{ needs.build_windows.result }} + - fail_on_cancelled_jobs: ${{ needs.fail_on_cancelled_jobs.result }} secrets: EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }} EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 97409732c..cb6e6b66b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -104,14 +104,30 @@ jobs: CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \ CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)" - send_email_on_failure: + fail_on_cancelled_jobs: needs: [lint] - # Run if any of the dependencies failed in master branch + # Keep this job running when a needed job fails or is cancelled. + # See: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idneeds + if: ${{ always() }} + runs-on: ubuntu-24.04 + steps: + - name: Fail on cancelled jobs + run: | + result="${{ needs.lint.result }}" + echo "lint: ${result}" + if [ "${result}" = "cancelled" ]; then + exit 1 + fi + + send_email_on_failure: + needs: [lint, fail_on_cancelled_jobs] + # Run if any of the dependencies failed or timed out in master branch if: ${{ always() && contains(needs.*.result, 'failure') && github.ref_name == 'master' && github.event.repository.fork == false }} uses: ./.github/workflows/send_email_on_fail.yml with: job_results: | - lint: ${{ needs.lint.result }} + - fail_on_cancelled_jobs: ${{ needs.fail_on_cancelled_jobs.result }} secrets: EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }} EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} diff --git a/.github/workflows/nouse_install.yml b/.github/workflows/nouse_install.yml index dbac925fd..416c35981 100644 --- a/.github/workflows/nouse_install.yml +++ b/.github/workflows/nouse_install.yml @@ -85,14 +85,30 @@ jobs: pytest --rootdir=. -v cd .. - send_email_on_failure: + fail_on_cancelled_jobs: needs: [nouse_install] - # Run if any of the dependencies failed in master branch + # Keep this job running when a needed job fails or is cancelled. + # See: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idneeds + if: ${{ always() }} + runs-on: ubuntu-24.04 + steps: + - name: Fail on cancelled jobs + run: | + result="${{ needs.nouse_install.result }}" + echo "nouse_install: ${result}" + if [ "${result}" = "cancelled" ]; then + exit 1 + fi + + send_email_on_failure: + needs: [nouse_install, fail_on_cancelled_jobs] + # Run if any of the dependencies failed or timed out in master branch if: ${{ always() && contains(needs.*.result, 'failure') && github.ref_name == 'master' && github.event.repository.fork == false }} uses: ./.github/workflows/send_email_on_fail.yml with: job_results: | - nouse_install: ${{ needs.nouse_install.result }} + - fail_on_cancelled_jobs: ${{ needs.fail_on_cancelled_jobs.result }} secrets: EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }} EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} diff --git a/.github/workflows/profiling.yml b/.github/workflows/profiling.yml index 092584607..caf969127 100644 --- a/.github/workflows/profiling.yml +++ b/.github/workflows/profiling.yml @@ -74,13 +74,29 @@ jobs: run: | make pyprof - send_email_on_failure: + fail_on_cancelled_jobs: needs: [profile] - if: ${{ always() && (needs.*.result == 'failure') && github.ref_name == 'master' && github.event.repository.fork == false }} + # Keep this job running when a needed job fails or is cancelled. + # See: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idneeds + if: ${{ always() }} + runs-on: ubuntu-24.04 + steps: + - name: Fail on cancelled jobs + run: | + result="${{ needs.profile.result }}" + echo "profile: ${result}" + if [ "${result}" = "cancelled" ]; then + exit 1 + fi + + send_email_on_failure: + needs: [profile, fail_on_cancelled_jobs] + if: ${{ always() && contains(needs.*.result, 'failure') && github.ref_name == 'master' && github.event.repository.fork == false }} uses: ./.github/workflows/send_email_on_fail.yml with: job_results: | - profile: ${{ needs.profile.result }} + - fail_on_cancelled_jobs: ${{ needs.fail_on_cancelled_jobs.result }} secrets: EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }} EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}