-
Notifications
You must be signed in to change notification settings - Fork 21
137 lines (137 loc) · 4.58 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Tests
on:
push:
branches:
- master
pull_request:
# Run on manual triggers
workflow_dispatch:
env:
PYTHONIOENCODING: utf-8
jobs:
build-packages:
name: build-packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
cache: "pip"
- name: Install uv
run: |
# https://github.com/astral-sh/uv/issues/1386#issuecomment-1947801083
echo "VIRTUAL_ENV=${Python_ROOT_DIR}" >> $GITHUB_ENV
pip install uv
- name: Build packages
run: |
uv pip install hatch
hatch build
- name: Store packages
uses: actions/upload-artifact@v4
with:
name: packages
path: dist/
examples:
needs: build-packages
name: examples-${{ matrix.os }}-py${{ matrix.python-version }}-qiskit${{ matrix.qiskit-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
qiskit-version: ['0.46.0', '1.0.1']
python-version: ['3.9', '3.10', '3.11', '3.12']
os: ["ubuntu-latest"]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
run: |
# https://github.com/astral-sh/uv/issues/1386#issuecomment-1947801083
echo "VIRTUAL_ENV=${Python_ROOT_DIR}" >> $GITHUB_ENV
pip install uv
- name: Restore packages
uses: actions/download-artifact@v4
with:
name: packages
path: dist
- name: Install package wheel
run: |
# there is only one wheel in dist/
echo "qiskit==${{ matrix.qiskit-version }}" > override.txt
uv pip install --strict --override override.txt "qiskit-aqt-provider[examples] @ $(ls dist/*.whl)"
- name: Checkout examples # FIXME: ship examples with source distribution
uses: actions/checkout@v4
with:
sparse-checkout: |
examples
sparse-checkout-cone-mode: false
- name: Run examples
run: |
./examples/run_all.sh
tests:
name: tests-${{ matrix.os }}-py${{ matrix.python-version }}-qiskit${{ matrix.qiskit-version }}-resolve-${{ matrix.resolution-strategy }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
qiskit-version: ['0.46.0', '1.0.1']
python-version: ['3.9', '3.10', '3.11', '3.12']
os: ['ubuntu-latest']
resolution-strategy: ['highest', 'lowest-direct']
steps:
- uses: actions/checkout@v4
- name: Check shell scripts
uses: ludeeus/[email protected]
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install uv
run: |
# https://github.com/astral-sh/uv/issues/1386#issuecomment-1947801083
echo "VIRTUAL_ENV=${Python_ROOT_DIR}" >> $GITHUB_ENV
pip install uv
- name: Lock dependencies
run: |
echo "qiskit==${{ matrix.qiskit-version }}" > qiskit-override.txt
# FIXME: https://github.com/Qiskit/qiskit_sphinx_theme/issues/567
echo 'furo==2023.9.10' > furo-override.txt
uv pip compile pyproject.toml --all-extras --override qiskit-override.txt --override furo-override.txt | tee requirements.txt
- name: Install project
run: |
uv pip sync --strict requirements.txt
uv pip install 'qiskit-aqt-provider @ .' # for the plugins
- name: Check version numbers consistency
run: poe version_check
- name: Check formatting
run: poe format_check
- name: Linting
run: poe lint
- name: Type checking
run: poe typecheck
- name: Run examples with coverage
run: |
./examples/run_all.sh -c
- name: Run tests with coverage
run: poe test --cov_opts="-a" # add to examples coverage
- name: Build docs
run: poe docs
- name: Generate coverage report
run: coverage lcov -o coverage.lcov
- name: Upload coverage report
uses: coverallsapp/github-action@v2
with:
file: coverage.lcov
parallel: true
flag-name: run ${{ join(matrix.*, ' - ') }}
finish:
needs: tests
runs-on: ubuntu-latest
steps:
- name: Close parallel coverage build
uses: coverallsapp/github-action@v2
with:
parallel-finished: true