From c62292390200c59c0072613ba3365a265798329e Mon Sep 17 00:00:00 2001 From: Thomas S Date: Wed, 18 Dec 2024 20:57:09 +0100 Subject: [PATCH] ci: Fix `skore` workflow to send coverage report even on PR from forks --- .github/workflows/ci.yml | 4 +- .../skore-send-coverage-artifact.yml | 29 ++++++++ .github/workflows/skore-test.yml | 54 +++++++++++++++ .github/workflows/skore.yml | 68 ------------------- 4 files changed, 85 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/skore-send-coverage-artifact.yml create mode 100644 .github/workflows/skore-test.yml delete mode 100644 .github/workflows/skore.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3db1d26d..83108cb30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: - 'skore/tests/**' - 'skore/pyproject.toml' - 'skore/requirements*.txt' - - '.github/workflows/skore.yml' + - '.github/workflows/skore-test.yml' skore-ui: - 'skore-ui/**' - '.github/workflows/skore-ui.yml' @@ -42,7 +42,7 @@ jobs: lint-and-test-skore: 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 + uses: ./.github/workflows/skore-test.yml permissions: contents: read pull-requests: write diff --git a/.github/workflows/skore-send-coverage-artifact.yml b/.github/workflows/skore-send-coverage-artifact.yml new file mode 100644 index 000000000..7adfcea17 --- /dev/null +++ b/.github/workflows/skore-send-coverage-artifact.yml @@ -0,0 +1,29 @@ +name: + +on: + workflow_run: + workflows: ["Reusable skore workflow"] + types: + - completed + +permissions: + pull-requests: write + +jobs: + send-coverage-message: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' + steps: + - name: Download coverage reports + uses: actions/download-artifact@v4 + with: + name: python-coverage + path: coverage/ + - name: Send + uses: MishaKav/pytest-coverage-comment@main + with: + pytest-coverage-path: coverage/coverage.txt + junitxml-path: coverage/coverage.xml + title: pytest coverage report diff --git a/.github/workflows/skore-test.yml b/.github/workflows/skore-test.yml new file mode 100644 index 000000000..84774a87b --- /dev/null +++ b/.github/workflows/skore-test.yml @@ -0,0 +1,54 @@ +name: Reusable skore workflow + +on: [workflow_call] + +defaults: + run: + shell: "bash" + +jobs: + test-skore: + strategy: + fail-fast: true + matrix: + os: ["ubuntu-latest", "windows-latest"] + python: ["3.9", "3.10", "3.11", "3.12"] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + cache: "pip" + - name: Setup + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade pre-commit + python -m pip install --upgrade build + - name: Lint + working-directory: skore/ + run: pre-commit run --all-files ruff + - name: Build + working-directory: skore/ + run: python -m build + - name: Install + working-directory: skore/ + run: wheel=(dist/*.whl); python -m pip install "${wheel}[test]" + - name: Test without coverage + if: matrix.os != 'ubuntu-latest' || matrix.python != '3.12' + timeout-minutes: 10 + working-directory: skore/ + run: python -m pytest --no-cov src/ tests/ + - name: Test with coverage + if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' + timeout-minutes: 10 + working-directory: skore/ + run: | + mkdir coverage + python -m pytest --junitxml=coverage/coverage.xml --cov=skore src/ tests/ | tee coverage/coverage.txt + - name: Upload coverage reports + if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' + uses: actions/upload-artifact@v4 + with: + name: python-coverage + path: skore/coverage/ diff --git a/.github/workflows/skore.yml b/.github/workflows/skore.yml deleted file mode 100644 index 24ec97412..000000000 --- a/.github/workflows/skore.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Reusable skore workflow - -on: [workflow_call] - -defaults: - run: - shell: "bash" - working-directory: "./skore" - -jobs: - test-skore: - strategy: - fail-fast: true - matrix: - os: ["ubuntu-latest", "windows-latest"] - python-version: ["3.9", "3.10", "3.11", "3.12"] - 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 - - # Lint - pre-commit run --all-files ruff - - # Build - python -m build - - # Install - wheel=(dist/*.whl); python -m pip install "${wheel}[test]" - - # Test - python -m pytest --no-cov src/ tests/ - - 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 - 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] - - # run coverage - python -m pytest --junitxml=coverage.xml --cov=skore src/ tests/ | tee pytest-coverage.txt - - name: Pytest coverage comment - uses: MishaKav/pytest-coverage-comment@main - with: - pytest-coverage-path: ./skore/pytest-coverage.txt - junitxml-path: ./skore/coverage.xml - title: pytest coverage report