All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ci: respect the [skip ci] convention in our GitHub workflow "CI/PR"
@ 2020-05-02 15:08 Johannes Schindelin via GitGitGadget
  2020-05-03  9:36 ` Jeff King
  0 siblings, 1 reply; 62+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2020-05-02 15:08 UTC (permalink / raw)
  To: git; +Cc: Jeff King, Jeff Hostetler, Johannes Schindelin, Johannes Schindelin

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

^ permalink raw reply related	[flat|nested] 62+ messages in thread

end of thread, other threads:[~2020-05-09  1:23 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02 15:08 [PATCH] ci: respect the [skip ci] convention in our GitHub workflow "CI/PR" Johannes Schindelin via GitGitGadget
2020-05-03  9:36 ` Jeff King
2020-05-03 12:05   ` Danh Doan
2020-05-04 15:01     ` Jeff King
2020-05-04 15:49       ` [PATCH v2 0/2] Limit GitHub Actions to designated branches Đoàn Trần Công Danh
2020-05-04 15:49         ` [PATCH v2 1/2] CI: limit " Đoàn Trần Công Danh
2020-05-04 16:23           ` Jeff King
2020-05-04 21:58             ` Taylor Blau
2020-05-04 22:52               ` Junio C Hamano
2020-05-04 23:15                 ` Taylor Blau
2020-05-04 23:35                   ` Jeff King
2020-05-05  0:24                     ` Junio C Hamano
2020-05-04 23:36               ` Jeff King
2020-05-05  0:20                 ` Taylor Blau
2020-05-05 16:43                   ` Jeff King
2020-05-05 17:57                     ` Junio C Hamano
2020-05-05 18:24                       ` Jeff King
2020-05-05 21:04                         ` Jeff King
2020-05-05 21:29                           ` Junio C Hamano
2020-05-05 21:58                             ` Jeff King
2020-05-05 22:28                               ` Junio C Hamano
2020-05-06 15:09                             ` Johannes Schindelin
2020-05-06 16:26                               ` Junio C Hamano
2020-05-07 12:17                                 ` Jeff King
2020-05-07 14:02                                   ` Jeff King
2020-05-07 18:17                                     ` Junio C Hamano
2020-05-07 12:01                               ` Đoàn Trần Công Danh
2020-05-07 12:47                                 ` Đoàn Trần Công Danh
2020-05-06  0:46                           ` Đoàn Trần Công Danh
2020-05-06  3:56                             ` Junio C Hamano
2020-05-06 14:25                               ` Đoàn Trần Công Danh
2020-05-06 16:31                                 ` Junio C Hamano
2020-05-07 12:25                                   ` Jeff King
2020-05-07 18:29                                     ` Junio C Hamano
2020-05-07 18:54                                       ` Jeff King
2020-05-07 19:33                                         ` Junio C Hamano
2020-05-07 16:20                           ` [PATCH v2] ci: allow per-branch config for GitHub Actions Jeff King
2020-05-07 17:00                             ` Taylor Blau
2020-05-07 17:18                               ` Jeff King
2020-05-07 19:53                             ` Junio C Hamano
2020-05-07 20:46                               ` Jeff King
2020-05-07 21:58                                 ` Junio C Hamano
2020-05-08 18:00                                   ` Jeff King
2020-05-09  1:23                                     ` Đoàn Trần Công Danh
2020-05-05  0:34             ` [PATCH v2 1/2] CI: limit GitHub Actions to designated branches Đoàn Trần Công Danh
2020-05-04 15:49         ` [PATCH v2 2/2] SubmittingPatches: advertise GitHub Actions CI Đoàn Trần Công Danh
2020-05-04 16:37           ` Junio C Hamano
2020-05-05  0:46             ` Đoàn Trần Công Danh
2020-05-05 16:26         ` [PATCH v3 0/3] Provide option to opt in/out GitHub Actions Đoàn Trần Công Danh
2020-05-05 16:26           ` [PATCH v3 1/3] SubmittingPatches: advertise GitHub Actions CI Đoàn Trần Công Danh
2020-05-05 16:47             ` Jeff King
2020-05-05 16:59               ` Đoàn Trần Công Danh
2020-05-05 17:07                 ` Jeff King
2020-05-05 16:26           ` [PATCH v3 2/3] CI: limit GitHub Actions to designated branches Đoàn Trần Công Danh
2020-05-05 16:51             ` Jeff King
2020-05-05 17:05               ` Đoàn Trần Công Danh
2020-05-05 17:11                 ` Jeff King
2020-05-05 18:49             ` Junio C Hamano
2020-05-05 16:26           ` [PATCH v3 3/3] fixup! " Đoàn Trần Công Danh
2020-05-05 18:59             ` Junio C Hamano
2020-05-05 17:01           ` [PATCH v3 0/3] Provide option to opt in/out GitHub Actions Jeff King
2020-05-03 16:46   ` [PATCH] ci: respect the [skip ci] convention in our GitHub workflow "CI/PR" Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.