Skip to content

Commit

Permalink
ci: create reusable testing workflow
Browse files Browse the repository at this point in the history
Signed-off-by: David Hart <[email protected]>
  • Loading branch information
dbhart authored Oct 22, 2024
1 parent 2c5b730 commit fbdf6dc
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/pytest-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Testing Workflow

on:
workflow_call:
inputs:
version:
required: true
type: string
os:
required: true
type: string
secrets:
coverage_token:
required: false

permissions:
contents: read

jobs:
run-pytest-coverage:
runs-on: ${{ inputs.os }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.codecov.io:443
api.github.com:443
cli.codecov.io:443
codecov.io:443
files.pythonhosted.org:443
github.com:443
pypi.org:443
storage.googleapis.com:443
uploader.codecov.io:443
- name: Check out the commit
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1

- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ inputs.version }}

- name: Install testing dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt -r requirements-dev.txt
- name: Test build and install
run: python3 -m pip install .

- name: Test with pytest
run: python3 -m pytest --nbmake --cov=sansmic --cov=tests examples/ tests/

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
with:
token: ${{ secrets.coverage_token }}
flags: ${{ inputs.os }}

- name: Test uninstall
if: success() || failure()
# Allow upload to codecov to fail but not fail all tests
run: python3 -m pip uninstall -y sansmic

0 comments on commit fbdf6dc

Please sign in to comment.