Skip to content

Commit b6fb6bc

Browse files
Ci optimization (#147)
* ci: optimize workflow triggers based on file paths - Add path-based filtering to all CI jobs to run only when relevant files change: - formal-spec-typecheck: only for formal-spec/ changes - simulation jobs (test/hlint/fourmolu): for simulation/, data/, cabal.project changes - sim-rs-check: for sim-rs/ and data/ changes - docs-generate-d2-diagrams: only for .d2 file changes - docs-build/publish: only for site/ directory changes - Add workflow-level path filters to prevent unnecessary workflow runs - Fix docs-publish job to only run on main branch with site/ changes - Improve change detection logic for both pull request and push events This change makes the CI more efficient by only running relevant jobs based on modified files, reducing unnecessary builds and checks.
1 parent c1d2d85 commit b6fb6bc

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
- "data/**"
1616
- "site/**"
1717
- "docs/**"
18+
<<<<<<< HEAD
19+
- "cabal.project"
20+
=======
21+
>>>>>>> main
1822
push:
1923
branches:
2024
- main
@@ -25,6 +29,10 @@ on:
2529
- "data/**"
2630
- "site/**"
2731
- "docs/**"
32+
<<<<<<< HEAD
33+
- "cabal.project"
34+
=======
35+
>>>>>>> main
2836

2937
jobs:
3038
################################################################################
@@ -33,7 +41,13 @@ jobs:
3341
formal-spec-typecheck:
3442
name: "formal-spec: Typecheck"
3543
if: |
44+
<<<<<<< HEAD
45+
github.event_name == 'push' &&
46+
contains(github.event.commits.*.modified, 'formal-spec/') ||
47+
github.event_name == 'pull_request' &&
48+
=======
3649
github.event_name == 'push' ||
50+
>>>>>>> main
3751
contains(github.event.pull_request.files.*.path, 'formal-spec/')
3852
runs-on: ubuntu-22.04
3953
steps:
@@ -78,9 +92,20 @@ jobs:
7892
simulation-test:
7993
name: "simulation: Test on ${{ matrix.os }} with GHC ${{ matrix.ghc-version }}"
8094
if: |
95+
<<<<<<< HEAD
96+
github.event_name == 'push' &&
97+
(contains(github.event.commits.*.modified, 'simulation/') ||
98+
contains(github.event.commits.*.modified, 'data/') ||
99+
contains(github.event.commits.*.modified, 'cabal.project')) ||
100+
github.event_name == 'pull_request' &&
101+
(contains(github.event.pull_request.files.*.path, 'simulation/') ||
102+
contains(github.event.pull_request.files.*.path, 'data/') ||
103+
contains(github.event.pull_request.files.*.path, 'cabal.project'))
104+
=======
81105
github.event_name == 'push' ||
82106
contains(github.event.pull_request.files.*.path, 'simulation/') ||
83107
contains(github.event.pull_request.files.*.path, 'data/')
108+
>>>>>>> main
84109
runs-on: ${{ matrix.os }}
85110
strategy:
86111
fail-fast: false
@@ -148,9 +173,20 @@ jobs:
148173
simulation-hlint:
149174
name: "simulation: Check with HLint"
150175
if: |
176+
<<<<<<< HEAD
177+
github.event_name == 'push' &&
178+
(contains(github.event.commits.*.modified, 'simulation/') ||
179+
contains(github.event.commits.*.modified, 'data/') ||
180+
contains(github.event.commits.*.modified, 'cabal.project')) ||
181+
github.event_name == 'pull_request' &&
182+
(contains(github.event.pull_request.files.*.path, 'simulation/') ||
183+
contains(github.event.pull_request.files.*.path, 'data/') ||
184+
contains(github.event.pull_request.files.*.path, 'cabal.project'))
185+
=======
151186
github.event_name == 'push' ||
152187
contains(github.event.pull_request.files.*.path, 'simulation/') ||
153188
contains(github.event.pull_request.files.*.path, 'data/')
189+
>>>>>>> main
154190
runs-on: ubuntu-22.04
155191
steps:
156192
- name: 📥 Checkout repository
@@ -168,9 +204,20 @@ jobs:
168204
simulation-fourmolu:
169205
name: "simulation: Check with fourmolu"
170206
if: |
207+
<<<<<<< HEAD
208+
github.event_name == 'push' &&
209+
(contains(github.event.commits.*.modified, 'simulation/') ||
210+
contains(github.event.commits.*.modified, 'data/') ||
211+
contains(github.event.commits.*.modified, 'cabal.project')) ||
212+
github.event_name == 'pull_request' &&
213+
(contains(github.event.pull_request.files.*.path, 'simulation/') ||
214+
contains(github.event.pull_request.files.*.path, 'data/') ||
215+
contains(github.event.pull_request.files.*.path, 'cabal.project'))
216+
=======
171217
github.event_name == 'push' ||
172218
contains(github.event.pull_request.files.*.path, 'simulation/') ||
173219
contains(github.event.pull_request.files.*.path, 'data/')
220+
>>>>>>> main
174221
runs-on: ubuntu-22.04
175222
steps:
176223
- name: 📥 Checkout repository
@@ -188,9 +235,18 @@ jobs:
188235
sim-rs-check:
189236
name: "sim-rs: Test"
190237
if: |
238+
<<<<<<< HEAD
239+
github.event_name == 'push' &&
240+
(contains(github.event.commits.*.modified, 'sim-rs/') ||
241+
contains(github.event.commits.*.modified, 'data/')) ||
242+
github.event_name == 'pull_request' &&
243+
(contains(github.event.pull_request.files.*.path, 'sim-rs/') ||
244+
contains(github.event.pull_request.files.*.path, 'data/'))
245+
=======
191246
github.event_name == 'push' ||
192247
contains(github.event.pull_request.files.*.path, 'sim-rs/') ||
193248
contains(github.event.pull_request.files.*.path, 'data/')
249+
>>>>>>> main
194250
runs-on: ubuntu-22.04
195251
steps:
196252
- uses: actions/checkout@v4
@@ -210,7 +266,13 @@ jobs:
210266
docs-generate-d2-diagrams:
211267
name: "docs: Generate D2 Diagrams"
212268
if: |
269+
<<<<<<< HEAD
270+
github.event_name == 'push' &&
271+
endsWith(github.event.commits.*.modified, '.d2') ||
272+
github.event_name == 'pull_request' &&
273+
=======
213274
github.event_name == 'push' ||
275+
>>>>>>> main
214276
endsWith(github.event.pull_request.files.*.path, '.d2')
215277
runs-on: ubuntu-22.04
216278
permissions:
@@ -272,7 +334,13 @@ jobs:
272334
docs-build:
273335
name: "docs: Build"
274336
if: |
337+
<<<<<<< HEAD
338+
github.event_name == 'push' &&
339+
contains(github.event.commits.*.modified, 'site/') ||
340+
github.event_name == 'pull_request' &&
341+
=======
275342
github.event_name == 'push' ||
343+
>>>>>>> main
276344
contains(github.event.pull_request.files.*.path, 'site/')
277345
runs-on: ubuntu-22.04
278346
outputs:

0 commit comments

Comments
 (0)