Skip to content

Commit c5c50cc

Browse files
authored
ci: Introduce <backend|sphinx> jobs as "all green" required jobs (#1514)
Some changes to prepare the setup of the GH merge queue, for which we need to specify the jobs required to succeed: - Set filenames as workflow/job names to avoid confusion, - Add `backend` job that can be used as required ๐ŸŸข job, - Add `sphinx` job that can be used as required ๐ŸŸข job, - Add explicit restricted permissions to the `sphinx`ย workflow (no worries, they were already restricted to read-only). --- For a job to be required, its **workflow** has to be executed and not skipped. Before this PR, we skipped entire workflow via path filtering, which is incompatible with "required jobs". https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks ![image](https://github.com/user-attachments/assets/a48bab3f-c361-4a55-b933-9cf94057f26c) Now we always execute workflows, but skip jobs individually based on modified files.
1 parent c1d59d3 commit c5c50cc

File tree

8 files changed

+196
-48
lines changed

8 files changed

+196
-48
lines changed

โ€Ž.github/workflows/backend.ymlโ€Ž

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ name: backend
22

33
on:
44
pull_request:
5-
paths:
6-
- '.github/workflows/backend.yml'
7-
- 'skore/**'
85
push:
96
branches:
107
- main
@@ -15,22 +12,44 @@ concurrency:
1512
group: ${{ github.workflow }}-${{ github.ref }}
1613
cancel-in-progress: true
1714

18-
permissions:
19-
contents: read
15+
permissions: {}
2016

2117
defaults:
2218
run:
2319
shell: "bash"
2420

2521
jobs:
22+
backend-changes:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
changes: ${{ steps.filter.outputs.backend }}
26+
permissions:
27+
pull-requests: read
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
31+
32+
- name: Define if at least one file has changed
33+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
34+
id: filter
35+
with:
36+
filters: |
37+
backend:
38+
- '.github/workflows/backend.yml'
39+
- 'skore/**'
40+
2641
backend-lint:
2742
runs-on: "ubuntu-latest"
43+
needs: [backend-changes]
44+
if: ${{ (github.event_name == 'push') || (needs.backend-changes.outputs.changes == 'true') }}
45+
permissions:
46+
contents: read
2847
steps:
2948
- name: Checkout code
30-
uses: actions/checkout@v4
49+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3150

3251
- name: Setup Python
33-
uses: actions/setup-python@v5
52+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
3453
with:
3554
python-version: "3.12"
3655
cache: pip
@@ -46,10 +65,13 @@ jobs:
4665
4766
backend-lockfiles:
4867
runs-on: "ubuntu-latest"
49-
if: ${{ github.event_name == 'pull_request' }}
68+
needs: [backend-changes]
69+
if: ${{ (contains(fromJSON('["pull_request", "merge_group"]'), github.event_name)) && (needs.backend-changes.outputs.changes == 'true') }}
70+
permissions:
71+
contents: read
5072
steps:
5173
- name: Checkout code
52-
uses: actions/checkout@v4
74+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5375
with:
5476
fetch-depth: 2
5577

@@ -66,6 +88,8 @@ jobs:
6688
fi
6789
6890
backend-test:
91+
needs: [backend-changes]
92+
if: ${{ (github.event_name == 'push') || (needs.backend-changes.outputs.changes == 'true') }}
6993
strategy:
7094
fail-fast: false
7195
matrix:
@@ -84,20 +108,22 @@ jobs:
84108
scikit-learn: "1.6"
85109
coverage: true
86110
runs-on: ${{ matrix.os }}
111+
permissions:
112+
contents: read
87113
steps:
88114
- name: Checkout code
89-
uses: actions/checkout@v4
115+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
90116

91117
- name: Setup Python
92-
uses: actions/setup-python@v5
118+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
93119
id: setup-python
94120
with:
95121
python-version: ${{ matrix.python }}
96122
check-latest: True
97123
cache: pip
98124

99125
- name: Restore python-venv
100-
uses: actions/cache/restore@v4
126+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
101127
id: cache-python-venv
102128
with:
103129
path: 'skore/venv'
@@ -132,7 +158,7 @@ jobs:
132158
python -m pip install --requirement test-requirements.txt
133159
134160
- name: Save python-venv
135-
uses: actions/cache/save@v4
161+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
136162
if: steps.cache-python-venv.outputs.cache-hit != 'true'
137163
with:
138164
path: 'skore/venv'
@@ -148,8 +174,7 @@ jobs:
148174

149175
- name: Show dependencies versions
150176
working-directory: skore/
151-
run: |
152-
python -c "import skore; skore.show_versions()"
177+
run: python -c 'import skore; skore.show_versions()'
153178

154179
- name: Test without coverage
155180
if: ${{ ! matrix.coverage }}
@@ -167,7 +192,20 @@ jobs:
167192
168193
- name: Upload coverage reports
169194
if: ${{ matrix.coverage && (github.event_name == 'pull_request') }}
170-
uses: actions/upload-artifact@v4
195+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
171196
with:
172197
name: backend-coverage
173198
path: skore/coverage/
199+
200+
backend:
201+
needs:
202+
- backend-changes
203+
- backend-lint
204+
- backend-lockfiles
205+
- backend-test
206+
if: ${{ always() }}
207+
runs-on: Ubuntu-latest
208+
steps:
209+
- shell: bash
210+
run: |
211+
[[ ${{ contains(needs.*.result, 'failure') }} = false ]]

โ€Ž.github/workflows/pr-add-assignee.ymlโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: add assignee in PR
1+
name: pr-add-assignee
22

33
on:
44
pull_request_target:
@@ -7,7 +7,7 @@ on:
77
permissions: {}
88

99
jobs:
10-
add-assignee:
10+
pr-add-assignee:
1111
runs-on: ubuntu-latest
1212
permissions:
1313
pull-requests: write

โ€Ž.github/workflows/pr-cleanup.ymlโ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: cleanup PR
1+
name: pr-cleanup
22

33
on:
44
pull_request_target:
@@ -11,7 +11,7 @@ defaults:
1111
shell: "bash"
1212

1313
jobs:
14-
clean-artifacts:
14+
pr-clean-artifacts:
1515
if: always()
1616
runs-on: ubuntu-latest
1717
permissions:
@@ -55,7 +55,7 @@ jobs:
5555
HEAD_REPOSITORY_ID: ${{ github.event.pull_request.head.repo.id }}
5656
HEAD_BRANCH: ${{ github.head_ref }}
5757

58-
clean-documentation-preview:
58+
pr-clean-documentation-preview:
5959
if: always()
6060
runs-on: ubuntu-latest
6161
steps:

โ€Ž.github/workflows/pr-display-backend-coverage.ymlโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: display backend coverage in PR
1+
name: pr-display-backend-coverage
22

33
on:
44
workflow_run:
@@ -12,7 +12,7 @@ concurrency:
1212
permissions: {}
1313

1414
jobs:
15-
display-backend-coverage:
15+
pr-display-backend-coverage:
1616
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
1717
runs-on: ubuntu-latest
1818
permissions:

โ€Ž.github/workflows/pr-lint-title.ymlโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: lint title in PR
1+
name: pr-lint-title
22

33
on:
44
pull_request:
@@ -8,7 +8,7 @@ permissions:
88
pull-requests: read
99

1010
jobs:
11-
lint-title:
11+
pr-lint-title:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/setup-node@v4

โ€Ž.github/workflows/pr-serve-documentation-preview.ymlโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: serve documentation preview in PR
1+
name: pr-serve-documentation-preview
22

33
on:
44
workflow_run:
@@ -12,7 +12,7 @@ concurrency:
1212
permissions: {}
1313

1414
jobs:
15-
serve-documentation-preview:
15+
pr-serve-documentation-preview:
1616
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
1717
runs-on: ubuntu-latest
1818
permissions:

โ€Ž.github/workflows/sphinx.ymlโ€Ž

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,9 @@ name: sphinx
4848

4949
on:
5050
pull_request:
51-
paths:
52-
- '.github/actions/sphinx/**'
53-
- '.github/workflows/sphinx.yml'
54-
- 'examples/**'
55-
- 'sphinx/**'
56-
- 'skore/**'
5751
push:
5852
branches:
5953
- main
60-
paths:
61-
- '.github/actions/sphinx/**'
62-
- '.github/workflows/sphinx.yml'
63-
- 'examples/**'
64-
- 'sphinx/**'
65-
- 'skore/**'
6654
release:
6755
types: [released]
6856
merge_group:
@@ -72,9 +60,35 @@ concurrency:
7260
group: ${{ github.workflow }}-${{ github.ref }}
7361
cancel-in-progress: true
7462

63+
permissions: {}
64+
7565
jobs:
66+
sphinx-changes:
67+
runs-on: ubuntu-latest
68+
outputs:
69+
changes: ${{ steps.filter.outputs.sphinx }}
70+
permissions:
71+
pull-requests: read
72+
steps:
73+
- name: Checkout code
74+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
75+
76+
- name: Define if at least one file has changed
77+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
78+
id: filter
79+
with:
80+
filters: |
81+
sphinx:
82+
- '.github/actions/sphinx/**'
83+
- '.github/workflows/sphinx.yml'
84+
- 'examples/**'
85+
- 'sphinx/**'
86+
- 'skore/**'
87+
7688
sphinx-version:
7789
runs-on: ubuntu-latest
90+
needs: [sphinx-changes]
91+
if: ${{ (contains(fromJSON('["push", "release"]'), github.event_name)) || (needs.sphinx-changes.outputs.changes == 'true') }}
7892
outputs:
7993
SPHINX_VERSION: ${{ steps.sphinx-version.outputs.SPHINX_VERSION }}
8094
SPHINX_RELEASE: ${{ steps.sphinx-version.outputs.SPHINX_RELEASE }}
@@ -99,12 +113,15 @@ jobs:
99113
100114
sphinx-build:
101115
runs-on: ubuntu-latest
102-
needs: sphinx-version
116+
needs: [sphinx-version]
117+
if: ${{ (contains(fromJSON('["push", "release"]'), github.event_name)) || (needs.sphinx-changes.outputs.changes == 'true') }}
118+
permissions:
119+
contents: read
103120
steps:
104-
- uses: actions/checkout@v4
121+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
105122
with:
106123
lfs: 'true'
107-
- uses: actions/setup-python@v5
124+
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
108125
with:
109126
python-version: '3.12'
110127
cache: 'pip'
@@ -114,21 +131,25 @@ jobs:
114131
SPHINX_VERSION: ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}
115132
SPHINX_RELEASE: ${{ needs.sphinx-version.outputs.SPHINX_RELEASE }}
116133
SPHINX_DOMAIN: ${{ vars.DOCUMENTATION_DOMAIN }}
117-
- uses: actions/upload-artifact@v4
134+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
118135
with:
119136
name: sphinx-html-artifact
120137
path: sphinx/build/html/
121138

122139
sphinx-deploy-html:
123-
if: ${{ (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
140+
if: ${{ (contains(fromJSON('["push", "release"]'), github.event_name)) }}
124141
runs-on: ubuntu-latest
125142
needs: [sphinx-version, sphinx-build]
143+
permissions:
144+
contents: read
126145
steps:
127146
- name: Checkout code
128-
uses: actions/checkout@v4
147+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
148+
with:
149+
sparse-checkout: .github
129150

130151
- name: Download HTML artifacts
131-
uses: actions/download-artifact@v4
152+
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
132153
with:
133154
name: sphinx-html-artifact
134155
path: html/
@@ -145,8 +166,12 @@ jobs:
145166
if: ${{ github.event_name == 'release' }}
146167
runs-on: ubuntu-latest
147168
needs: [sphinx-version, sphinx-build, sphinx-deploy-html]
169+
permissions:
170+
contents: read
148171
steps:
149-
- uses: actions/checkout@v4
172+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
173+
with:
174+
sparse-checkout: .github
150175
- shell: python
151176
run: |
152177
import os
@@ -239,6 +264,21 @@ jobs:
239264
if: ${{ always() && (github.event_name != 'pull_request') }}
240265
needs: [sphinx-version, sphinx-build, sphinx-deploy-html, sphinx-deploy-root-files]
241266
steps:
242-
- uses: geekyeggo/delete-artifact@v5
267+
- uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
243268
with:
244269
name: sphinx-html-artifact
270+
271+
sphinx:
272+
needs:
273+
- sphinx-changes
274+
- sphinx-version
275+
- sphinx-build
276+
- sphinx-deploy-html
277+
- sphinx-deploy-root-files
278+
- sphinx-clean-artifacts
279+
if: ${{ always() }}
280+
runs-on: Ubuntu-latest
281+
steps:
282+
- shell: bash
283+
run: |
284+
[[ ${{ contains(needs.*.result, 'failure') }} = false ]]

0 commit comments

Comments
ย (0)