Skip to content

docs: record phase 7 review and remaining validation #428

docs: record phase 7 review and remaining validation

docs: record phase 7 review and remaining validation #428

name: pytest
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
run_pytest:
name: Tests (Python ${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
GH_ACTION: True
TZ: Europe/London
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
python-version: [ "3.11", "3.12","3.13", "3.14"]
os: ["ubuntu-latest"]
include:
- python-version: "3.14"
os: ubuntu-latest
coverage: true
- python-version: "3.14"
os: macos-15-intel
micromamba-extra-args: pyqt6
steps:
- name: Check out repository code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Install Mamba environment
uses: mamba-org/setup-micromamba@f457c30a868e4760d3a6fcea5f25dc655b8edf39 # v3.2.1
with:
environment-file: tests/test-env.yml
environment-name: test-environment
create-args: >-
python=${{ matrix.python-version }}
--channel-priority flexible
${{ matrix.micromamba-extra-args }}
init-shell: bash
cache-downloads: true
cache-environment: true
- name: Mamba information
run: |
micromamba info
micromamba list
- name: install package
run: pip install --no-deps .
- name: Install headless server
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install xvfb
sudo apt-get install qtbase5-dev
- name: Test with xvfb on Linux
if: runner.os == 'Linux'
env:
LC_CTYPE: en_GB.UTF-8
COLLECT_COVERAGE: ${{ matrix.coverage == true }}
run: |
coverage_args=()
if [[ "$COLLECT_COVERAGE" == "true" ]]; then
coverage_args=(--cov-config="$GITHUB_WORKSPACE/pyproject.toml" --cov-report= --cov=Stoner)
fi
xvfb-run --auto-servernum pytest -vv -n 2 -o faulthandler_timeout=120 --durations=20 "${coverage_args[@]}" --junitxml pytest.xml || PYTEST_EXIT=$?
if [[ "$COLLECT_COVERAGE" == "true" ]]; then
coverage xml
fi
exit ${PYTEST_EXIT:-0}
- name: Test on macOS
if: runner.os != 'Linux'
run: |
pytest -vv -n 2 -o faulthandler_timeout=120 --durations=20 --junitxml pytest.xml || PYTEST_EXIT=$?
exit ${PYTEST_EXIT:-0}
env:
QT_QPA_PLATFORM: offscreen
- name: Cleanup X11 server
if: runner.os == 'Linux'
uses: bcomnes/cleanup-xvfb@9e016c43bb8d73fe7d5933d2ef00fd770c1a7c50 # v1.0.9
- name: Upload coverage to Coveralls
if: matrix.coverage == true
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7
with:
flag-name: run-${{ matrix.python-version }}-${{ matrix.os }}
format: cobertura
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: Unit Test Results (Python ${{ matrix.python-version }}, ${{ matrix.os }})
path: pytest.xml
- name: Post coverage result to Codacy
if: matrix.coverage == true && github.event_name != 'pull_request'
uses: codacy/codacy-coverage-reporter-action@89d6c85cfafaec52c72b6c5e8b2878d33104c699 # v1.3.0
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml
publish-test-results:
name: "Publish Unit Tests Results"
needs: run_pytest
runs-on: ubuntu-latest
if: >-
${{ always() &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository) }}
permissions:
checks: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: artifacts
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@c950f6fb443cb5af20a377fd0dfaa78838901040 # v2.23.0
with:
files: artifacts/**/*.xml