Skip to content

Commit

Permalink
Create run_coverage.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored May 20, 2024
1 parent 0ece8ca commit 13c3ad3
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/run_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Run code coverage
on:
pull_request:
workflow_dispatch:

jobs:
run-coverage:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
# TODO handle forks
# run pipeline on either a push event or a PR event on a fork
# if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
defaults:
run:
shell: bash
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
env: # used by codecov-action
OS: ${{ matrix.os }}
PYTHON: '3.11'
steps:
- name: Cancel any previous incomplete runs
uses: styfle/cancel-workflow-action@0.11.0
with:
all_but_latest: true
access_token: ${{ github.token }}

- uses: actions/checkout@v3
with:
submodules: 'recursive'
fetch-depth: 0 # fetch tags

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.txt
- name: Install package
run: |
python -m pip install -e . # must install in editable mode for coverage to find sources
python -m pip list
- name: Run tests and generate coverage report
run: |
pytest --cov
python -m coverage xml # codecov uploader requires xml format
python -m coverage report -m
# TODO uncomment after setting up repo on codecov.io
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# fail_ci_if_error: true

0 comments on commit 13c3ad3

Please sign in to comment.