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

add coverage to workflow #8

Merged
merged 1 commit into from
Jan 7, 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
23 changes: 23 additions & 0 deletions .github/workflows/post-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Post coverage comment

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

jobs:
test:
name: Display coverage
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
permissions:
pull-requests: write
contents: write
actions: read
steps:
- 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 }}
44 changes: 44 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,47 @@ jobs:
run: |
source ./venv/bin/activate
PYTHONPATH="$(pwd)" pytest

coverage:
name: Coverage
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4

- name: Set up CPython 3.12
uses: actions/setup-python@v2
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m venv venv
source ./venv/bin/activate
pip install --upgrade pip setuptools wheel pytest setuptools-rust
pip install -U -r requirements_dev.txt
- name: Installing distribution (dev mode)
# this adds the .so to the inner lib files so we can test
run: |
source ./venv/bin/activate
python ./setup.py develop
- name: Run tests
shell: bash
run: |
source ./venv/bin/activate
PYTHONPATH="$(pwd)" coverage run -m pytest

- 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:
name: python-coverage-comment-action
path: python-coverage-comment-action.txt
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ requires = ["setuptools", "wheel", "setuptools-rust"]
omit = [
"neofoodclub/types/*",
]
relative_files = true

[tool.coverage.report]
exclude_lines = [
Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage
numpy
orjson
pytest
Expand Down
Loading