This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
218 lines (217 loc) · 7.59 KB
/
ci.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
name: CI
on:
[ push, pull_request ]
# save resources: cancel redundant workflow runs on the same branch when new commits are pushed
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
code-quality:
if: github.repository_owner == 'Qiskit'
name: Run code quality checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -c constraints.txt -r requirements-dev.txt -e .
- name: Run black
run: make style
- name: Run lint
run: make lint
- name: Run mypy
run: make mypy
documentation:
if: github.repository_owner == 'Qiskit'
name: Build documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U tox
sudo apt install -y graphviz pandoc
pip install -c constraints.txt -e .
- name: Build documentation
run: tox -edocs
- name: Upload documentation
uses: actions/upload-artifact@v2
with:
name: html_docs
path: docs/_build/html
unit-tests:
if: github.repository_owner == 'Qiskit'
# only kick-off test cases when basic code quality checks succeed
needs: [ "code-quality" , "documentation" ]
name: Run unit tests - python${{ matrix.python-version }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [ 3.8, 3.9, '3.10', '3.11']
os: [ "macOS-latest", "ubuntu-latest", "windows-latest" ]
env:
LOG_LEVEL: DEBUG
STREAM_LOG: True
QISKIT_IN_PARALLEL: True
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -c constraints.txt -r requirements-dev.txt -e .
- name: Run unit tests
run: make unit-test-coverage
- name: Report coverage to coveralls.io
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: unit-tests_python${{ matrix.python-version }}-${{ matrix.os }}
parallel: true
path-to-lcov: coverage.lcov
integration-tests-1:
if: github.event_name == 'push' && github.repository_owner == 'Qiskit'
# only kick-off resource intensive integration tests if unit tests and all basic checks succeeded
needs: [ "unit-tests" ]
name: Run integration tests 1 - ${{ matrix.environment }}
runs-on: ${{ matrix.os }}
strategy:
# avoid cancellation of in-progress jobs if any matrix job fails
fail-fast: false
matrix:
python-version: [ 3.9 ]
os: [ "ubuntu-latest" ]
environment: [ "ibm-quantum-production" ]
environment: ${{ matrix.environment }}
env:
QISKIT_IBM_TOKEN: ${{ secrets.QISKIT_IBM_TOKEN }}
QISKIT_IBM_URL: ${{ secrets.QISKIT_IBM_URL }}
QISKIT_IBM_INSTANCE: ${{ secrets.QISKIT_IBM_INSTANCE }}
LOG_LEVEL: DEBUG
STREAM_LOG: True
QISKIT_IN_PARALLEL: True
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -c constraints.txt -e . -r requirements-dev.txt
- name: Run integration tests 1
run: make integration-test-1
integration-tests-2:
if: github.event_name == 'push' && github.repository_owner == 'Qiskit'
# only kick-off resource intensive integration tests if unit tests and all basic checks succeeded
needs: [ "unit-tests" ]
name: Run integration tests 2 - ${{ matrix.environment }}
runs-on: ${{ matrix.os }}
strategy:
# avoid cancellation of in-progress jobs if any matrix job fails
fail-fast: false
matrix:
python-version: [ 3.9 ]
os: [ "ubuntu-latest" ]
environment: [ "ibm-quantum-production" ]
environment: ${{ matrix.environment }}
env:
QISKIT_IBM_TOKEN: ${{ secrets.QISKIT_IBM_TOKEN }}
QISKIT_IBM_URL: ${{ secrets.QISKIT_IBM_URL }}
QISKIT_IBM_INSTANCE: ${{ secrets.QISKIT_IBM_INSTANCE }}
LOG_LEVEL: DEBUG
STREAM_LOG: True
QISKIT_IN_PARALLEL: True
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -c constraints.txt -e . -r requirements-dev.txt
- name: Run integration tests 2
run: make integration-test-2
integration-tests-3:
if: github.event_name == 'push' && github.repository_owner == 'Qiskit'
# only kick-off resource intensive integration tests if unit tests and all basic checks succeeded
needs: [ "unit-tests" ]
name: Run integration tests 3 - ${{ matrix.environment }}
runs-on: ${{ matrix.os }}
strategy:
# avoid cancellation of in-progress jobs if any matrix job fails
fail-fast: false
matrix:
python-version: [ 3.9 ]
os: [ "ubuntu-latest" ]
environment: [ "ibm-quantum-production" ]
environment: ${{ matrix.environment }}
env:
QISKIT_IBM_TOKEN: ${{ secrets.QISKIT_IBM_TOKEN }}
QISKIT_IBM_URL: ${{ secrets.QISKIT_IBM_URL }}
QISKIT_IBM_INSTANCE: ${{ secrets.QISKIT_IBM_INSTANCE }}
LOG_LEVEL: DEBUG
STREAM_LOG: True
QISKIT_IN_PARALLEL: True
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -c constraints.txt -e . -r requirements-dev.txt
- name: Run integration tests 3
run: make integration-test-3
tests-finished:
if: github.repository_owner == 'Qiskit'
name: Submit code coverage metrics
needs: [ unit-tests ]
runs-on: ubuntu-latest
steps:
- name: Notify coveralls.io that all parallel tests have finished
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true