Skip to content

Commit c548583

Browse files
authored
ci: Add workflow to lint/test skore-remote-project (#1598)
Some changes to prepare for the arrival of the new package `skore-remote-project`: - Rename the `skore` workflow from `backend` to `skore`, - Factorize `pr-display-backend-coverage` to be usable by both `skore` and `skore-remote-project`, - Add the structure of the package `skore-remote-project`, - Add the `skore-remote-project` workflow.
1 parent f270641 commit c548583

File tree

17 files changed

+646
-31
lines changed

17 files changed

+646
-31
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
name: pr-display-backend-coverage
1+
name: pr-display-code-coverage
22

33
on:
44
workflow_run:
5-
workflows: [backend]
5+
workflows: [skore, skore-remote-project]
66
types: [completed]
77

88
concurrency:
9-
group: ${{ github.workflow }}-${{ github.ref }}
9+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.workflow_run.name }}
1010
cancel-in-progress: true
1111

1212
permissions: {}
1313

1414
jobs:
15-
pr-display-backend-coverage:
15+
pr-display-code-coverage:
1616
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
1717
runs-on: ubuntu-latest
1818
permissions:
@@ -21,24 +21,26 @@ jobs:
2121
pull-requests: write
2222
steps:
2323
- name: Checkout code
24-
uses: actions/checkout@v4
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
with:
26+
sparse-checkout: .github
2527

2628
- name: Acquire PR context
2729
id: acquire-pr-context
2830
uses: ./.github/actions/workflow-run/context
2931

3032
- name: Download coverage reports
31-
uses: actions/download-artifact@v4
33+
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
3234
with:
33-
name: backend-coverage
35+
name: ${{ github.event.workflow_run.name }}-coverage
3436
path: coverage/
3537
github-token: ${{ github.token }}
3638
run-id: ${{ github.event.workflow_run.id }}
3739

3840
- name: Display coverage reports
39-
uses: MishaKav/pytest-coverage-comment@main
41+
uses: MishaKav/pytest-coverage-comment@81882822c5b22af01f91bd3eacb1cefb6ad73dc2 # v1.1.53
4042
with:
4143
issue-number: ${{ steps.acquire-pr-context.outputs.pr-number }}
4244
pytest-coverage-path: coverage/coverage.txt
4345
junitxml-path: coverage/coverage.xml
44-
title: Coverage Report for backend
46+
title: Coverage Report for `${{ github.event.workflow_run.name }}`
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
name: skore-remote-project
2+
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+
17+
defaults:
18+
run:
19+
shell: "bash"
20+
21+
jobs:
22+
skore-remote-project-changes:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
changes: ${{ steps.filter.outputs.skore-remote-project }}
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+
skore-remote-project:
38+
- '.github/workflows/skore-remote-project.yml'
39+
- 'ci/requirements/skore-remote-project/**'
40+
- 'skore-remote-project/**'
41+
42+
skore-remote-project-lint:
43+
runs-on: "ubuntu-latest"
44+
needs: [skore-remote-project-changes]
45+
if: ${{ (github.event_name == 'push') || (needs.skore-remote-project-changes.outputs.changes == 'true') }}
46+
permissions:
47+
contents: read
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
51+
52+
- name: Setup Python
53+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
54+
with:
55+
python-version: "3.12"
56+
cache: pip
57+
58+
- name: Install dependencies
59+
run: python -m pip install --upgrade pip pre-commit
60+
61+
- name: Lint
62+
working-directory: skore-remote-project/
63+
run: |
64+
pre-commit run --all-files ruff
65+
pre-commit run --all-files mypy
66+
67+
skore-remote-project-lockfiles:
68+
runs-on: "ubuntu-latest"
69+
needs: [skore-remote-project-changes]
70+
if: ${{ (contains(fromJSON('["pull_request", "merge_group"]'), github.event_name)) && (needs.skore-remote-project-changes.outputs.changes == 'true') }}
71+
permissions:
72+
contents: read
73+
steps:
74+
- name: Checkout code
75+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
76+
with:
77+
fetch-depth: 2
78+
79+
- name: Check lockfiles are not obsolete
80+
run: |
81+
set -eu
82+
83+
# Check if `pyproject.toml` has changed in this pull-request
84+
# ├── False
85+
# │ └── Exit 0
86+
# └── True
87+
# └── Check if lockfiles have changed in this pull-request
88+
# ├── True
89+
# │ └── Exit 0
90+
# └── False
91+
# └── Recompile lockfiles and check if they have to change
92+
# ├── False
93+
# │ └── Exit 0
94+
# └── True
95+
# └── Exit 1
96+
97+
changes=$(git diff --name-only HEAD^1 HEAD)
98+
99+
if
100+
(echo "${changes}" | grep -qE "skore-remote-project/pyproject.toml") &&
101+
(echo "${changes}" | (! grep -qE "ci/requirements/skore-remote-project/.*/test-requirements.txt"))
102+
then
103+
curl -LsSf https://astral.sh/uv/0.6.16/install.sh | sh
104+
bash ci/pip-compile.sh skore-remote-project
105+
106+
if (git diff --name-only | grep -qE "ci/requirements/skore-remote-project/.*/test-requirements.txt"); then
107+
echo '::error title=skore-remote-project-lockfiles::Lockfiles obsolete, please execute `$ bash ci/pip-compile.sh skore-remote-project`'
108+
exit 1
109+
fi
110+
fi
111+
112+
skore-remote-project-test:
113+
needs: [skore-remote-project-changes]
114+
if: ${{ (github.event_name == 'push') || (needs.skore-remote-project-changes.outputs.changes == 'true') }}
115+
strategy:
116+
fail-fast: false
117+
matrix:
118+
os: ["ubuntu-latest", "windows-latest"]
119+
python: ["3.9", "3.10", "3.11", "3.12"]
120+
scikit-learn: ["1.6"]
121+
include:
122+
- os: "ubuntu-latest"
123+
python: "3.12"
124+
scikit-learn: "1.4"
125+
- os: "ubuntu-latest"
126+
python: "3.12"
127+
scikit-learn: "1.5"
128+
- os: "ubuntu-latest"
129+
python: "3.12"
130+
scikit-learn: "1.6"
131+
coverage: true
132+
runs-on: ${{ matrix.os }}
133+
permissions:
134+
contents: read
135+
steps:
136+
- name: Checkout code
137+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
138+
139+
- name: Setup Python
140+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
141+
id: setup-python
142+
with:
143+
python-version: ${{ matrix.python }}
144+
check-latest: True
145+
cache: pip
146+
147+
- name: Restore python-venv
148+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
149+
id: cache-python-venv
150+
with:
151+
path: 'skore-remote-project/venv'
152+
key: >-
153+
python-venv
154+
-${{ matrix.os }}
155+
-${{ steps.setup-python.outputs.python-version }}
156+
-${{ hashFiles(format('ci/requirements/skore-remote-project/python-{0}/scikit-learn-{1}/test-requirements.txt', matrix.python, matrix.scikit-learn)) }}
157+
158+
- name: Setup python-venv
159+
working-directory: "skore-remote-project/"
160+
run: |
161+
set -eu
162+
163+
# Ensure venv is created
164+
python -m venv venv
165+
166+
# Activate venv for each step depending on the OS
167+
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
168+
echo "${GITHUB_WORKSPACE}/skore-remote-project/venv/bin" >> ${GITHUB_PATH}
169+
echo "VIRTUAL_ENV=${GITHUB_WORKSPACE}/skore-remote-project/venv" >> ${GITHUB_ENV}
170+
else
171+
echo "${GITHUB_WORKSPACE}\\skore-remote-project\\venv\\Scripts" >> ${GITHUB_PATH}
172+
echo "VIRTUAL_ENV=${GITHUB_WORKSPACE}\\skore-remote-project\\venv" >> ${GITHUB_ENV}
173+
fi
174+
175+
- name: Install dependencies in python-venv
176+
working-directory: ${{ format('ci/requirements/skore-remote-project/python-{0}/scikit-learn-{1}', matrix.python, matrix.scikit-learn) }}
177+
if: steps.cache-python-venv.outputs.cache-hit != 'true'
178+
run: |
179+
python -m pip install --upgrade pip build
180+
python -m pip install --requirement test-requirements.txt
181+
182+
- name: Save python-venv
183+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
184+
if: steps.cache-python-venv.outputs.cache-hit != 'true'
185+
with:
186+
path: 'skore-remote-project/venv'
187+
key: ${{ steps.cache-python-venv.outputs.cache-primary-key }}
188+
189+
- name: Build
190+
working-directory: skore-remote-project/
191+
run: python -m build
192+
193+
- name: Install
194+
working-directory: skore-remote-project/dist/
195+
run: wheel=(*.whl); python -m pip install --force-reinstall --no-deps "${wheel}"
196+
197+
- name: Test without coverage
198+
if: ${{ ! matrix.coverage }}
199+
timeout-minutes: 10
200+
working-directory: skore-remote-project/
201+
run: python -m pytest -n auto src/ tests/ --no-cov
202+
203+
- name: Test with coverage
204+
if: ${{ matrix.coverage }}
205+
timeout-minutes: 10
206+
working-directory: skore-remote-project/
207+
run: |
208+
mkdir coverage
209+
python -m pytest -n auto src/ tests/ --junitxml=coverage/coverage.xml --cov-config=pyproject.toml --cov | tee coverage/coverage.txt
210+
211+
- name: Upload coverage reports
212+
if: ${{ matrix.coverage && (github.event_name == 'pull_request') }}
213+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
214+
with:
215+
name: skore-remote-project-coverage
216+
path: skore-remote-project/coverage/
217+
218+
skore-remote-project:
219+
needs:
220+
- skore-remote-project-changes
221+
- skore-remote-project-lint
222+
- skore-remote-project-lockfiles
223+
- skore-remote-project-test
224+
if: ${{ always() }}
225+
runs-on: Ubuntu-latest
226+
steps:
227+
- shell: bash
228+
run: |
229+
[[ ${{ contains(needs.*.result, 'failure') }} = false ]]

.github/workflows/backend.yml renamed to .github/workflows/skore.yml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: backend
1+
name: skore
22

33
on:
44
pull_request:
@@ -19,10 +19,10 @@ defaults:
1919
shell: "bash"
2020

2121
jobs:
22-
backend-changes:
22+
skore-changes:
2323
runs-on: ubuntu-latest
2424
outputs:
25-
changes: ${{ steps.filter.outputs.backend }}
25+
changes: ${{ steps.filter.outputs.skore }}
2626
permissions:
2727
pull-requests: read
2828
steps:
@@ -34,14 +34,15 @@ jobs:
3434
id: filter
3535
with:
3636
filters: |
37-
backend:
38-
- '.github/workflows/backend.yml'
37+
skore:
38+
- '.github/workflows/skore.yml'
39+
- 'ci/requirements/skore/**'
3940
- 'skore/**'
4041
41-
backend-lint:
42+
skore-lint:
4243
runs-on: "ubuntu-latest"
43-
needs: [backend-changes]
44-
if: ${{ (github.event_name == 'push') || (needs.backend-changes.outputs.changes == 'true') }}
44+
needs: [skore-changes]
45+
if: ${{ (github.event_name == 'push') || (needs.skore-changes.outputs.changes == 'true') }}
4546
permissions:
4647
contents: read
4748
steps:
@@ -63,10 +64,10 @@ jobs:
6364
pre-commit run --all-files ruff
6465
pre-commit run --all-files mypy
6566
66-
backend-lockfiles:
67+
skore-lockfiles:
6768
runs-on: "ubuntu-latest"
68-
needs: [backend-changes]
69-
if: ${{ (contains(fromJSON('["pull_request", "merge_group"]'), github.event_name)) && (needs.backend-changes.outputs.changes == 'true') }}
69+
needs: [skore-changes]
70+
if: ${{ (contains(fromJSON('["pull_request", "merge_group"]'), github.event_name)) && (needs.skore-changes.outputs.changes == 'true') }}
7071
permissions:
7172
contents: read
7273
steps:
@@ -100,17 +101,17 @@ jobs:
100101
(echo "${changes}" | (! grep -qE "ci/requirements/skore/.*/test-requirements.txt"))
101102
then
102103
curl -LsSf https://astral.sh/uv/0.6.16/install.sh | sh
103-
bash ci/pip-compile.sh
104+
bash ci/pip-compile.sh skore
104105
105106
if (git diff --name-only | grep -qE "ci/requirements/skore/.*/test-requirements.txt"); then
106-
echo '::error title=backend-lockfiles::Lockfiles obsolete, please execute `$ bash ci/pip-compile.sh skore`'
107+
echo '::error title=skore-lockfiles::Lockfiles obsolete, please execute `$ bash ci/pip-compile.sh skore`'
107108
exit 1
108109
fi
109110
fi
110111
111-
backend-test:
112-
needs: [backend-changes]
113-
if: ${{ (github.event_name == 'push') || (needs.backend-changes.outputs.changes == 'true') }}
112+
skore-test:
113+
needs: [skore-changes]
114+
if: ${{ (github.event_name == 'push') || (needs.skore-changes.outputs.changes == 'true') }}
114115
strategy:
115116
fail-fast: false
116117
matrix:
@@ -215,15 +216,15 @@ jobs:
215216
if: ${{ matrix.coverage && (github.event_name == 'pull_request') }}
216217
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
217218
with:
218-
name: backend-coverage
219+
name: skore-coverage
219220
path: skore/coverage/
220221

221-
backend:
222+
skore:
222223
needs:
223-
- backend-changes
224-
- backend-lint
225-
- backend-lockfiles
226-
- backend-test
224+
- skore-changes
225+
- skore-lint
226+
- skore-lockfiles
227+
- skore-test
227228
if: ${{ always() }}
228229
runs-on: Ubuntu-latest
229230
steps:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

0 commit comments

Comments
 (0)