Skip to content

Commit 893dcdb

Browse files
BinderDavidjulialongtin
authored andcommitted
Finish improvements to the CI configuration for documentation changes (#9460)
* Add bootstrap postjob to CI config Add a new job to the bootstrap.yml GitHub action config. This job succeeds if, and only if, all the other bootstrap jobs succeed. * Do not run bootstrap CI jobs for documentation changes The approach was already introduced in #9355 for the validate jobs. This commit introduces the same change also for the bootstrap jobs. * Also ignore CONTRIBUTING.md and README.md in CI We do not run the entire CI suite for documentation changes. Previously, only changes which were restricted to the 'docs/' subdirectory were considered to be documentation changes. With this commit we also recognize changes to README.md and CONTRIBUTING.md as documentation changes. * Document improved CI for documentation in CONTRIBUTING.md The CONTRIBUTING.md file now mentions that documentation changes do not waste expensive CI resources. * Recognize all README.md in subdirs as documentation Expensive CI jobs should not run on changes which affect only README.md files.
1 parent 30e6ea7 commit 893dcdb

File tree

5 files changed

+90
-5
lines changed

5 files changed

+90
-5
lines changed

.github/workflows/bootstrap.skip.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Bootstrap Skip
2+
3+
# This Workflow is special and contains a workaround for a known limitation of GitHub CI.
4+
#
5+
# The problem: We don't want to run the "bootstrap" jobs on PRs which contain only changes
6+
# to the docs, since these jobs take a long time to complete without providing any benefit.
7+
# We therefore use path-filtering in the workflow triggers for the bootstrap jobs, namely
8+
# "paths-ignore: doc/**". But the "Bootstrap post job" is a required job, therefore a PR cannot
9+
# be merged unless the "Bootstrap post job" completes succesfully, which it doesn't do if we
10+
# filter it out.
11+
#
12+
# The solution: We use a second job with the same name which always returns the exit code 0.
13+
# The logic implemented for "required" workflows accepts if 1) at least one job with that name
14+
# runs through, AND 2) If multiple jobs of that name exist, then all jobs of that name have to
15+
# finish successfully.
16+
on:
17+
push:
18+
paths:
19+
- 'doc/**'
20+
- '**/README.md'
21+
- 'CONTRIBUTING.md'
22+
branches:
23+
- master
24+
pull_request:
25+
paths:
26+
- 'doc/**'
27+
- '**/README.md'
28+
- 'CONTRIBUTING.md'
29+
release:
30+
types:
31+
- created
32+
33+
jobs:
34+
bootstrap-post-job:
35+
if: always()
36+
name: Bootstrap post job
37+
runs-on: ubuntu-latest
38+
steps:
39+
- run: exit 0

.github/workflows/bootstrap.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@ concurrency:
55
group: ${{ github.ref }}-${{ github.workflow }}
66
cancel-in-progress: true
77

8+
# Note: This workflow file contains the required job "Bootstrap post job". We are using path filtering
9+
# here to ignore PRs which only change documentation. This can cause a problem, see the workflow file
10+
# "bootstrap.skip.yml" for a description of the problem and the solution provided in that file.
811
on:
912
push:
13+
paths-ignore:
14+
- 'doc/**'
15+
- '**/README.md'
16+
- 'CONTRIBUTING.md'
1017
branches:
1118
- master
1219
pull_request:
20+
paths-ignore:
21+
- 'doc/**'
22+
- '**/README.md'
23+
- 'CONTRIBUTING.md'
1324
release:
1425
types:
1526
- created
@@ -66,3 +77,20 @@ jobs:
6677
with:
6778
name: cabal-${{ matrix.os }}-${{ matrix.ghc }}-bootstrapped
6879
path: _build/artifacts/*
80+
81+
# We use this job as a summary of the workflow
82+
# It will fail if any of the previous jobs does it
83+
# This way we can use it exclusively in branch protection rules
84+
# and abstract away the concrete jobs of the workflow, including their names
85+
bootstrap-post-job:
86+
if: always()
87+
name: Bootstrap post job
88+
runs-on: ubuntu-latest
89+
# IMPORTANT! Any job added to the workflow should be added here too
90+
needs: [bootstrap]
91+
92+
steps:
93+
- run: |
94+
echo "jobs info: ${{ toJSON(needs) }}"
95+
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
96+
run: exit 1

.github/workflows/validate.skip.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: Validate Skip
55
# The problem: We don't want to run the "validate" jobs on PRs which contain only changes
66
# to the docs, since these jobs take a long time to complete without providing any benefit.
77
# We therefore use path-filtering in the workflow triggers for the validate jobs, namely
8-
# "paths_ignore: doc/**". But the "Validate post job" is a required job, therefore a PR cannot
8+
# "paths-ignore: doc/**". But the "Validate post job" is a required job, therefore a PR cannot
99
# be merged unless the "Validate post job" completes succesfully, which it doesn't do if we
1010
# filter it out.
1111
#
@@ -15,11 +15,17 @@ name: Validate Skip
1515
# finish successfully.
1616
on:
1717
push:
18-
paths: 'doc/**'
18+
paths:
19+
- 'doc/**'
20+
- '**/README.md'
21+
- 'CONTRIBUTING.md'
1922
branches:
2023
- master
2124
pull_request:
22-
paths: 'doc/**'
25+
paths:
26+
- 'doc/**'
27+
- '**/README.md'
28+
- 'CONTRIBUTING.md'
2329
release:
2430
types:
2531
- created

.github/workflows/validate.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@ concurrency:
1616
# "validate.skip.yml" for a description of the problem and the solution provided in that file.
1717
on:
1818
push:
19-
paths-ignore: 'doc/**'
19+
paths-ignore:
20+
- 'doc/**'
21+
- '**/README.md'
22+
- 'CONTRIBUTING.md'
2023
branches:
2124
- master
2225
pull_request:
23-
paths-ignore: 'doc/**'
26+
paths-ignore:
27+
- 'doc/**'
28+
- '**/README.md'
29+
- 'CONTRIBUTING.md'
2430
release:
2531
types:
2632
- created

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ Some tips for using GitHub Actions effectively:
5151
sure everything is OK; otherwise, try to run relevant tests locally
5252
first.
5353
54+
* If you are only changing documentation in the `docs/` subdirectory,
55+
or if you change `README.md` or `CONTRIBUTING.md`, then we only run a
56+
small subset of the CI jobs. You can therefore open small PRs with
57+
improvements to the documentation without feeling guilty about wasted
58+
resources!
59+
5460
* Watch over your jobs on the [GitHub Actions website](http://github.org/haskell/cabal/actions).
5561
If you know a build of yours is going to fail (because one job has
5662
already failed), be nice to others and cancel the rest of the jobs,

0 commit comments

Comments
 (0)