Skip to content

Commit be1aec3

Browse files
authored
ci: Refactor workflows so that they are usable by forks (#981)
This PR addresses several issues concerning the CI in PR from forks: - Refactor workflows so that they are usable in every PR - assignee can be added to every PR - coverage comments can be send to every PR - Add workflow to serve documentation preview and send a comment with the corresponding link in PR - Add workflow to clean documentation preview and GH artifacts after closing a PR
1 parent 24a7c1b commit be1aec3

18 files changed

+476
-207
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.github/ @thomass-dev @rouk1 @augustebaum

.github/actions/sphinx/deploy/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ inputs:
1414
required: false
1515
default: scaleway
1616
BUCKET:
17-
required: false
18-
default: prod-probabl-skore
17+
required: true
1918
SOURCE:
2019
required: true
2120
DESTINATION:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: acquire-pr-context
2+
description: |
3+
Acquire the PR number and the PR commit HEAD sha, after a "workflow_run" event.
4+
5+
The "workflow_run" context differs from the "pull_request" context and doesn't contain
6+
PR basic information. This action intends to provide some missing information in the
7+
"workflow_run" context, without having to explicitly record them in the workflow that
8+
triggered the "workflow_run" event.
9+
10+
outputs:
11+
pr-number:
12+
description: "The PR number"
13+
value: ${{ steps.acquire-pr-context.outputs.number }}
14+
pr-head-sha:
15+
description: "The PR commit HEAD sha"
16+
value: ${{ steps.acquire-pr-context.outputs.head-sha }}
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- id: acquire-pr-context
22+
shell: bash
23+
run: |-
24+
gh pr view \
25+
--repo "${REPOSITORY}" "${BRANCH}" \
26+
--json 'number,headRefOid' \
27+
--jq '"number=\(.number)\nhead-sha=\(.headRefOid)"' \
28+
\
29+
>> "${GITHUB_OUTPUT}"
30+
env:
31+
GH_TOKEN: ${{ github.token }}
32+
REPOSITORY: ${{ github.repository }}
33+
BRANCH: |-
34+
${{
35+
(github.event.workflow_run.head_repository.fork == true)
36+
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
37+
|| github.event.workflow_run.head_branch
38+
}}

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

Lines changed: 72 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,49 @@
1-
name: Reusable skore workflow
2-
3-
on: [workflow_call]
1+
name: backend
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'skore/src/**'
7+
- 'skore/tests/**'
8+
- 'skore/pyproject.toml'
9+
- 'skore/requirements*.txt'
10+
- '.github/workflows/backend.yml'
11+
push:
12+
branches:
13+
- main
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
permissions:
20+
contents: read
421

522
defaults:
623
run:
724
shell: "bash"
825

926
jobs:
10-
test-skore:
27+
backend-lint:
28+
runs-on: "ubuntu-latest"
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: "3.12"
37+
cache: pip
38+
39+
- name: Install dependencies
40+
run: python -m pip install --upgrade pip pre-commit
41+
42+
- name: Lint
43+
working-directory: skore/
44+
run: pre-commit run --all-files ruff
45+
46+
backend-test:
1147
strategy:
1248
fail-fast: false
1349
matrix:
@@ -21,14 +57,20 @@ jobs:
2157
- os: "ubuntu-latest"
2258
python: "3.12"
2359
scikit-learn: "1.5"
60+
- os: "ubuntu-latest"
61+
python: "3.12"
62+
scikit-learn: "1.6"
63+
coverage: true
2464
runs-on: ${{ matrix.os }}
2565
steps:
26-
- uses: actions/checkout@v4
66+
- name: Checkout code
67+
uses: actions/checkout@v4
2768

28-
- uses: actions/setup-python@v5
69+
- name: Setup Python
70+
uses: actions/setup-python@v5
2971
with:
3072
python-version: ${{ matrix.python }}
31-
cache: "pip"
73+
cache: pip
3274

3375
- name: Restore python-venv
3476
uses: actions/cache/restore@v4
@@ -75,46 +117,33 @@ jobs:
75117
path: 'skore/venv'
76118
key: ${{ steps.cache-python-venv.outputs.cache-primary-key }}
77119

78-
- name: Lint and test
79-
timeout-minutes: 10
80-
working-directory: "skore/"
81-
run: |
82-
# Lint
83-
pre-commit run --all-files ruff
84-
85-
# Build
86-
python -m build
120+
- name: Build
121+
working-directory: skore/
122+
run: python -m build
87123

124+
- name: Install
125+
working-directory: skore/
126+
run: |
88127
# Install `skore` without its dependencies, which are present in the venv
89128
wheel=(dist/*.whl); python -m pip install --force-reinstall --no-deps "${wheel}"
90129
91-
# Test
92-
python -m pytest --no-cov src/ tests/ -n auto
130+
- name: Test without coverage
131+
if: ${{ ! matrix.coverage }}
132+
timeout-minutes: 10
133+
working-directory: skore/
134+
run: python -m pytest -n auto src/ tests/ --no-cov
93135

94-
coverage-skore:
95-
runs-on: ubuntu-latest
96-
if: ${{ github.event_name == 'pull_request' }}
97-
steps:
98-
- uses: actions/checkout@v4
99-
- uses: actions/setup-python@v5
100-
with:
101-
python-version: 3.12
102-
cache: "pip"
103-
- name: pytest coverage
104-
working-directory: "skore/"
136+
- name: Test with coverage
137+
if: ${{ matrix.coverage }}
138+
timeout-minutes: 10
139+
working-directory: skore/
105140
run: |
106-
# Install dependencies
107-
python -m pip install --upgrade pip
108-
python -m pip install --upgrade pre-commit
109-
python -m pip install --upgrade build
110-
python -m pip install -e .[test]
111-
112-
# run coverage
113-
python -m pytest -n auto --junitxml=coverage.xml --cov=skore src/ tests/ | tee pytest-coverage.txt
114-
- name: Pytest coverage comment
115-
if: ${{ ! github.event.pull_request.head.repo.fork }}
116-
uses: MishaKav/pytest-coverage-comment@main
141+
mkdir coverage
142+
python -m pytest -n auto src/ tests/ --junitxml=coverage/coverage.xml --cov-config=pyproject.toml --cov | tee coverage/coverage.txt
143+
144+
- name: Upload coverage reports
145+
if: ${{ matrix.coverage && (github.event_name == 'pull_request') }}
146+
uses: actions/upload-artifact@v4
117147
with:
118-
pytest-coverage-path: ./skore/pytest-coverage.txt
119-
junitxml-path: ./skore/coverage.xml
120-
title: pytest coverage report
148+
name: backend-coverage
149+
path: skore/coverage/

.github/workflows/ci.yml

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

.github/workflows/frontend.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: frontend
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'skore-ui/**'
7+
- '.github/workflows/frontend.yml'
8+
push:
9+
branches:
10+
- main
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
permissions:
17+
contents: read
18+
19+
defaults:
20+
run:
21+
shell: "bash"
22+
23+
jobs:
24+
frontend-lint:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Node
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: '20'
34+
cache: 'npm'
35+
cache-dependency-path: skore-ui/package-lock.json
36+
37+
- name: Lint
38+
working-directory: skore-ui/
39+
run: |
40+
npm install
41+
npm run type-check
42+
npm run lint
43+
npm run format
44+
npm run style-lint
45+
46+
frontend-test:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
52+
- name: Setup Node
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: '20'
56+
cache: 'npm'
57+
cache-dependency-path: skore-ui/package-lock.json
58+
59+
- name: Test with coverage
60+
working-directory: skore-ui/
61+
run: |
62+
npm install
63+
npm run test:unit:coverage
64+
65+
- name: Upload coverage reports
66+
if: ${{ github.event_name == 'pull_request' }}
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: frontend-coverage
70+
path: skore-ui/coverage/
71+
72+
frontend-build:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout code
76+
uses: actions/checkout@v4
77+
78+
- name: Setup Node
79+
uses: actions/setup-node@v4
80+
with:
81+
node-version: '20'
82+
cache: 'npm'
83+
cache-dependency-path: skore-ui/package-lock.json
84+
85+
- name: Build
86+
working-directory: skore-ui/
87+
run: |
88+
npm install
89+
npm run build

0 commit comments

Comments
 (0)