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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Johannes Schindelin <johannes.schindelin@xxxxxx>

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@xxxxxx>
---
    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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux