Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Modularize CI pipeline and test Python >= 3.11 #402

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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