Skip to content

Run tests as part of CI #22

Run tests as part of CI

Run tests as part of CI #22

Workflow file for this run

name: 'Install PyGEM and Run Test Suite'
on:
push:
branches:
- master
- dev
paths:
- '**.py'
- '.github/workflows/test_suite.yml'
- 'pyproject.toml'
pull_request:
paths:
- '**.py'
- '.github/workflows/test_suite.yml'
- 'pyproject.toml'
# Run test suite every Saturday at 1AM GMT (1 hour after the Docker image is updated)
schedule:
- cron: '0 1 * * 6'
# Stop the workflow if a new one is started
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
set-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-branches.outputs.matrix }}
steps:
# Set the matrix for the test_suite job. Use master and dev branches for scheduled runs
# and the branch of the push event otherwise
- id: set-branches
run: |
if [[ "${{ github.event_name }}" == "schedule" ]]; then
echo "matrix={\"branch\":[\"master\",\"dev\"]}" >> $GITHUB_OUTPUT
else
echo "matrix={\"branch\":[\"${{ github.head_ref }}\"]}" >> $GITHUB_OUTPUT
fi
test_suite:
name: 'Test suite'
needs: set-matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.set-matrix.outputs.matrix) }}
fail-fast: false
# Use pygem:latest for master branch and pygem:dev otherwise
container:
image: ghcr.io/pygem-community/pygem:${{ github.ref == 'refs/heads/master' && 'latest' || 'dev' }}
options: --user root
steps:
- name: 'Check out the repo'
id: checkout
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
- name: 'Reinstall PyGEM'
run: pip install --break-system-packages -e .
- name: 'Run tests'
run: |
python3 -m coverage erase
python3 -m pytest --cov=pygem -v --durations=20 pygem/tests