From 473213b7dfc68d6ae2d16e9633efbee3570bb00b Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Fri, 8 Sep 2023 20:41:40 +0200 Subject: [PATCH 1/3] .github/workflows: Cancel redundant workflow runs Evern since the move to github actions in 70daa61b (CI: add GH actions for main and release builds, 2023-04-20) we just executed the workflows for every branch push. This can quickly result in the workflow queue being clogged. There is also no point in executing older versions of the same branch when a newer version is available. The version here supports multiple workflows [1]. And also cancels, on purpose, redundant workflows on main and the release branches. See [2] for a future way to don't do that on special branches. [1]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow [2]: https://stackoverflow.com/questions/68418857/how-to-cancel-existing-runs-when-a-new-push-happens-on-github-actions-but-only --- .github/workflows/build-pr.yml | 3 +++ .github/workflows/build-release.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 7bdd96e505..0a6330019f 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -31,6 +31,9 @@ on: defaults: run: shell: bash +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: BuildInstaller: diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 86c022fed1..6050f3d021 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -8,6 +8,9 @@ on: defaults: run: shell: bash +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: CallPR: From 021a8233a299fa0ddd87b809678ca861880d6951 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Fri, 8 Sep 2023 20:49:11 +0200 Subject: [PATCH 2/3] .github/workflows: Don't execute FTPUpload job on workflow cancel The FTPUpload job is responsible for storing the job artefacts of all jobs regardless if the jobs passed or failed. But we don't need to store the artefacts if the job was cancelled. This avoids a failed job in case of cancellation and also the nagging email from github actions. --- .github/workflows/build-pr.yml | 2 +- .github/workflows/build-release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 0a6330019f..e3c914765d 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -226,7 +226,7 @@ jobs: FTPUpload: name: 📦 FTP Upload Artifacts runs-on: [ self-hosted, Linux, Docker ] - if: always() && !inputs.is_called_workflow + if: ${{ !cancelled() && !inputs.is_called_workflow}} needs: # All jobs that create new artifacts - BuildInstaller diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 6050f3d021..74bd7372fe 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -126,7 +126,7 @@ jobs: FTPUpload: name: 📦 FTP Upload Artifacts runs-on: [ self-hosted, Linux, Docker ] - if: always() + if: ${{ !cancelled() }} needs: # All jobs that create new artifacts - CallPR From 04fd05234e4f70ab21095372eb7abb14ed18df04 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 11 Sep 2023 22:01:15 +0200 Subject: [PATCH 3/3] .github/workflows/build-release.yaml: Fix deadlock on workflow skipping The recent fix in one of the previous commits (.github/workflows: Cancel redundant workflow runs, 2023-09-08) did not work for the main branch as the error message on cancelling was [1]: > Cancelling since a deadlock for concurrency group 'Build Release-refs/heads/main' > was detected between 'top level workflow' and 'CallPR' So we now only cancel the CallPR workflow. [1]: https://github.com/AllenInstitute/MIES/actions/runs/6132292975 --- .github/workflows/build-release.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 74bd7372fe..efb890d0fa 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -8,9 +8,6 @@ on: defaults: run: shell: bash -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true jobs: CallPR: