Skip to content

Commit

Permalink
ci: Add coverage reports
Browse files Browse the repository at this point in the history
Fix coverage badge based on that
Also fix other urls pointing to gitlab still
  • Loading branch information
183amir committed Jul 8, 2024
1 parent 66b3b0c commit b243db3
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 5 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Post coverage comment

on:
workflow_run:
workflows: ["pixi"]
types:
- completed

jobs:
test:
name: Run tests & display coverage
runs-on: ubuntu-22.04
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
permissions:
# Gives the action the necessary permissions for publishing new
# comments in pull requests.
pull-requests: write
# Gives the action the necessary permissions for editing existing
# comments (to avoid publishing multiple comments in the same PR)
contents: write
# Gives the action the necessary permissions for looking up the
# workflow that launched this workflow, and download the related
# artifact that contains the comment to be published
actions: read
steps:
# DO NOT run actions/checkout here, for security reasons
# For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
- name: Post comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }}
# Update those if you changed the default values:
# COMMENT_ARTIFACT_NAME: python-coverage-comment-action
# COMMENT_FILENAME: python-coverage-comment-action.txt
21 changes: 21 additions & 0 deletions .github/workflows/pixi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ jobs:
tests:
runs-on: ubuntu-22.04
permissions:
# Gives the action the necessary permissions for publishing new
# comments in pull requests.
pull-requests: write
# Gives the action the necessary permissions for pushing data to the
# python-coverage-comment-action branch, and for editing existing
# comments (to avoid publishing multiple comments in the same PR)
contents: write
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -45,6 +53,19 @@ jobs:
environments: test
- name: Run Tests
run: pixi run test-ci
- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v4
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
# If you use a different name, update COMMENT_ARTIFACT_NAME accordingly
name: python-coverage-comment-action
# If you use a different name, update COMMENT_FILENAME accordingly
path: python-coverage-comment-action.txt

doc:
runs-on: ubuntu-22.04
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: GPL-3.0-or-later

[![latest-docs](https://img.shields.io/badge/docs-latest-orange.svg)](https://gridtk.readthedocs.io/en/latest/)
[![build](https://github.com/idiap/gridtk/actions/workflows/pixi.yml/badge.svg)](https://github.com/idiap/gridtk/actions/workflows/pixi.yml)
[![coverage](https://gitlab.idiap.ch/software/gridtk/badges/main/coverage.svg)](https://www.idiap.ch/software/biosignal/docs/software/gridtk/main/coverage/index.html)
[![coverage](https://raw.githubusercontent.com/idiap/gridtk/python-coverage-comment-action-data/badge.svg)](https://htmlpreview.github.io/?https://github.com/idiap/gridtk/blob/python-coverage-comment-action-data/htmlcov/index.html)
[![repository](https://img.shields.io/badge/github-project-0000c0.svg)](https://github.com/idiap/gridtk)

# GridTK: SLURM Job Managetment for Humans
Expand Down Expand Up @@ -35,7 +35,7 @@ To install GridTK, open your terminal and run the following command:
```bash
$ pixi global install pipx
$ pixi global install python=3.12
$ pipx install --force --python python3.12 'git+https://gitlab.idiap.ch/software/gridtk.git'
$ pipx install --force --python python3.12 'git+https://github.com/idiap/gridtk.git'
```
It is **not recommennded** to install GridTK using `pip install gridtk` in the
same environment as your expeirments. GirdTK does not need to be installed in
Expand Down
4 changes: 2 additions & 2 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ doctest = "sphinx-build -aEb doctest doc html/doctest"

[tool.pixi.feature.test.tasks]
test = "pytest -sv tests/"
test-ci = "pytest -sv --cov-report 'html:html/coverage' --cov-report 'xml:coverage.xml' --junitxml 'junit-coverage.xml' --ignore '.profile' tests/"
test-ci = "pytest -sv --cov-branch --cov-report xml --ignore '.profile' tests/"

[tool.pixi.environments]
default = { features = ["doc", "test"], solve-group = "default" }
Expand Down Expand Up @@ -165,5 +165,8 @@ addopts = ["--cov=gridtk", "--cov-report=term-missing", "--import-mode=append"]
junit_logging = "all"
junit_log_passing_tests = false

[tool.coverage.run]
relative_files = true

[tool.mypy]
python_version = "3.12"

0 comments on commit b243db3

Please sign in to comment.