Skip to content

Commit b76feb9

Browse files
committed
ci: Refactor workflows so that they are usable by forks
1 parent 469d1e5 commit b76feb9

File tree

13 files changed

+337
-217
lines changed

13 files changed

+337
-217
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/workflows/backend.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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
21+
22+
defaults:
23+
run:
24+
shell: "bash"
25+
26+
jobs:
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:
47+
strategy:
48+
fail-fast: true
49+
matrix:
50+
os: ["ubuntu-latest", "windows-latest"]
51+
python: ["3.9", "3.10", "3.11", "3.12"]
52+
include:
53+
- os: "ubuntu-latest"
54+
python: "3.12"
55+
coverage: true
56+
runs-on: ${{ matrix.os }}
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v4
60+
61+
- name: Setup Python
62+
uses: actions/setup-python@v5
63+
with:
64+
python-version: ${{ matrix.python }}
65+
cache: pip
66+
67+
- name: Install dependencies
68+
run: python -m pip install --upgrade pip build
69+
70+
- name: Build
71+
working-directory: skore/
72+
run: python -m build
73+
74+
- name: Install
75+
working-directory: skore/
76+
run: wheel=(dist/*.whl); python -m pip install "${wheel}[test]"
77+
78+
- name: Test without coverage
79+
if: ${{ ! matrix.coverage }}
80+
timeout-minutes: 10
81+
working-directory: skore/
82+
run: python -m pytest -n auto --no-cov src/ tests/
83+
84+
- name: Test with coverage
85+
if: ${{ matrix.coverage }}
86+
timeout-minutes: 10
87+
working-directory: skore/
88+
run: |
89+
mkdir coverage
90+
python -m pytest -n auto --junitxml=coverage/coverage.xml --cov=skore src/ tests/ | tee coverage/coverage.txt
91+
92+
- name: Upload coverage reports
93+
if: ${{ matrix.coverage }}
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: backend-coverage
97+
path: skore/coverage/

.github/workflows/ci.yml

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

.github/workflows/frontend.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
uses: actions/upload-artifact@v4
67+
with:
68+
name: frontend-coverage
69+
path: skore-ui/coverage/
70+
71+
frontend-build:
72+
runs-on: ubuntu-latest
73+
steps:
74+
- name: Checkout code
75+
uses: actions/checkout@v4
76+
77+
- name: Setup Node
78+
uses: actions/setup-node@v4
79+
with:
80+
node-version: '20'
81+
cache: 'npm'
82+
cache-dependency-path: skore-ui/package-lock.json
83+
84+
- name: Build
85+
working-directory: skore-ui/
86+
run: |
87+
npm install
88+
npm run build

.github/workflows/lint.yml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,40 @@
1-
name: Reusable lint workflow
1+
name: lint
22

3-
on: [workflow_call]
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
16+
defaults:
17+
run:
18+
shell: "bash"
419

520
jobs:
6-
lint-all-files:
21+
lint:
722
runs-on: ubuntu-latest
823
steps:
9-
- uses: actions/checkout@v4
10-
- uses: actions/setup-python@v5
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Python
28+
uses: actions/setup-python@v5
1129
with:
12-
python-version: '3.12'
13-
cache: 'pip'
14-
- name: Lint all files
15-
run: |
16-
python -m pip install --upgrade pip
17-
python -m pip install --upgrade pre-commit
30+
python-version: "3.12"
31+
cache: pip
32+
33+
- name: Install dependencies
34+
run: python -m pip install --upgrade pip pre-commit
1835

36+
- name: Lint
37+
run: |
1938
pre-commit run --all-files check-yaml
2039
pre-commit run --all-files check-toml
2140
pre-commit run --all-files check-added-large-files

.github/workflows/add-pr-assignee.yml renamed to .github/workflows/pr-add-assignee.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
name: Add PR assignee
1+
name: add assignee in PR
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
types: [opened]
66

7+
permissions: {}
8+
79
jobs:
8-
add-pr-assignee:
10+
add-assignee:
911
runs-on: ubuntu-latest
1012
permissions:
1113
pull-requests: write
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: display backend coverage in PR
2+
3+
on:
4+
workflow_run:
5+
workflows: [backend]
6+
types: [completed]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions: {}
13+
14+
jobs:
15+
acquire-pr-number:
16+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
17+
runs-on: ubuntu-latest
18+
outputs:
19+
PR_NUMBER: ${{ steps.acquire-pr-number.outputs.number }}
20+
permissions:
21+
contents: read
22+
steps:
23+
- id: acquire-pr-number
24+
run: gh pr view --repo "${REPOSITORY}" "${BRANCH}" --json 'number' --jq '"number=\(.number)"' >> "${GITHUB_OUTPUT}"
25+
env:
26+
GH_TOKEN: ${{ github.token }}
27+
REPOSITORY: ${{ github.repository }}
28+
BRANCH: |-
29+
${{
30+
(github.event.workflow_run.head_repository.fork == true)
31+
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
32+
|| github.event.workflow_run.head_branch
33+
}}
34+
35+
display-backend-coverage:
36+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
37+
runs-on: ubuntu-latest
38+
needs: [acquire-pr-number]
39+
permissions:
40+
actions: read
41+
pull-requests: write
42+
steps:
43+
- name: Download coverage reports
44+
uses: actions/download-artifact@v4
45+
with:
46+
name: backend-coverage
47+
path: coverage/
48+
github-token: ${{ github.token }}
49+
run-id: ${{ github.event.workflow_run.id }}
50+
51+
- name: Display coverage reports
52+
uses: MishaKav/pytest-coverage-comment@main
53+
with:
54+
issue-number: ${{ needs.acquire-pr-number.outputs.PR_NUMBER }}
55+
pytest-coverage-path: coverage/coverage.txt
56+
junitxml-path: coverage/coverage.xml
57+
title: Coverage Report for backend

0 commit comments

Comments
 (0)