Fix tests, update workflows, support Python 3.12 tests #285
Workflow file for this run
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: Run code tests on push and pull requests | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
tests: | |
name: Code tests | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
include-sigpy: [true, false] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Cache pip dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install PyPulseq and dependencies | |
run: | | |
pip install --upgrade --upgrade-strategy eager .[test] | |
if [ ${{ matrix.include-sigpy }} == "true" ]; then | |
pip install sigpy | |
fi | |
- name: Install PyTest GitHub Annotation Plugin | |
run: pip install pytest-github-actions-annotate-failures | |
- name: Run PyTest and Generate Coverage Report | |
run: | | |
if [ ${{ matrix.include-sigpy }} == "true" ]; then | |
pytest -m "not slow" --junitxml=pytest.xml \ | |
--cov-report=term-missing:skip-covered --cov=sequences | tee pytest-coverage.txt | |
else | |
pytest -m "not slow and not sigpy" --junitxml=pytest.xml \ | |
--cov-report=term-missing:skip-covered --cov=sequences | tee pytest-coverage.txt | |
fi | |
continue-on-error: ${{ matrix.include-sigpy }} | |
- name: Verify PyTest XML Output | |
run: | | |
if [ ! -f pytest.xml ]; then | |
echo "PyTest XML report not found. Please check the previous 'Run PyTest' step for errors." | |
exit 1 | |
fi | |
- name: Post PyTest Coverage Comment | |
id: coverageComment | |
uses: MishaKav/[email protected] | |
with: | |
pytest-coverage-path: ./pytest-coverage.txt | |
junitxml-path: ./pytest.xml | |
- name: Set Pipeline Status Based on Test Results | |
if: steps.coverageComment.outputs.errors != 0 || steps.coverageComment.outputs.failures != 0 | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
core.setFailed("PyTest workflow failed with ${{ steps.coverageComment.outputs.errors }} errors and ${{ steps.coverageComment.outputs.failures }} failures.") | |
example-sequence-tests: | |
name: Example sequence tests (slow) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.12"] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Cache pip dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install PyPulseq and dependencies | |
run: pip install --upgrade --upgrade-strategy eager .[test] | |
- name: Run only sequence tests (labeled as 'slow') | |
run: pytest -m "slow" --cov=sequences --cov-report=term-missing:skip-covered | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
# Cancel in-progress runs when a new workflow with the same group name is triggered | |
cancel-in-progress: true |