From 2576af9e92f4cf50ee56f80550de00c846b80343 Mon Sep 17 00:00:00 2001 From: Mustafa Kemal Gilor Date: Mon, 7 Apr 2025 17:44:52 +0300 Subject: [PATCH 1/4] [gh/wf/linux.yml] set concurrency.cancel-in-progress to true allow in progress workflows to be cancelled when an external event requests, (e.g. the workflow run has been superseded with a new commit). Signed-off-by: Mustafa Kemal Gilor --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 6c9166259a..2185745d23 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -24,7 +24,7 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.event.number && format('pr{0}', github.event.number) || github.run_id }} - cancel-in-progress: ${{ github.event_name == 'merge_group' }} + cancel-in-progress: true jobs: Lint: From d8e4a20267878634cf34ac9fd2fb0a450e4ecb9c Mon Sep 17 00:00:00 2001 From: Mustafa Kemal Gilor Date: Mon, 7 Apr 2025 17:48:17 +0300 Subject: [PATCH 2/4] [gh/wf/linux.yml] set group name based on gh doc recommendations https://docs.github.com/en/enterprise-cloud@latest/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs Signed-off-by: Mustafa Kemal Gilor --- .github/workflows/linux.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2185745d23..cbab0f4c10 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -23,8 +23,8 @@ on: types: [checks_requested] concurrency: - group: ${{ github.workflow }}-${{ github.event.number && format('pr{0}', github.event.number) || github.run_id }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true # jobs: Lint: @@ -64,6 +64,9 @@ jobs: echo "${MATRIX}" | jq -cs '{"include": . }' | awk '{ print "matrix=" $0 }' >> $GITHUB_OUTPUT BuildAndTest: + concurrency: + group: ${{ github.workflow }}-buildtest-${{ github.head_ref || github.run_id }}-${{ matrix.build-type }} + cancel-in-progress: true needs: [Lint, GetMatrix] # Allow skipped Lint From 566db1966b207cd7dbab9fe936164c2d99726b50 Mon Sep 17 00:00:00 2001 From: Mustafa Kemal Gilor Date: Fri, 18 Apr 2025 11:23:29 +0300 Subject: [PATCH 3/4] [gh/wf/linux.yml] sprinkle some job-level !cancelled() checks also replace instances of !failed() with success(). Signed-off-by: Mustafa Kemal Gilor --- .github/workflows/linux.yml | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index cbab0f4c10..a000198f52 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -24,13 +24,13 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true # + cancel-in-progress: true jobs: Lint: runs-on: ubuntu-latest - if: ${{ contains('pull_request merge_group', github.event_name) }} + if: ${{ !cancelled() && contains('pull_request merge_group', github.event_name) }} steps: - name: Check out code @@ -64,20 +64,14 @@ jobs: echo "${MATRIX}" | jq -cs '{"include": . }' | awk '{ print "matrix=" $0 }' >> $GITHUB_OUTPUT BuildAndTest: - concurrency: - group: ${{ github.workflow }}-buildtest-${{ github.head_ref || github.run_id }}-${{ matrix.build-type }} - cancel-in-progress: true needs: [Lint, GetMatrix] # Allow skipped Lint # Let Lint fail on pull requests - if: | - ${{ - success() - || needs.Lint.result == 'skipped' - || ( needs.Lint.result == 'failure' - && github.event_name == 'pull_request' ) - }} + if: ${{ !cancelled() && (success() || + needs.Lint.result == 'skipped' || + (needs.Lint.result == 'failure' && github.event_name == 'pull_request') + )}} outputs: label: ${{ steps.build-params.outputs.label }} @@ -312,9 +306,7 @@ jobs: Publish-Snap: needs: BuildAndTest # Need to explicitly continue on Lint getting skipped. - if: ${{ - !failure() - && !cancelled() + if: ${{ !cancelled() && success() && needs.BuildAndTest.outputs.channel != '' && (github.event_name == 'push' || github.event_name == 'merge_group' @@ -347,9 +339,7 @@ jobs: # Only dispatch if we have access to secrets. # Need to explicitly continue on Lint getting skipped. - if: ${{ - !failure() - && !cancelled() + if: ${{ !cancelled() && success() && (github.event_name == 'push' || github.event_name == 'merge_group' || github.event.pull_request.head.repo.full_name == github.repository) From 614b3bdcd7812b6bd7805726aee59d67e8636587 Mon Sep 17 00:00:00 2001 From: Mustafa Kemal Gilor Date: Mon, 21 Apr 2025 14:16:54 +0300 Subject: [PATCH 4/4] [gh/wf/linux.yml] fix alignment and readability of condition Signed-off-by: Mustafa Kemal Gilor --- .github/workflows/linux.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a000198f52..20809e22a4 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -68,10 +68,16 @@ jobs: # Allow skipped Lint # Let Lint fail on pull requests - if: ${{ !cancelled() && (success() || - needs.Lint.result == 'skipped' || - (needs.Lint.result == 'failure' && github.event_name == 'pull_request') - )}} + if: ${{ !cancelled() && + ( + success() || + needs.Lint.result == 'skipped' || + ( + needs.Lint.result == 'failure' && + github.event_name == 'pull_request' + ) + ) + }} outputs: label: ${{ steps.build-params.outputs.label }}