Skip to content

Commit

Permalink
ci: Modularize CI pipeline and test Python >= 3.11 (#402)
Browse files Browse the repository at this point in the history
- Remove reference of `Makefile` in workflow's instructions to build
front-end
- Use matrix to test back-end on all versions of python `>=3.11`
- Trigger CI tasks at job level instead of workflow level
- Use one and only entry-point to define if pipeline succeed
`ci-all-green`

---

Example: https://github.com/probabl-ai/skore/actions/runs/11146672648


![image](https://github.com/user-attachments/assets/294b9b89-0e86-43ae-a432-320d1ece016f)
  • Loading branch information
thomass-dev authored Oct 3, 2024
1 parent ca5f789 commit 9880d1e
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Add PR assignee

on:
pull_request:
types: [opened]

jobs:
add-assignee:
add-pr-assignee:
runs-on: ubuntu-latest
permissions:
pull-requests: write
Expand Down
75 changes: 48 additions & 27 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,75 @@
name: Backend
name: Reusable backend workflow

on:
pull_request:
paths:
- 'src/**'
- 'tests/**'
- 'pyproject.toml'
- 'Makefile'
- 'requirements*.txt'
- '.github/workflows/backend.yml'

permissions:
contents: read
on: [workflow_call]

jobs:
lint-backend:
build-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/setup-node@v4
with:
python-version: '3.12'
cache: 'pip'
- name: Lint backend
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pre-commit
cd frontend
pre-commit run --all-files ruff
npm install
npm run build
npm run build:lib -- --emptyOutDir false
- uses: actions/upload-artifact@v4
with:
name: frontend-package-distributions
path: frontend/dist

test-backend:
runs-on: ubuntu-latest
needs: build-frontend
strategy:
fail-fast: true
matrix:
python-version: ['3.11', '3.12']

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Build frontend and share library
shell: bash
run: make build-frontend
- name: Build package distributions

- name: Lint
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pre-commit
pre-commit run --all-files ruff
- name: Download package distributions
uses: actions/download-artifact@v4
with:
name: frontend-package-distributions
path: src/skore/ui/static

- name: Build
run: |
python -m pip install --upgrade build
python -m build
- name: Install
run: |
python -m pip install dist/*.whl --no-dependencies
python -m pip install -r requirements.txt -r requirements-test.txt
- name: Pytest
- name: Test
timeout-minutes: 5
run: python -m pytest

cleanup:
runs-on: ubuntu-latest
if: always()
needs: test-backend
steps:
- uses: geekyeggo/delete-artifact@v5
with:
name: frontend-package-distributions
58 changes: 58 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI

on: [pull_request]

jobs:
changes:
runs-on: ubuntu-latest
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
permissions:
pull-requests: read
steps:
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend:
- 'src/**'
- 'tests/**'
- 'pyproject.toml'
- 'requirements*.txt'
- '.github/workflows/backend.yml'
frontend:
- 'frontend/**'
- '.github/workflows/frontend.yml'
lint-all-files:
uses: ./.github/workflows/lint.yml
permissions:
contents: read

lint-and-test-backend:
needs: [lint-all-files, changes]
if: ${{ needs.changes.outputs.backend == 'true' }}
uses: ./.github/workflows/backend.yml
permissions:
contents: read

lint-and-test-frontend:
needs: [lint-all-files, changes]
if: ${{ needs.changes.outputs.frontend == 'true' }}
uses: ./.github/workflows/frontend.yml
permissions:
contents: read
pull-requests: write

ci-all-green:
needs:
- lint-all-files
- lint-and-test-backend
- lint-and-test-frontend
if: ${{ always() }}
runs-on: Ubuntu-latest
steps:
- shell: bash
run: |
[[ ${{ contains(needs.*.result, 'failure') }} = false ]]
22 changes: 10 additions & 12 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
name: Frontend
name: Reusable frontend workflow

on:
pull_request:
paths:
- 'frontend/**'
- Makefile
- .github/workflows/frontend.yml

permissions:
contents: read
pull-requests: write
on: [workflow_call]

jobs:
lint-frontend:
Expand All @@ -33,6 +24,7 @@ jobs:
test-frontend:
runs-on: ubuntu-latest
needs: lint-frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -43,6 +35,7 @@ jobs:
- name: Test frontend
run: |
cd frontend
npm install
npm run test:unit:coverage
- name: Report coverage
Expand All @@ -64,4 +57,9 @@ jobs:
cache-dependency-path: frontend/package-lock.json
- name: Build frontend
shell: bash
run: make build-frontend
run: |
cd frontend
npm install
npm run build
npm run build:lib -- --emptyOutDir false
7 changes: 2 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Lint
name: Reusable lint workflow

on: [pull_request]

permissions:
contents: read
on: [workflow_call]

jobs:
lint-all-files:
Expand Down

0 comments on commit 9880d1e

Please sign in to comment.