git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] ci: respect the [skip ci] convention in our GitHub workflow "CI/PR"

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
May 2, 2020, 15:08 UTC
Message-ID
<pull.776.git.git.1588432087854.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

It might have been invented by Travis CI (at least it is described here: https://docs.travis-ci.com/user/customizing-the-build/#skipping-a-build) to avoid unnecessary builds: if the tip commit message (or for PR builds, the PR description) contains the needle `[skip ci]`, then the build is skipped.

Unlike Azure Pipelines, GitHub workflows does not support that feature out of the box (at least not at the time of writing), but we can reinstate it manually.

Note: GitHub workflows might implement this at some stage. In the least,
the desire for this feature is expressed, together with some history, at
https://github.community/t5/GitHub-Actions/GitHub-Actions-does-not-respect-skip-ci/m-p/42834

While it is the number five in the kudo ranking of the GitHub Actions posts, it might take a while given the current state of the world. In the meantime let's do the manual thing.

Following Travis CI's example, we also add special handling to exclude the PR build when the PR title or description (or any other part of the pull request information provided by the GitHub event) contains the needle `[skip pr]`.

Note: for technical reasons, a PR build will still run if a commit
message contains the needle `[skip ci]` but neither PR title nor
description contain the needle `[skip pr]`: for PR builds, the commit
messages are not part of the payload delivered via the event.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
    ci: allow skipping CI/PR builds on GitHub
    
    It was mentioned to me that it might not be totally helpful to run all 
    the builds whenever an in-progress branch is pushed to GitHub. For
    example, if a contributor has dozens of topic branches in flight, they
    might not want to have all of them built whenever a new end-of-day push
    happens.
    
    This patch tries to address that, by following the convention that I
    believe Travis CI invented: if a commit message contains the needle 
    [skip ci], any CI build (i.e. a build triggered by a push) is skipped.
    Likewise, PR builds are skipped when the PR title and/or description
    contains [skip pr].
    
    Ideally, GitHub workflows will support this feature at some stage, but
    until then, we could have this (admittedly not very elegant) workaround.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-776%2Fdscho%2Fskip-ci-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-776/dscho/skip-ci-v1
Pull-Request: https://github.com/git/git/pull/776
 .github/workflows/main.yml | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index fd4df939b50..0e4a280d309 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -7,6 +7,7 @@ env:
 
 jobs:
   windows-build:
+    if: "!contains(toJSON(github.event.commits.*.message), '[skip ci]') && !contains(toJSON(github.event.pull_request), '[skip pr]')"
     runs-on: windows-latest
     steps:
     - uses: actions/checkout@v1
@@ -70,6 +71,7 @@ jobs:
         name: failed-tests-windows
         path: ${{env.FAILED_TEST_ARTIFACTS}}
   vs-build:
+    if: "!contains(toJSON(github.event.commits.*.message), '[skip ci]') && !contains(toJSON(github.event.pull_request), '[skip pr]')"
     env:
       MSYSTEM: MINGW64
       NO_PERL: 1
@@ -154,6 +156,7 @@ jobs:
                           ${{matrix.nr}} 10 t[0-9]*.sh)
         "@
   regular:
+    if: "!contains(toJSON(github.event.commits.*.message), '[skip ci]') && !contains(toJSON(github.event.pull_request), '[skip pr]')"
     strategy:
       matrix:
         vector:
@@ -189,6 +192,7 @@ jobs:
         name: failed-tests-${{matrix.vector.jobname}}
         path: ${{env.FAILED_TEST_ARTIFACTS}}
   dockerized:
+    if: "!contains(toJSON(github.event.commits.*.message), '[skip ci]') && !contains(toJSON(github.event.pull_request), '[skip pr]')"
     strategy:
       matrix:
         vector:
@@ -213,6 +217,7 @@ jobs:
         name: failed-tests-${{matrix.vector.jobname}}
         path: ${{env.FAILED_TEST_ARTIFACTS}}
   static-analysis:
+    if: "!contains(toJSON(github.event.commits.*.message), '[skip ci]') && !contains(toJSON(github.event.pull_request), '[skip pr]')"
     env:
       jobname: StaticAnalysis
     runs-on: ubuntu-latest
@@ -221,6 +226,7 @@ jobs:
     - run: ci/install-dependencies.sh
     - run: ci/run-static-analysis.sh
   documentation:
+    if: "!contains(toJSON(github.event.commits.*.message), '[skip ci]') && !contains(toJSON(github.event.pull_request), '[skip pr]')"
     env:
       jobname: Documentation
     runs-on: ubuntu-latest

base-commit: b34789c0b0d3b137f0bb516b417bd8d75e0cb306
-- 
gitgitgadget
Next: Jeff King
Message 1 of 62 in “ci: respect the [skip ci] convention in our GitHub workflow "CI/PR"”
  1. ci: respect the [skip ci] convention in our GitHub workflow "CI/PR"Johannes Schindelin via GitGitGadget, May 2, 2020
  2. Jeff KingMay 3, 2020
  3. Danh DoanMay 3, 2020
  4. Jeff KingMay 4, 2020
  5. 0/2 Limit GitHub Actions to designated branchesĐoàn Trần Công Danh, May 4, 2020
  6. 1/2 CI: limit GitHub Actions to designated branchesĐoàn Trần Công Danh, May 4, 2020
  7. Jeff KingMay 4, 2020
  8. Taylor BlauMay 4, 2020
  9. Junio C HamanoMay 4, 2020
  10. Taylor BlauMay 4, 2020
  11. Jeff KingMay 4, 2020
  12. Junio C HamanoMay 5, 2020
  13. Jeff KingMay 4, 2020
  14. Taylor BlauMay 5, 2020
  15. Jeff KingMay 5, 2020
  16. Junio C HamanoMay 5, 2020
  17. Jeff KingMay 5, 2020
  18. Jeff KingMay 5, 2020
  19. Junio C HamanoMay 5, 2020
  20. Jeff KingMay 5, 2020
  21. Junio C HamanoMay 5, 2020
  22. Johannes SchindelinMay 6, 2020
  23. Junio C HamanoMay 6, 2020
  24. Jeff KingMay 7, 2020
  25. Jeff KingMay 7, 2020
  26. Junio C HamanoMay 7, 2020
  27. Đoàn Trần Công DanhMay 7, 2020
  28. Đoàn Trần Công DanhMay 7, 2020
  29. Đoàn Trần Công DanhMay 6, 2020
  30. Junio C HamanoMay 6, 2020
  31. Đoàn Trần Công DanhMay 6, 2020
  32. Junio C HamanoMay 6, 2020
  33. Jeff KingMay 7, 2020
  34. Junio C HamanoMay 7, 2020
  35. Jeff KingMay 7, 2020
  36. Junio C HamanoMay 7, 2020
  37. ci: allow per-branch config for GitHub ActionsJeff King, May 7, 2020
  38. Taylor BlauMay 7, 2020
  39. Jeff KingMay 7, 2020
  40. Junio C HamanoMay 7, 2020
  41. Jeff KingMay 7, 2020
  42. Junio C HamanoMay 7, 2020
  43. Jeff KingMay 8, 2020
  44. Đoàn Trần Công DanhMay 9, 2020
  45. Đoàn Trần Công DanhMay 5, 2020
  46. 2/2 SubmittingPatches: advertise GitHub Actions CIĐoàn Trần Công Danh, May 4, 2020
  47. Junio C HamanoMay 4, 2020
  48. Đoàn Trần Công DanhMay 5, 2020
  49. 0/3 Provide option to opt in/out GitHub ActionsĐoàn Trần Công Danh, May 5, 2020
  50. 1/3 SubmittingPatches: advertise GitHub Actions CIĐoàn Trần Công Danh, May 5, 2020
  51. Jeff KingMay 5, 2020
  52. Đoàn Trần Công DanhMay 5, 2020
  53. Jeff KingMay 5, 2020
  54. 2/3 CI: limit GitHub Actions to designated branchesĐoàn Trần Công Danh, May 5, 2020
  55. Jeff KingMay 5, 2020
  56. Đoàn Trần Công DanhMay 5, 2020
  57. Jeff KingMay 5, 2020
  58. Junio C HamanoMay 5, 2020
  59. 3/3 fixup! CI: limit GitHub Actions to designated branchesĐoàn Trần Công Danh, May 5, 2020
  60. Junio C HamanoMay 5, 2020
  61. Jeff KingMay 5, 2020
  62. Junio C HamanoMay 3, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.