support pytest (#3) #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pytest | |
on: [push, pull_request, workflow_dispatch] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
# Install and Test Example | |
- name: Install and Test Example | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest pytest-cov | |
- name: Test | |
run: | | |
cd example | |
python -m pytest --cov --cov-report json | |
cp -r coverage.json .. | |
cd .. | |
# Add this | |
- name: Update Coverage Badge | |
# GitHub actions: default branch variable | |
# https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable | |
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
uses: ./ |