workflows/release: fix missing artifacts downloads (#208) #410
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: Tests | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
# Run on manual triggers | |
workflow_dispatch: | |
env: | |
PYTHONIOENCODING: utf-8 | |
jobs: | |
tests: | |
name: tests-python${{ matrix.python-version }}-${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
python-version: ['3.9', '3.10', '3.11', '3.12'] | |
poetry-version: [1.8.3] | |
os: ["ubuntu-latest", "windows-latest"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Install poetry | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: ${{ matrix.poetry-version }} | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "poetry" | |
- name: Check shell scripts | |
uses: ludeeus/action-shellcheck@2.0.0 | |
if: startsWith(matrix.os, 'ubuntu') | |
- name: Check Poetry lock file status | |
run: poetry check --lock | |
- name: Install coverage tool | |
run: | | |
poetry run pip install coverage[toml] | |
if: startsWith(matrix.os, 'ubuntu') | |
- name: Install examples and test dependencies | |
run: | | |
poetry install --only main --extras examples | |
- name: Run examples (linux) | |
run: | | |
poetry run examples/run_all.sh -c | |
if: startsWith(matrix.os, 'ubuntu') | |
- name: Run examples (windows) | |
run: | | |
# TODO: list examples programmatically | |
echo "Running example.py" | |
poetry run python examples/example.py | |
echo "Running example_noise.py" | |
poetry run python examples/example_noise.py | |
echo "Running quickstart-sampler.py" | |
poetry run python examples/quickstart-sampler.py | |
echo "Running quickstart-estimator.py" | |
poetry run python examples/quickstart-estimator.py | |
echo "Running quickstart-transpile.py" | |
poetry run python examples/quickstart-transpile.py | |
echo "Running vqe.py" | |
poetry run python examples/vqe.py | |
echo "Running qaoa.py" | |
poetry run python examples/qaoa.py | |
echo "Running number_partition.py" | |
poetry run python examples/number_partition.py | |
if: startsWith(matrix.os, 'windows') | |
- name: Install all dependencies | |
run: poetry install --sync --all-extras | |
- name: Check version numbers consistency | |
run: poetry run poe version_check | |
if: startsWith(matrix.os, 'ubuntu') | |
- name: Check formatting | |
run: poetry run poe format_check | |
if: startsWith(matrix.os, 'ubuntu') | |
- name: Linting | |
run: poetry run poe lint | |
if: startsWith(matrix.os, 'ubuntu') | |
- name: Type checking | |
run: poetry run poe typecheck | |
if: startsWith(matrix.os, 'ubuntu') | |
- name: Testing | |
run: poetry run poe test --cov_opts="-a" # add to examples coverage | |
if: startsWith(matrix.os, 'ubuntu') | |
- name: Docs | |
run: poetry run poe docs | |
if: startsWith(matrix.os, 'ubuntu') | |
- name: Generate coverage report | |
run: poetry run coverage lcov -o coverage.lcov | |
if: startsWith(matrix.os, 'ubuntu') | |
- name: Upload coverage report | |
uses: coverallsapp/github-action@v2 | |
with: | |
file: coverage.lcov | |
parallel: true | |
flag-name: run ${{ join(matrix.*, ' - ') }} | |
if: startsWith(matrix.os, 'ubuntu') | |
finish: | |
needs: tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Close parallel coverage build | |
uses: coverallsapp/github-action@v2 | |
with: | |
parallel-finished: true |