Skip to content

Commit 97b6a8f

Browse files
ci: Only run CI when necessary (#168)
Signed-off-by: AlexNg <contact@ngjx.org>
1 parent ead2b87 commit 97b6a8f

File tree

4 files changed

+123
-2
lines changed

4 files changed

+123
-2
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,39 @@ name: Deploy Documentation
22

33
on:
44
push:
5+
branches:
6+
- main
57
pull_request:
68
workflow_dispatch:
79

810
jobs:
11+
changed-files:
12+
name: Changed Files
13+
runs-on: ubuntu-latest
14+
outputs:
15+
docs-change: ${{ steps.changed-files.outputs.docs-change_any_modified == 'true' }}
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 50 # Assume PRs are less than 50 commits
22+
23+
- name: Find changed files
24+
uses: tj-actions/changed-files@v44
25+
id: changed-files
26+
with:
27+
files_yaml: |
28+
docs-change:
29+
- .github/workflows/deploy-docs.yml
30+
- docs/**
31+
- package.json
32+
- package-lock.json
33+
934
vercel:
1035
runs-on: ubuntu-latest
36+
needs: [changed-files]
37+
if: ${{ needs.changed-files.outputs.docs-change == 'true' }}
1138

1239
steps:
1340
- name: Checkout Code

.github/workflows/draft-release-tag.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ permissions:
1010

1111
jobs:
1212
update_release_draft:
13+
runs-on: ubuntu-latest
1314
permissions:
1415
contents: write
1516
pull-requests: read
1617

17-
runs-on: ubuntu-latest
1818
steps:
1919
# Drafts your next Release notes as Pull Requests are merged into "master"
2020
- uses: release-drafter/release-drafter@v6

.github/workflows/linter.yml

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,63 @@
11
name: Linting
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
48

59
env:
610
PIP_DISABLE_PIP_VERSION_CHECK: 1
711

812
jobs:
13+
changed-files:
14+
name: Changed Files
15+
runs-on: ubuntu-latest
16+
outputs:
17+
docs-change: ${{ steps.changed-files.outputs.docs-change_any_modified == 'true' }}
18+
python-change: ${{ steps.changed-files.outputs.python-change_any_modified == 'true' }}
19+
project-change: ${{ steps.changed-files.outputs.project-change_any_modified == 'true' }}
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 50 # Assume PRs are less than 50 commits
26+
27+
- name: Find changed files
28+
uses: tj-actions/changed-files@v44
29+
id: changed-files
30+
with:
31+
files_yaml: |
32+
common: &common
33+
- .github/workflows/linter.yml
34+
35+
docs-change:
36+
- *common
37+
- docs/**
38+
- package.json
39+
- package-lock.json
40+
41+
python-change:
42+
- *common
43+
- src/**
44+
- tests/**
45+
- ruff.toml
46+
- poetry.lock
47+
- pyproject.toml
48+
49+
project-change:
50+
- *common
51+
- package.json
52+
- .prettierignore
53+
- .github/ISSUE_TEMPLATE/**
54+
- .github/*.md
55+
956
lint-python:
1057
name: Python
1158
runs-on: ubuntu-latest
59+
needs: [changed-files]
60+
if: ${{ needs.changed-files.outputs.python-change == 'true' }}
1261

1362
steps:
1463
- name: Checkout repository
@@ -33,6 +82,8 @@ jobs:
3382
lint-docs:
3483
name: Docs
3584
runs-on: ubuntu-latest
85+
needs: [changed-files]
86+
if: ${{ needs.changed-files.outputs.docs-change == 'true' }}
3687

3788
steps:
3889
- name: Checkout repository
@@ -56,6 +107,8 @@ jobs:
56107
lint-project:
57108
name: Project
58109
runs-on: ubuntu-latest
110+
needs: [changed-files]
111+
if: ${{ needs.changed-files.outputs.project-change == 'true' }}
59112

60113
steps:
61114
- name: Checkout repository
@@ -86,4 +139,5 @@ jobs:
86139
- name: Whether the whole linting suite passed
87140
uses: re-actors/alls-green@v1.2.2
88141
with:
142+
allowed-skips: ${{ toJSON(needs) }}
89143
jobs: ${{ toJSON(needs) }}

.github/workflows/test-worker.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Run Test Suite
22

33
on:
44
push:
5+
branches:
6+
- main
57
pull_request:
68
workflow_dispatch:
79

@@ -21,9 +23,44 @@ concurrency:
2123
group: ${{ github.workflow }}-${{ github.ref }}
2224

2325
jobs:
26+
changed-files:
27+
name: Changed Files
28+
runs-on: ubuntu-latest
29+
outputs:
30+
docs-change: ${{ steps.changed-files.outputs.docs-change_any_modified == 'true' }}
31+
python-change: ${{ steps.changed-files.outputs.python-change_any_modified == 'true' }}
32+
project-change: ${{ steps.changed-files.outputs.project-change_any_modified == 'true' }}
33+
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 50 # Assume PRs are less than 50 commits
39+
40+
- name: Find changed files
41+
uses: tj-actions/changed-files@v44
42+
id: changed-files
43+
with:
44+
files_yaml: |
45+
common: &common
46+
- .github/workflows/test-worker.yml
47+
48+
docs-change:
49+
- *common
50+
- docs/**
51+
- package.json
52+
- package-lock.json
53+
54+
python-change:
55+
- *common
56+
- src/**
57+
- tests/**
58+
2459
test-python:
2560
name: "${{ matrix.python-version }} on ${{ matrix.os }}"
2661
runs-on: "${{ matrix.os }}-latest"
62+
needs: [changed-files]
63+
if: ${{ needs.changed-files.outputs.python-change == 'true' }}
2764

2865
continue-on-error: ${{ startsWith(matrix.python-version, '~') }} # Allows unstable Python versions to fail
2966

@@ -59,6 +96,8 @@ jobs:
5996
test-docs:
6097
name: Docs
6198
runs-on: ubuntu-latest
99+
needs: [changed-files]
100+
if: ${{ needs.changed-files.outputs.docs-change == 'true' }}
62101

63102
steps:
64103
- name: Checkout repository
@@ -89,4 +128,5 @@ jobs:
89128
- name: Whether the whole test suite passed
90129
uses: re-actors/alls-green@v1.2.2
91130
with:
131+
allowed-skips: ${{ toJSON(needs) }}
92132
jobs: ${{ toJSON(needs) }}

0 commit comments

Comments
 (0)