Pytest #255
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
# see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
name: Pytest | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
inputs: | |
upgraded: | |
description: "Include upgraded dependencies in build matrix" | |
default: false | |
type: boolean | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
info: | |
name: Collect info | |
outputs: | |
dependencies: ${{ steps.info.outputs.dependencies }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Collect info | |
id: info | |
run: | | |
dependencies='["pinned", "upgraded"]' | |
if [[ "${{ github.event_name }}" == "push" ]] || \ | |
[[ "${{ github.event_name }}" == "pull_request" ]] || \ | |
[[ "${{ github.event.inputs.upgraded }}" == "false" ]]; | |
then | |
dependencies='["pinned"]' | |
fi | |
# Output & sent to GitHub Actions | |
echo "dependencies: ${dependencies}" | |
echo "dependencies=${dependencies}" >> $GITHUB_OUTPUT | |
build: | |
name: Run tests | |
runs-on: ubuntu-latest | |
needs: | |
- info | |
strategy: | |
fail-fast: false | |
matrix: | |
dependencies: ${{ fromJSON(needs.info.outputs.dependencies) }} | |
python-version: ["3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
if [[ "${{ matrix.dependencies }}" == "upgraded" ]]; | |
then | |
echo "unpinning dependencies" | |
./script/unfreeze | |
fi | |
pip install -r requirements.test.txt | |
if [[ "${{ matrix.dependencies }}" == "upgraded" ]]; | |
then | |
./script/freeze | |
echo "dependency changes after upgrade:" | |
git diff requirements.test.txt | |
fi | |
- name: Test with pytest | |
run: | | |
pytest | |
- name: Validate coverage | |
run: | | |
coverage json -q -o - | python3 .github/validate_coverage.py |