Skip to content

Merge pull request #6586 from paniash/fix-link #16414

Merge pull request #6586 from paniash/fix-link

Merge pull request #6586 from paniash/fix-link #16414

Workflow file for this run

name: Run mypy and pytest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- 'main'
- 'release/*'
tags:
- 'v*'
pull_request:
merge_group:
branches: ['main']
permissions:
contents: read
jobs:
pytestmypy:
runs-on: ${{ matrix.os }}
strategy:
# don't stop other jobs if one fails
# this is often due to network issues
# and or flaky tests
# and the time lost in such cases
# is bigger than the gain from canceling the job
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12", "3.13"]
min-version: [false]
include:
- os: ubuntu-latest
python-version: "3.10"
min-version: true
exclude:
- os: ubuntu-latest
python-version: "3.10"
- os: windows-latest
python-version: "3.11"
- os: windows-latest
python-version: "3.12"
- os: windows-latest
python-version: "3.13"
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
# we need full history with tags for the version number
fetch-depth: '0'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
pyproject.toml
requirements.txt
- name: upgrade pip setuptools wheel
run: python -m pip install --upgrade pip setuptools wheel
shell: bash
- name: install qcodes with minimum requirements
run: |
pip install uv
uv pip compile pyproject.toml --extra test --resolution=lowest-direct --output-file min-requirements.txt
pip install -r min-requirements.txt
pip install .[test]
echo "PYTEST_OPT=-Wignore" >> $GITHUB_ENV
if: ${{ matrix.min-version }}
- name: install qcodes
run: |
pip install .[test] -c requirements.txt
echo "PYTEST_OPT=" >> $GITHUB_ENV
if: ${{ !matrix.min-version }}
- name: Get Pyright Version
id: pyright-version
run: |
PYRIGHT_VERSION=$(jq -r '.devDependencies.pyright' < package.json)
echo $PYRIGHT_VERSION
echo "version=$PYRIGHT_VERSION" >> $GITHUB_OUTPUT
working-directory: .github
shell: bash
- uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2
with:
version: ${{ steps.pyright-version.outputs.version }}
if: ${{ !matrix.min-version }}
- name: Run Mypy
run: mypy -p qcodes
if: ${{ !matrix.min-version }}
- name: Run parallel tests
run: |
pytest -m "not serial" --cov=qcodes --cov-report xml --hypothesis-profile ci --durations=20 $PYTEST_OPT tests
# a subset of the tests fails when run in parallel on Windows so run those in serial here
- name: Run serial tests
run: |
pytest -m "serial" -n 0 --dist no --cov=qcodes --cov-report xml --cov-append --hypothesis-profile ci $PYTEST_OPT tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
with:
file: ./coverage.xml
env_vars: OS,PYTHON
token: ${{ secrets.CODECOV_TOKEN }}
if: ${{ github.event_name != 'merge_group' }}
# we don't trigger coverage from merge groups since that would
# make twice the number of coverage reports be uploded from a given commit