{"thread":{"id":"58767","subject":"[PATCH 0/1] ci: avoid unnecessary builds, with ci-config","startedAt":"2022-11-08T18:25:48Z","lastAt":"2022-11-08T20:09:39Z","messageCount":5,"participants":["Taylor Blau","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"466868","messageId":"cover.1667931937.git.me@ttaylorr.com","threadId":"58767","inReplyTo":null,"subject":"[PATCH 0/1] ci: avoid unnecessary builds, with ci-config","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-11-08T18:25:42Z","receivedAt":"2022-11-08T18:25:48Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"This is an alternative approach to Johannes's patch in [1], which\ncancels running GitHub Actions workflows when newer ones appear via the\n'concurrency' controls.\n\nThough the original patch was promising, it does not satisfy all\nworkflows. A couple examples:\n\n  - ÆVar points out in [2] that he pushes a topic branch multiple times\n    while working on it to see where CI breaks along a stream of\n    commits.\n\n  - Junio points out in [3] that he will often push various combinations\n    of topics merged into 'seen' to try and \"bisect\" the culprit when\n    debugging CI failures.\n\nOn the other hand, being able to cancel previously initiated runs of a\nworkflow on a given branch name is useful when the branch has been\nupdated locally and the results of the in-progress CI run are no longer\ninteresting.\n\nThis patch takes an alternative approach to the original patch in [1] by\nusing the same ci-config mechanism to cancel in-progress jobs when newer\nones appear only when configured to do so.\n\nThe original patch I posted with this approach in [4] had syntax issues.\nThis approach works as expected.\n\nThanks in advance for your review.\n\n[1]: https://lore.kernel.org/git/pull.1404.git.1667482458622.gitgitgadget@gmail.com/\n[2]: https://lore.kernel.org/git/221104.86bkpnzdqi.gmgdl@evledraar.gmail.com/\n[3]: https://lore.kernel.org/git/xmqqk046cmmv.fsf@gitster.g/\n[4]: https://lore.kernel.org/git/Y2R3vJf1A2KOZwA7@nand.local/\n\nTaylor Blau (1):\n  ci: avoid unnecessary builds\n\n .github/workflows/check-whitespace.yml |  6 ++++\n .github/workflows/l10n.yml             |  6 ++++\n .github/workflows/main.yml             | 40 ++++++++++++++++++++++++--\n 3 files changed, 50 insertions(+), 2 deletions(-)\n\n-- \n2.38.0.16.g393fd4c6db\n"},{"id":"466869","messageId":"ff172f1de982f6f79b598e4ac6d5b2964ca4a098.1667931937.git.me@ttaylorr.com","threadId":"58767","inReplyTo":"cover.1667931937.git.me@ttaylorr.com","subject":"[PATCH 1/1] ci: avoid unnecessary builds","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-11-08T18:25:45Z","receivedAt":"2022-11-08T18:25:52Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"Whenever a branch is pushed to a repository which has GitHub Actions\nenabled, a bunch of new workflow runs are started.\n\nWe sometimes see contributors push multiple branch updates in rapid\nsuccession, which in conjunction with the impressive time swallowed by\neven just a single CI build frequently leads to many queued-up runs.\n\nThis is particularly problematic in the case of Pull Requests where a\nsingle contributor can easily (inadvertently) prevent timely builds for\nother contributors when using a shared repository.\n\nTo help with this situation, let's use the `concurrency` feature of\nGitHub workflows, essentially canceling GitHub workflow runs that are\nobsoleted by more recent runs:\n\n  https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency\n\nFor workflows that *do* want the behavior in the pre-image of this\npatch, they can use the ci-config feature to disable the new behavior by\nadding an executable script on the ci-config branch called\n'skip-concurrent' which terminates with a non-zero exit code.\n\nOriginal-patch-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nSigned-off-by: Taylor Blau <me@ttaylorr.com>\n---\n .github/workflows/check-whitespace.yml |  6 ++++\n .github/workflows/l10n.yml             |  6 ++++\n .github/workflows/main.yml             | 40 ++++++++++++++++++++++++--\n 3 files changed, 50 insertions(+), 2 deletions(-)\n\ndiff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml\nindex ad3466ad16..0bcc9cffbd 100644\n--- a/.github/workflows/check-whitespace.yml\n+++ b/.github/workflows/check-whitespace.yml\n@@ -9,6 +9,12 @@ on:\n   pull_request:\n     types: [opened, synchronize]\n \n+# Avoid unnecessary builds. Unlike the main CI jobs, these are not\n+# ci-configurable (but could be).\n+concurrency:\n+  group: ${{ github.workflow }}-${{ github.ref }}\n+  cancel-in-progress: true\n+\n jobs:\n   check-whitespace:\n     runs-on: ubuntu-latest\ndiff --git a/.github/workflows/l10n.yml b/.github/workflows/l10n.yml\nindex 27f72f0ff3..51fd46e6af 100644\n--- a/.github/workflows/l10n.yml\n+++ b/.github/workflows/l10n.yml\n@@ -2,6 +2,12 @@ name: git-l10n\n \n on: [push, pull_request_target]\n \n+# Avoid unnecessary builds. Unlike the main CI jobs, these are not\n+# ci-configurable (but could be).\n+concurrency:\n+  group: ${{ github.workflow }}-${{ github.ref }}\n+  cancel-in-progress: true\n+\n jobs:\n   git-po-helper:\n     if: >-\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex bd6f75b8e0..d27cd44584 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -11,6 +11,7 @@ jobs:\n     runs-on: ubuntu-latest\n     outputs:\n       enabled: ${{ steps.check-ref.outputs.enabled }}${{ steps.skip-if-redundant.outputs.enabled }}\n+      skip_concurrent: ${{ steps.check-ref.outputs.skip_concurrent }}\n     steps:\n       - name: try to clone ci-config branch\n         run: |\n@@ -34,7 +35,15 @@ jobs:\n           then\n             enabled=no\n           fi\n+\n+          skip_concurrent=yes\n+          if test -x config-repo/ci/config/skip-concurrent &&\n+             ! config-repo/ci/config/skip-concurrent '${{ github.ref }}'\n+          then\n+            skip_concurrent=no\n+          fi\n           echo \"::set-output name=enabled::$enabled\"\n+          echo \"::set-output name=skip_concurrent::$skip_concurrent\"\n       - name: skip if the commit or tree was already tested\n         id: skip-if-redundant\n         uses: actions/github-script@v3\n@@ -82,6 +91,9 @@ jobs:\n     needs: ci-config\n     if: needs.ci-config.outputs.enabled == 'yes'\n     runs-on: windows-latest\n+    concurrency:\n+      group: windows-build-${{ github.ref }}\n+      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n     steps:\n     - uses: actions/checkout@v2\n     - uses: git-for-windows/setup-git-for-windows-sdk@v1\n@@ -101,11 +113,14 @@ jobs:\n   windows-test:\n     name: win test\n     runs-on: windows-latest\n-    needs: [windows-build]\n+    needs: [ci-config, windows-build]\n     strategy:\n       fail-fast: false\n       matrix:\n         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n+    concurrency:\n+      group: windows-test-${{ matrix.nr }}-${{ github.ref }}\n+      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n     steps:\n     - name: download tracked files and build artifacts\n       uses: actions/download-artifact@v2\n@@ -137,6 +152,9 @@ jobs:\n       NO_PERL: 1\n       GIT_CONFIG_PARAMETERS: \"'user.name=CI' 'user.email=ci@git'\"\n     runs-on: windows-latest\n+    concurrency:\n+      group: vs-build-${{ github.ref }}\n+      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n     steps:\n     - uses: actions/checkout@v2\n     - uses: git-for-windows/setup-git-for-windows-sdk@v1\n@@ -184,11 +202,14 @@ jobs:\n   vs-test:\n     name: win+VS test\n     runs-on: windows-latest\n-    needs: vs-build\n+    needs: [ci-config, vs-build]\n     strategy:\n       fail-fast: false\n       matrix:\n         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n+    concurrency:\n+      group: vs-test-${{ matrix.nr }}-${{ github.ref }}\n+      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n     steps:\n     - uses: git-for-windows/setup-git-for-windows-sdk@v1\n     - name: download tracked files and build artifacts\n@@ -218,6 +239,9 @@ jobs:\n     name: ${{matrix.vector.jobname}} (${{matrix.vector.pool}})\n     needs: ci-config\n     if: needs.ci-config.outputs.enabled == 'yes'\n+    concurrency:\n+      group: ${{ matrix.vector.jobname }}-${{ matrix.vector.pool }}-${{ github.ref }}\n+      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n     strategy:\n       fail-fast: false\n       matrix:\n@@ -281,6 +305,9 @@ jobs:\n     name: ${{matrix.vector.jobname}} (${{matrix.vector.image}})\n     needs: ci-config\n     if: needs.ci-config.outputs.enabled == 'yes'\n+    concurrency:\n+      group: dockerized-${{ matrix.vector.jobname }}-${{ matrix.vector.image }}-${{ github.ref }}\n+      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n     strategy:\n       fail-fast: false\n       matrix:\n@@ -316,6 +343,9 @@ jobs:\n     env:\n       jobname: StaticAnalysis\n     runs-on: ubuntu-22.04\n+    concurrency:\n+      group: static-analysis-${{ github.ref }}\n+      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n     steps:\n     - uses: actions/checkout@v2\n     - run: ci/install-dependencies.sh\n@@ -327,6 +357,9 @@ jobs:\n     env:\n       jobname: sparse\n     runs-on: ubuntu-20.04\n+    concurrency:\n+      group: sparse-${{ github.ref }}\n+      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n     steps:\n     - name: Download a current `sparse` package\n       # Ubuntu's `sparse` version is too old for us\n@@ -345,6 +378,9 @@ jobs:\n     name: documentation\n     needs: ci-config\n     if: needs.ci-config.outputs.enabled == 'yes'\n+    concurrency:\n+      group: documentation-${{ github.ref }}\n+      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n     env:\n       jobname: Documentation\n     runs-on: ubuntu-latest\n-- \n2.38.0.16.g393fd4c6db\n"},{"id":"466884","messageId":"221108.86r0ydqmts.gmgdl@evledraar.gmail.com","threadId":"58767","inReplyTo":"ff172f1de982f6f79b598e4ac6d5b2964ca4a098.1667931937.git.me@ttaylorr.com","subject":"Re: [PATCH 1/1] ci: avoid unnecessary builds","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-11-08T18:52:07Z","receivedAt":"2022-11-08T19:16:06Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Nov 08 2022, Taylor Blau wrote:\n\n> Whenever a branch is pushed to a repository which has GitHub Actions\n> enabled, a bunch of new workflow runs are started.\n>\n> We sometimes see contributors push multiple branch updates in rapid\n> succession, which in conjunction with the impressive time swallowed by\n> even just a single CI build frequently leads to many queued-up runs.\n>\n> This is particularly problematic in the case of Pull Requests where a\n> single contributor can easily (inadvertently) prevent timely builds for\n> other contributors when using a shared repository.\n>\n> To help with this situation, let's use the `concurrency` feature of\n> GitHub workflows, essentially canceling GitHub workflow runs that are\n> obsoleted by more recent runs:\n>\n>   https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency\n>\n> For workflows that *do* want the behavior in the pre-image of this\n> patch, they can use the ci-config feature to disable the new behavior by\n> adding an executable script on the ci-config branch called\n> 'skip-concurrent' which terminates with a non-zero exit code.\n\nFirst, thanks for hacking this up. I've tested this just now in my fork,\nand it seems to mostly work as advertised to me, more on the \"mostly\"\nlater.\n\nI.e. the \"cancel-in-progress\" seems to work perfectly. I pushed a branch\nwith this, it started CI, then I made a trivial update, re-pushed, and\nthe initial branch's CI run was stopped, one job at a time (not all at\nthe same time, but almost).\n\nNow, obviously it's a bit more of a verbose solution v.s. Johannes's\noriginal in [1], but on the other hand our main.yml is full of that sort\nof copy/pasting already.\n\nAside from the change under discussion I don't find that to be a big\ndeal. It's a general \"problem\", and we could always generate the file\nwith a script if we really cared, but I think for the forseeable future\nthe copy/pasting is fine.\n\nBut now on the \"mostly\": I *also* observed that when I turned this off\n(I manually patched it to be \"skip_concurrent=no\" by default) the\n\"re-push\" wouldn't run anything yet, because it was waiting on the other\nrun. A little \"clock\" icon is shown, and clicking on the job shows e.g.:\n\n\t Waiting: This workflow is waiting on sparse to complete before running. \n\nThe \"sparse\" is then a link to the in-progress \"sparse\" run in the\n\"other job\".\n\nSo, completely aside from any catering to my (or anyone else's[2]?)\nexisting workflow around re-pushes (which I'll freely admit may or may\nnot be worth the effort), I think this change also has the presumably\nunintended effect of changing how CI jobs are queued.\n\nWhich is that our workers were before scheduled per-repo (I think), and\nyou have a finite amount, but they're assigned generally (just from my\nobservation) in FIFO order based on the jobs that need to be run.\n\nBut now you have a queue that'll be piled up on the \"repo/workflow/ref\"\nkey. So that e.g. if you have 10 outstanding runs, 10 workers, and all\nthe pushes have finished except for their \"linux-asan\" job (or whatever\nthe slowest one happens to be) that you're only going to run one of\nthose \"linux-asan\" jobs at a time.\n\nNow, I think this only matters *if* you flip the \"cancel-in-progress\" to\n\"false\", so it was a moot point in the original [1]. I.e. you wouldn't\nget concurrency anyway, so it didn't matter how things were queued.\n\nThis seems pretty clear from the API docs:\n\n\tUse concurrency to ensure that only a single job or workflow\n\tusing the same concurrency group will run at a time.\n\nI'm less sure about GitHub, but in other CI systems (e.g. GitLab's) a\n\"concurrency\" feature like that is mainly targeted at jobs that\ne.g. need some external resource (say a RDBMS), so you really want that\nkind of throttling.\n\nI don't know if there's a workaround for that, I'd think it would be the\nlogical equivalent of e.g.:\n\n\tgroup: sparse-${{ matrix.nr }}-${{ github.ref }}-${{ needs.ci-config.outputs.skip_concurrent ? github.run_id : \"\" }}\n\nBut the docs say \"The expression can only use the github context.\"[3],\nand I don't know if such a thing would fit inside the syntax...\n\n\n1. https://lore.kernel.org/git/pull.1404.git.1667482458622.gitgitgadget@gmail.com/\n2. https://lore.kernel.org/git/75ono097-16nr-nno4-rqoq-rrn79spps249@tzk.qr/\n3. https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency\n\n\n> diff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml\n> index ad3466ad16..0bcc9cffbd 100644\n> --- a/.github/workflows/check-whitespace.yml\n> +++ b/.github/workflows/check-whitespace.yml\n> @@ -9,6 +9,12 @@ on:\n>    pull_request:\n>      types: [opened, synchronize]\n>  \n> +# Avoid unnecessary builds. Unlike the main CI jobs, these are not\n> +# ci-configurable (but could be).\n> +concurrency:\n> +  group: ${{ github.workflow }}-${{ github.ref }}\n> +  cancel-in-progress: true\n> +\n>  jobs:\n>    check-whitespace:\n>      runs-on: ubuntu-latest\n> diff --git a/.github/workflows/l10n.yml b/.github/workflows/l10n.yml\n> index 27f72f0ff3..51fd46e6af 100644\n> --- a/.github/workflows/l10n.yml\n> +++ b/.github/workflows/l10n.yml\n> @@ -2,6 +2,12 @@ name: git-l10n\n>  \n>  on: [push, pull_request_target]\n>  \n> +# Avoid unnecessary builds. Unlike the main CI jobs, these are not\n> +# ci-configurable (but could be).\n> +concurrency:\n> +  group: ${{ github.workflow }}-${{ github.ref }}\n> +  cancel-in-progress: true\n> +\n>  jobs:\n>    git-po-helper:\n>      if: >-\n> diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\n> index bd6f75b8e0..d27cd44584 100644\n> --- a/.github/workflows/main.yml\n> +++ b/.github/workflows/main.yml\n> @@ -11,6 +11,7 @@ jobs:\n>      runs-on: ubuntu-latest\n>      outputs:\n>        enabled: ${{ steps.check-ref.outputs.enabled }}${{ steps.skip-if-redundant.outputs.enabled }}\n> +      skip_concurrent: ${{ steps.check-ref.outputs.skip_concurrent }}\n>      steps:\n>        - name: try to clone ci-config branch\n>          run: |\n> @@ -34,7 +35,15 @@ jobs:\n>            then\n>              enabled=no\n>            fi\n> +\n> +          skip_concurrent=yes\n> +          if test -x config-repo/ci/config/skip-concurrent &&\n> +             ! config-repo/ci/config/skip-concurrent '${{ github.ref }}'\n> +          then\n> +            skip_concurrent=no\n> +          fi\n>            echo \"::set-output name=enabled::$enabled\"\n> +          echo \"::set-output name=skip_concurrent::$skip_concurrent\"\n>        - name: skip if the commit or tree was already tested\n>          id: skip-if-redundant\n>          uses: actions/github-script@v3\n> @@ -82,6 +91,9 @@ jobs:\n>      needs: ci-config\n>      if: needs.ci-config.outputs.enabled == 'yes'\n>      runs-on: windows-latest\n> +    concurrency:\n> +      group: windows-build-${{ github.ref }}\n> +      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n>      steps:\n>      - uses: actions/checkout@v2\n>      - uses: git-for-windows/setup-git-for-windows-sdk@v1\n> @@ -101,11 +113,14 @@ jobs:\n>    windows-test:\n>      name: win test\n>      runs-on: windows-latest\n> -    needs: [windows-build]\n> +    needs: [ci-config, windows-build]\n>      strategy:\n>        fail-fast: false\n>        matrix:\n>          nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n> +    concurrency:\n> +      group: windows-test-${{ matrix.nr }}-${{ github.ref }}\n> +      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n>      steps:\n>      - name: download tracked files and build artifacts\n>        uses: actions/download-artifact@v2\n> @@ -137,6 +152,9 @@ jobs:\n>        NO_PERL: 1\n>        GIT_CONFIG_PARAMETERS: \"'user.name=CI' 'user.email=ci@git'\"\n>      runs-on: windows-latest\n> +    concurrency:\n> +      group: vs-build-${{ github.ref }}\n> +      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n>      steps:\n>      - uses: actions/checkout@v2\n>      - uses: git-for-windows/setup-git-for-windows-sdk@v1\n> @@ -184,11 +202,14 @@ jobs:\n>    vs-test:\n>      name: win+VS test\n>      runs-on: windows-latest\n> -    needs: vs-build\n> +    needs: [ci-config, vs-build]\n>      strategy:\n>        fail-fast: false\n>        matrix:\n>          nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n> +    concurrency:\n> +      group: vs-test-${{ matrix.nr }}-${{ github.ref }}\n> +      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n>      steps:\n>      - uses: git-for-windows/setup-git-for-windows-sdk@v1\n>      - name: download tracked files and build artifacts\n> @@ -218,6 +239,9 @@ jobs:\n>      name: ${{matrix.vector.jobname}} (${{matrix.vector.pool}})\n>      needs: ci-config\n>      if: needs.ci-config.outputs.enabled == 'yes'\n> +    concurrency:\n> +      group: ${{ matrix.vector.jobname }}-${{ matrix.vector.pool }}-${{ github.ref }}\n> +      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n>      strategy:\n>        fail-fast: false\n>        matrix:\n> @@ -281,6 +305,9 @@ jobs:\n>      name: ${{matrix.vector.jobname}} (${{matrix.vector.image}})\n>      needs: ci-config\n>      if: needs.ci-config.outputs.enabled == 'yes'\n> +    concurrency:\n> +      group: dockerized-${{ matrix.vector.jobname }}-${{ matrix.vector.image }}-${{ github.ref }}\n> +      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n>      strategy:\n>        fail-fast: false\n>        matrix:\n> @@ -316,6 +343,9 @@ jobs:\n>      env:\n>        jobname: StaticAnalysis\n>      runs-on: ubuntu-22.04\n> +    concurrency:\n> +      group: static-analysis-${{ github.ref }}\n> +      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n>      steps:\n>      - uses: actions/checkout@v2\n>      - run: ci/install-dependencies.sh\n> @@ -327,6 +357,9 @@ jobs:\n>      env:\n>        jobname: sparse\n>      runs-on: ubuntu-20.04\n> +    concurrency:\n> +      group: sparse-${{ github.ref }}\n> +      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n>      steps:\n>      - name: Download a current `sparse` package\n>        # Ubuntu's `sparse` version is too old for us\n> @@ -345,6 +378,9 @@ jobs:\n>      name: documentation\n>      needs: ci-config\n>      if: needs.ci-config.outputs.enabled == 'yes'\n> +    concurrency:\n> +      group: documentation-${{ github.ref }}\n> +      cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}\n>      env:\n>        jobname: Documentation\n>      runs-on: ubuntu-latest\n\n"},{"id":"466891","messageId":"Y2q3QZDxuywzCexn@nand.local","threadId":"58767","inReplyTo":"221108.86r0ydqmts.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH 1/1] ci: avoid unnecessary builds","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-11-08T20:08:33Z","receivedAt":"2022-11-08T20:08:40Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Tue, Nov 08, 2022 at 07:52:07PM +0100, Ævar Arnfjörð Bjarmason wrote:\n> I don't know if there's a workaround for that, I'd think it would be the\n> logical equivalent of e.g.:\n>\n> \tgroup: sparse-${{ matrix.nr }}-${{ github.ref }}-${{ needs.ci-config.outputs.skip_concurrent ? github.run_id : \"\" }}\n\nHmm. Did you mean the opposite of the last part of that expression? IOW,\nshouldn't it be:\n\n  ${{ needs.ci-config.outputs.skip_concurrent ? \"\" : github.run_id }}\n\nThat is: if we're cancelling builds when others are in progress, the\ngroup ID shouldn't contain information about the specific run ID. But if\nwe *aren't* cancelling builds, then the group needs to have the run ID\nin it, that way we're effectively disabling the new behavior altogether.\n\n> But the docs say \"The expression can only use the github context.\"[3],\n> and I don't know if such a thing would fit inside the syntax...\n\nThat's at the workflow level. When you specify a 'concurrency' block\ninside of an individual job, you can use any context object excepts the\nsecrets one [2].\n\nThanks,\nTaylor\n\n[2]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idconcurrency\n"},{"id":"466892","messageId":"Y2q3f5noQSXmK0o8@nand.local","threadId":"58767","inReplyTo":"221108.86r0ydqmts.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH 1/1] ci: avoid unnecessary builds","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-11-08T20:09:35Z","receivedAt":"2022-11-08T20:09:39Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Tue, Nov 08, 2022 at 07:52:07PM +0100, Ævar Arnfjörð Bjarmason wrote:\n> I.e. the \"cancel-in-progress\" seems to work perfectly. I pushed a branch\n> with this, it started CI, then I made a trivial update, re-pushed, and\n> the initial branch's CI run was stopped, one job at a time (not all at\n> the same time, but almost).\n\nThanks to Johannes for all of that ;-).\n\n> Now, obviously it's a bit more of a verbose solution v.s. Johannes's\n> original in [1], but on the other hand our main.yml is full of that sort\n> of copy/pasting already.\n>\n> Aside from the change under discussion I don't find that to be a big\n> deal. It's a general \"problem\", and we could always generate the file\n> with a script if we really cared, but I think for the forseeable future\n> the copy/pasting is fine.\n\nTo be fair, I think that the solution I came up with is pretty gross.\nBut after spending a few hours with the Actions docs, I think that it's\nthe least-gross solution that meets the needs of our respective\nworkflows.\n\nSo I'm OK with it.\n\nThanks,\nTaylor\n"}]}