Skip to content

Commit

Permalink
add coverage to workflow (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
diceroll123 authored Jan 7, 2024
1 parent cda2444 commit 8f6f8ba
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
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

0 comments on commit 8f6f8ba

Please sign in to comment.