Skip to content

Commit

Permalink
ci: Fix skore workflow to send coverage report even on PR from forks
Browse files Browse the repository at this point in the history
  • Loading branch information
thomass-dev committed Dec 26, 2024
1 parent b19127c commit 5f7d570
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 80 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.github/ @thomass-dev @rouk1 @augustebaum
107 changes: 61 additions & 46 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,83 @@
name: Reusable skore workflow
# THIS
# IS
# DOCUMENTATION
# REUSABLE WORKFLOW

name: backend

on: [workflow_call]

defaults:
run:
shell: "bash"
working-directory: "./skore"

jobs:
test-skore:
lint-backend:
runs-on: "ubuntu-latest"
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip

- name: Install dependencies
run: python -m pip install --upgrade pip pre-commit

- name: Lint
working-directory: skore/
run: pre-commit run --all-files ruff

test-backend:
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python: ["3.9", "3.10", "3.11", "3.12"]
coverage: [false]
include:
- os: "ubuntu-latest"
python: "3.12"
coverage: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name:
timeout-minutes: 10
run: |
# Install dependencies
python -m pip install --upgrade pip
python -m pip install --upgrade pre-commit
python -m pip install --upgrade build
- name: Checkout code
uses: actions/checkout@v4

# Lint
pre-commit run --all-files ruff
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip

# Build
python -m build
- name: Install dependencies
run: python -m pip install --upgrade pip build

# Install
wheel=(dist/*.whl); python -m pip install "${wheel}[test]"
- name: Build
working-directory: skore/
run: python -m build

# Test
python -m pytest --no-cov src/ tests/ -n auto
- name: Install
working-directory: skore/
run: wheel=(dist/*.whl); python -m pip install "${wheel}[test]"

coverage-skore:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
cache: "pip"
- name: pytest coverage
- name: Test with/without coverage
timeout-minutes: 10
working-directory: skore/
run: |
# Install dependencies
python -m pip install --upgrade pip
python -m pip install --upgrade pre-commit
python -m pip install --upgrade build
python -m pip install -e .[test]
if [ ${{ matrix.coverage }} = false ] ; then
python -m pytest -n auto --no-cov src/ tests/
else
mkdir coverage
python -m pytest -n auto --junitxml=coverage/coverage.xml --cov=skore src/ tests/ | tee coverage/coverage.txt
fi
# run coverage
python -m pytest -n auto --junitxml=coverage.xml --cov=skore src/ tests/ | tee pytest-coverage.txt
- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
- name: Upload coverage reports
if: matrix.coverage == 'true'
uses: actions/upload-artifact@v4
with:
pytest-coverage-path: ./skore/pytest-coverage.txt
junitxml-path: ./skore/coverage.xml
title: pytest coverage report
name: backend-coverage
path: skore/coverage/
30 changes: 17 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# THIS
# IS
# DOCUMENTATION

name: CI

on:
Expand All @@ -10,6 +14,8 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: {}

jobs:
changes:
runs-on: ubuntu-latest
Expand All @@ -29,39 +35,37 @@ jobs:
- 'skore/tests/**'
- 'skore/pyproject.toml'
- 'skore/requirements*.txt'
- '.github/workflows/skore.yml'
- '.github/workflows/backend.yml'
skore-ui:
- 'skore-ui/**'
- '.github/workflows/skore-ui.yml'
- '.github/workflows/frontend.yml'
lint-all-files:
uses: ./.github/workflows/lint.yml
permissions:
contents: read

lint-and-test-skore:
lint-and-test-backend:
needs: [lint-all-files, changes]
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && needs.changes.outputs.skore == 'true') }}
uses: ./.github/workflows/skore.yml
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && needs.changes.outputs.skore == 'true')
uses: ./.github/workflows/backend.yml
permissions:
contents: read
pull-requests: write

lint-and-test-skore-ui:
lint-and-test-frontend:
needs: [lint-all-files, changes]
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && needs.changes.outputs.skore-ui == 'true') }}
uses: ./.github/workflows/skore-ui.yml
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && needs.changes.outputs.skore-ui == 'true')
uses: ./.github/workflows/frontend.yml
permissions:
contents: read
pull-requests: write

ci-all-green:
needs:
- changes
- lint-all-files
- lint-and-test-skore
- lint-and-test-skore-ui
if: ${{ always() }}
- lint-and-test-backend
- lint-and-test-frontend
if: always()
runs-on: Ubuntu-latest
steps:
- shell: bash
Expand Down
59 changes: 38 additions & 21 deletions .github/workflows/skore-ui.yml → .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,79 @@
name: Reusable skore-ui workflow
# THIS
# IS
# DOCUMENTATION
# REUSABLE WORKFLOW

name: frontend

on: [workflow_call]

defaults:
run:
shell: 'bash'
working-directory: './skore-ui'

jobs:
lint-skore-ui:
lint-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: skore-ui/package-lock.json
- name: Lint skore-ui

- name: Lint
working-directory: skore-ui/
run: |
npm install
npm run type-check
npm run lint
npm run format
npm run style-lint
test-skore-ui:
test-frontend:
runs-on: ubuntu-latest
needs: lint-skore-ui
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: skore-ui/package-lock.json
- name: Test skore-ui

- name: Test with coverage
working-directory: skore-ui/
run: |
npm install
npm run test:unit:coverage
- name: Report coverage
if: always()
uses: davelosert/vitest-coverage-report-action@v2
- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
working-directory: ./skore-ui
pr-number: ${{ github.event.number }}
name: frontend-coverage
path: skore-ui/coverage/

build-skore-ui:
build-frontend:
runs-on: ubuntu-latest
needs: test-skore-ui
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: skore-ui/package-lock.json
- name: Build skore-ui

- name: Build
working-directory: skore-ui/
run: |
npm install
npm run build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
pull_request_target:
types: [opened]

permissions: {}

jobs:
add-pr-assignee:
runs-on: ubuntu-latest
Expand Down
File renamed without changes.

0 comments on commit 5f7d570

Please sign in to comment.