-
Notifications
You must be signed in to change notification settings - Fork 1.1k
153 lines (134 loc) · 4.83 KB
/
pytest-debug.yaml
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
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary: GitHub workflow for manually running pytest with debug flags.
#
# This workflow can only be executed manually, e.g., using the "Run workflow"
# button on https://github.com/quantumlib/Cirq/actions/workflows/debug.yaml
# Clicking the "Run workflow" button there will present a form interface with
# various options for the characteristics of the run.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
name: Run pytest with debug options
on:
workflow_dispatch:
inputs:
py-version:
description: "Python version:"
type: choice
default: "3.12"
options:
- "3.13"
- "3.12"
- "3.11"
- "3.10"
os:
description: "Runner OS:"
type: choice
default: ubuntu-22.04
options:
- ubuntu-22.04
- ubuntu-20.04
- macos-15
- macos-14
- macos-13
- windows-2025
- windows-2022
- windows-2019
arch:
description: "Hardware architecture:"
type: choice
default: x64
options:
- x64
- arm64
single-test:
description: "Run specific single test:"
type: string
default: ""
repetitions:
description: "Number of repetitions:"
type: number
default: 1
random-seed:
description: "Explicit random seed:"
type: number
multiple-workers:
description: "Use multiple pytest workers"
type: boolean
default: true
verbose:
description: "Turn on verbose tracing"
type: boolean
default: false
exit-first:
description: "Stop at first error"
type: boolean
default: true
include-rigetti:
description: "Include rigetti module"
type: boolean
default: false
run-name: |
Pytest ${{inputs.single-test || '(all tests)' }} on ${{inputs.os}}
${{inputs.arch}} with Python ${{inputs.py-version}}
jobs:
pytest:
name: Run pytest
runs-on: ${{github.event.inputs.os}}
steps:
- name: Do miscellaneous preliminary configuration steps
run: |
mkdir -p ~/.cache/pip
- name: Check out a copy of the Cirq git repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{github.event.inputs.py-version}}
architecture: ${{github.event.inputs.arch}}
cache: pip
cache-dependency-path: |
dev_tools/requirements/*.txt
dev_tools/requirements/deps/*.txt
- name: Install Python requirements
run: |
set -e
requirements="dev_tools/requirements/dev.env.txt"
pip install --upgrade pip setuptools wheel
pip install --upgrade --upgrade-strategy eager -r "$requirements"
- name: Start Quil dependencies if needed
if: inputs.include-rigetti == true || inputs.include-rigetti == 'true'
run: docker compose -f cirq-rigetti/docker-compose.test.yaml up -d
- name: Run pytest
run: |
# Configure flags for pytest.
flags="--durations=20 --strict-config --ignore=cirq-core/cirq/contrib"
workers="-n auto"
if [[ -n "${{github.event.inputs.random-seed}}" ]]; then
flags=" --randomly-seed=${{github.event.inputs.random-seed}}"
fi
if [[ "${{github.event.inputs.multiple-workers}}" == "false" ]]; then
workers="-n0"
fi
if [[ "${{github.event.inputs.verbose}}" == "true" ]]; then
flags+="-vv --full-trace --setup-show"
# Save Python info to the run log, in case it's useful.
which python
pip list
fi
if [[ "${{github.event.inputs.include-rigetti}}" == true ]]; then
flags+=" --rigetti-integration"
fi
if [[ "${{github.event.inputs.exit-first}}" == "true" ]]; then
flags+=" --exitfirst"
set -e
fi
# Now finally run pytest, as many times as requested.
for i in $(seq 1 ${{github.event.inputs.repetitions}}); do
echo ""
echo -n "︎▞▚▞ Iteration $i ▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚"
echo "▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞▚▞"
echo ""
check/pytest $workers $flags ${{github.event.inputs.single-test}}
done
- name: Stop Quil dependencies if needed
if: inputs.include-rigetti == true || inputs.include-rigetti == 'true'
run: docker compose -f cirq-rigetti/docker-compose.test.yaml down