Skip to content

Commit

Permalink
try code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed May 15, 2024
1 parent b42cdef commit 238f798
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
pull_request:
push:
branches: [ main, feat/* ]

jobs:
hello_world_job:
runs-on: ubuntu-latest
name: Check coverage
steps:
- uses: actions/checkout@v3

- name: Set up Python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install deps
run: pip install -r requirements-dev.txt

- name: Launch tests & generate report
run: pytest .

- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
VERBOSE: true

- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v2
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
21 changes: 21 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Post coverage comment

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

jobs:
test:
name: Run tests & display coverage
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
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 }}
VERBOSE: true
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pytest
pytest-cov
flake8
autopep8
pre-commit
Expand Down

0 comments on commit 238f798

Please sign in to comment.