-
Notifications
You must be signed in to change notification settings - Fork 129
168 lines (144 loc) · 5.4 KB
/
ci.yaml
File metadata and controls
168 lines (144 loc) · 5.4 KB
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
# Copyright 2020 Google, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Continuous integration tests
run-name: >-
Test code and notebooks in
${{github.event_name == 'pull_request' && format('PR #{0}', github.event.pull_request.number)
|| format('push to {0}', github.ref_name) }}
by @${{github.actor}}
on:
push:
branches:
- main
pull_request:
branches:
- main
merge_group:
types:
- checks_requested
workflow_dispatch:
# Declare default workflow permissions as read only.
permissions: read-all
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:
# Python version to use.
python_version: 3.11
# Files containing lists of dependencies installed using pip. This is used as
# a parameter to setup-python to check whether its pip cache needs updating.
python_dep_files: |-
requirements.txt
recirq/**/extra-requirements.txt
dev_tools/requirements/deps/*.txt
dev_tools/check_notebooks.py
dev_tools/write-ci-requirements.py
jobs:
pytest:
name: Run Python tests
if: github.repository_owner == 'quantumlib'
runs-on: ubuntu-22.04-x64-8-core
timeout-minutes: 15
strategy:
matrix:
cirq-version:
- 'current'
- 'previous'
- 'next'
fail-fast: false
steps:
- name: Check out a copy of the git repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set up Python with caching of pip dependencies
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: ${{env.python_version}}
cache: pip
cache-dependency-path: ${{env.python_dep_files}}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python dev_tools/write-ci-requirements.py \
--relative-cirq-version=${{ matrix.cirq-version }} --all-extras
pip install -r ci-requirements.txt
pip install --no-deps -e .
- name: Test with pytest
run: |
# OMP_NUM_THREADS: PySCF's poor OpenMP performance slows down QCQMC tests.
# RECIRQ_IMPORT_FAILSAFE: skip tests on unsupported Cirq configurations.
export OMP_NUM_THREADS=1
RECIRQ_IMPORT_FAILSAFE=y pytest -n logical -v --skipslow
pylint:
name: Run Python linters
if: github.repository_owner == 'quantumlib'
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- name: Check out a copy of the git repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set up Python with caching of pip dependencies
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: ${{env.python_version}}
cache: pip
cache-dependency-path: ${{env.python_dep_files}}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names.
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# `exit-zero` treats all errors as warnings. The GitHub editor is 127 chars wide.
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
nbformat:
name: Check notebook formatting
if: github.repository_owner == 'quantumlib'
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- name: Check out a copy of the git repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set up Python with caching of pip dependencies
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: ${{env.python_version}}
cache: pip
cache-dependency-path: ${{env.python_dep_files}}
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install -r dev_tools/requirements/deps/tensorflow-docs.txt
- name: Check notebook formatting
run: |
dev_tools/nbformat
yaml-lint:
name: YAML lint checks
if: github.repository_owner == 'quantumlib'
runs-on: ubuntu-slim
timeout-minutes: 15
steps:
- name: Check out a copy of the git repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: Install yamllint
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y yamllint
- name: Lint the YAML files
run: yamllint -f github .