Skip to content

Commit

Permalink
Split CI workflows (#349)
Browse files Browse the repository at this point in the history
- split CI workflow into three pieces `lint`/`frontend`/`backend` to run
workflows only when needed
- run tests only on `pull_request` events
- add dedicated build step in frontend workflow
- update `pre-commit` hooks version to be up-to-date

---------

Co-authored-by: Auguste Baum <auguste@probabl.ai>
  • Loading branch information
thomass-dev and auguste-probabl authored Sep 23, 2024
1 parent ff7f368 commit 879e5ce
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 70 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Backend

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

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Lint
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pre-commit
pre-commit run --all-files ruff
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build frontend and share library
shell: bash
run: make build-frontend
- name: Build package distributions
run: |
python -m pip install --upgrade pip
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
timeout-minutes: 5
run: python -m pytest
62 changes: 62 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Frontend

on:
pull_request:
types: [synchronize]
paths:
- 'frontend/**'
- Makefile
- .github/workflows/lint-frontend.yml

permissions:
contents: read
pull-requests: write

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Lint
run: |
cd frontend
npm install
npm run type-check
npm run lint
npm run format
npm run style-lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Test
run: |
cd frontend
npm install
npm run test:unit:coverage
- name: Report coverage
if: always()
uses: davelosert/vitest-coverage-report-action@v2
with:
working-directory: ./frontend
pr-number: ${{ github.event.number }}

build:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Build
shell: bash
run: make build-frontend
51 changes: 0 additions & 51 deletions .github/workflows/lint-and-test.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint

on: [pull_request]

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Lint
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pre-commit
pre-commit run --all-files check-yaml
pre-commit run --all-files check-toml
pre-commit run --all-files check-added-large-files
pre-commit run --all-files check-merge-conflict
pre-commit run --all-files detect-private-key
pre-commit run --all-files end-of-file-fixer
pre-commit run --all-files trailing-whitespace
pre-commit run --all-files typos
1 change: 0 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ on:
pull_request:
types: [opened]


jobs:
add-assignee:
runs-on: ubuntu-latest
Expand Down
14 changes: 5 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: check-toml
Expand All @@ -13,20 +11,18 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/crate-ci/typos
rev: v1.21.0
rev: v1.24.6
hooks:
- id: typos

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.7
rev: v0.6.5
hooks:
# Run the linter.
- id: ruff
# Comment to disable autofix:
files: ^(src|tests)/
args: [--fix]
# Run the formatter.
- id: ruff-format
files: ^(src|tests)/

- repo: local
hooks:
Expand Down
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,3 @@ build-frontend:
cp -a frontend/dist/. src/skore/ui/static
# clean up
rm -rf frontend/dist

build-doc:
python -m pip install -e . -r requirements-doc.txt
cd doc
# Run a make instruction inside the doc folder
$(MAKE) -C doc html
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0-rc.1
0.0.0
3 changes: 1 addition & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
"type": "module",
"scripts": {
"dev": "vite --host",
"build": "npm-run-all --parallel type-check \"build-only {@}\" --",
"build": "vite build",
"build:lib": "vite build -c vite.config.lib.ts",
"preview": "vite preview",
"test:unit": "vitest run",
"test:unit:watch": "vitest",
"test:unit:coverage": "vitest run --coverage",
"build-only": "vite build",
"type-check": "vue-tsc --build --force",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"style-lint": "stylelint --fix src/**/*.{css,vue}",
Expand Down

0 comments on commit 879e5ce

Please sign in to comment.