Skip to content

Commit 77eb86a

Browse files
committed
ci: Introduce backend-all-green as a "must-be-green" job
1 parent aefff91 commit 77eb86a

File tree

3 files changed

+80
-69
lines changed

3 files changed

+80
-69
lines changed

.github/workflows/backend.yml

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,55 @@
11
name: backend
22

3-
on: [workflow_call]
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
merge_group:
9+
types: [checks_requested]
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
permissions: {}
416

517
defaults:
618
run:
719
shell: "bash"
820

921
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+
1041
backend-lint:
1142
runs-on: "ubuntu-latest"
43+
needs: [backend-changes]
44+
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (contains(fromJSON('["pull_request", "merge_group"]'), github.event_name) && needs.backend-changes.outputs.changes == 'true') }}
45+
permissions:
46+
contents: read
1247
steps:
1348
- name: Checkout code
14-
uses: actions/checkout@v4
49+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1550

1651
- name: Setup Python
17-
uses: actions/setup-python@v5
52+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
1853
with:
1954
python-version: "3.12"
2055
cache: pip
@@ -30,10 +65,13 @@ jobs:
3065
3166
backend-lockfiles:
3267
runs-on: "ubuntu-latest"
33-
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
3472
steps:
3573
- name: Checkout code
36-
uses: actions/checkout@v4
74+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3775
with:
3876
fetch-depth: 2
3977

@@ -50,6 +88,8 @@ jobs:
5088
fi
5189
5290
backend-test:
91+
needs: [backend-changes]
92+
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (contains(fromJSON('["pull_request", "merge_group"]'), github.event_name) && needs.backend-changes.outputs.changes == 'true') }}
5393
strategy:
5494
fail-fast: false
5595
matrix:
@@ -68,20 +108,22 @@ jobs:
68108
scikit-learn: "1.6"
69109
coverage: true
70110
runs-on: ${{ matrix.os }}
111+
permissions:
112+
contents: read
71113
steps:
72114
- name: Checkout code
73-
uses: actions/checkout@v4
115+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
74116

75117
- name: Setup Python
76-
uses: actions/setup-python@v5
118+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
77119
id: setup-python
78120
with:
79121
python-version: ${{ matrix.python }}
80122
check-latest: True
81123
cache: pip
82124

83125
- name: Restore python-venv
84-
uses: actions/cache/restore@v4
126+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
85127
id: cache-python-venv
86128
with:
87129
path: 'skore/venv'
@@ -116,7 +158,7 @@ jobs:
116158
python -m pip install --requirement test-requirements.txt
117159
118160
- name: Save python-venv
119-
uses: actions/cache/save@v4
161+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
120162
if: steps.cache-python-venv.outputs.cache-hit != 'true'
121163
with:
122164
path: 'skore/venv'
@@ -132,8 +174,7 @@ jobs:
132174

133175
- name: Show dependencies versions
134176
working-directory: skore/
135-
run: |
136-
python -c "import skore; skore.show_versions()"
177+
run: python -c 'import skore; skore.show_versions()'
137178

138179
- name: Test without coverage
139180
if: ${{ ! matrix.coverage }}
@@ -151,7 +192,20 @@ jobs:
151192
152193
- name: Upload coverage reports
153194
if: ${{ matrix.coverage && (github.event_name == 'pull_request') }}
154-
uses: actions/upload-artifact@v4
195+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
155196
with:
156197
name: backend-coverage
157198
path: skore/coverage/
199+
200+
backend-all-green:
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/ci.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
name: lint
22

3-
on: [workflow_call]
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
merge_group:
9+
types: [checks_requested]
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: read
417

518
defaults:
619
run:

0 commit comments

Comments
 (0)