-
Notifications
You must be signed in to change notification settings - Fork 385
265 lines (224 loc) · 7.16 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# Summary: OpenFermion continuous integration status checks.
#
# This workflow runs various tests to verify that changes to the OpenFermion
# codebase pass validation and conform to project format and style standards.
# It triggers on certain events such as pull requests and merge-queue merges,
# and can also be invoked manually via the "Run workflow" button at
# https://github.com/quantumlib/OpenFermion/actions/workflows/ci.yaml
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
name: Continuous integration checks
run-name: Continuous integration checks triggered by ${{github.event_name}}
on:
pull_request:
types: [opened, synchronize]
branches:
- master
merge_group:
types:
- checks_requested
push:
branches:
- master
# Allow manual invocation.
workflow_dispatch:
inputs:
python_ver:
description: Version of Python to use
type: string
default: "3.10.11"
concurrency:
# Cancel any previously-started but still active runs on the same branch.
cancel-in-progress: true
group: ${{github.workflow}}-${{github.event.pull_request.number||github.ref}}
env:
# Default Python version to use.
python_ver: "3.10.11"
# Files listing dependencies we install using pip in the various jobs below.
# This is used by setup-python to check whether its cache needs updating.
python_dep_files: >-
dev_tools/requirements/envs/format.env.txt
dev_tools/requirements/envs/mypy.env.txt
dev_tools/requirements/envs/pylint.env.txt
dev_tools/requirements/envs/pytest-extra.env.txt
dev_tools/requirements/envs/pytest.env.txt
dev_tools/requirements/max_compat/pytest-max-compat.env.txt
jobs:
Setup:
runs-on: ubuntu-latest
steps:
- name: Check out a copy of the OpenFermion git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python with caching of pip dependencies
uses: actions/setup-python@v5
with:
python-version: ${{inputs.python_ver || env.python_ver}}
architecture: "x64"
cache: pip
cache-dependency-path: ${{env.python_dep_files}}
- name: Install Python requirements
run: |
set -x
for file in ${{env.python_dep_files}}; do
pip install -r $file
done
set +x
echo "::group::List of installed pip packages and their versions"
pip list
echo "::endgroup::"
format:
name: Format check
needs: Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{inputs.python_ver || env.python_ver}}
architecture: "x64"
cache: pip
cache-dependency-path: ${{env.python_dep_files}}
- name: Install requirements
run: pip install -r dev_tools/requirements/envs/format.env.txt
- name: Format
run: check/format-incremental
mypy:
name: Type check
needs: Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{inputs.python_ver || env.python_ver}}
architecture: "x64"
cache: pip
cache-dependency-path: ${{env.python_dep_files}}
- name: Install requirements
run: pip install -r dev_tools/requirements/envs/mypy.env.txt
- name: Type check
run: check/mypy
pylint:
name: Lint check
needs: Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{inputs.python_ver || env.python_ver}}
architecture: "x64"
cache: pip
cache-dependency-path: ${{env.python_dep_files}}
- name: Install requirements
run: pip install -r dev_tools/requirements/envs/pylint.env.txt
- name: Lint
run: check/pylint
pytest-max-compat:
name: Pytest max compat
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
# Note: deliberately not using our Python cache here b/c this runs
# a different version of Python.
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install requirements
run: |
pip install -r dev_tools/requirements/max_compat/pytest-max-compat.env.txt
- name: Pytest check
run: check/pytest
shell: bash
pytest-matrix:
name: Pytest matrix
needs: Setup
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
cirq-version: [ 1.4.1 ]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{inputs.python_ver || env.python_ver}}
cache: pip
cache-dependency-path: ${{env.python_dep_files}}
- name: Install requirements
run: |
pip install -r dev_tools/requirements/envs/pytest.env.txt
pip install cirq-core==${{matrix.cirq-version}}
- name: Pytest check
run: check/pytest
shell: bash
pytest:
if: always()
name: Pytest
needs: pytest-matrix
runs-on: ubuntu-latest
steps:
- run: |
result="${{needs.pytest-matrix.result}}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi
pytest-extra-matrix:
name: Pytest extra matrix
needs: Setup
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
cirq-version: [ 1.4.1 ]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{inputs.python_ver || env.python_ver}}
cache: pip
cache-dependency-path: ${{env.python_dep_files}}
- name: Install requirements
run: |
pip install -r dev_tools/requirements/envs/pytest-extra.env.txt
pip install cirq-core==${{matrix.cirq-version}}
- name: Pytest check resources
run: check/pytest -m "not slow" src/openfermion/resource_estimates
shell: bash
pytest-extra:
if: always()
name: Pytest extra
needs: pytest-extra-matrix
runs-on: ubuntu-latest
steps:
- run: |
result="${{needs.pytest-extra-matrix.result}}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi
coverage:
name: Coverage check
needs: Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{inputs.python_ver || env.python_ver}}
cache: pip
cache-dependency-path: ${{env.python_dep_files}}
- name: Install requirements
run: pip install -r dev_tools/requirements/envs/pytest.env.txt
- name: Coverage check
run: check/pytest-and-incremental-coverage