-
Notifications
You must be signed in to change notification settings - Fork 16
233 lines (210 loc) · 7.39 KB
/
pr_workflow.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
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
name: PR workflow
on:
push:
branches:
- "pull-request/[0-9]+"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-changes:
name: Check changes
runs-on: ubuntu-latest
outputs:
build-cudaq: ${{ steps.filter.outputs.build-cudaq }}
build-docs: ${{ steps.filter.outputs.build-docs }}
build-all: ${{ steps.filter.outputs.build-all }}
build-qec: ${{ steps.filter.outputs.build-qec }}
build-solvers: ${{ steps.filter.outputs.build-solvers }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
set-safe-directory: true
- name: Lookup PR info
id: get-pr-info
env:
GH_TOKEN: ${{ github.token }}
uses: nv-gha-runners/get-pr-info@main
- name: Check what needs testing
uses: dorny/paths-filter@v3
id: filter
with:
base: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).base.sha }}
filters: |
build-cudaq:
- '.github/workflows/cudaq_bump.yml'
- '.github/actions/get-cudaq-build/**'
- '.github/workflows/scripts/build_cudaq.sh'
- '.cudaq_version'
build-docs:
- '.github/workflows/docs.yaml'
- 'docs/**'
- '**/*.cpp'
- '**/*.h'
- '**/*.py'
build-all:
- '.github/actions/build-lib/action.yaml'
- '.github/actions/build-lib/build_all.yaml'
- '.github/workflows/all_libs.yaml'
- 'cmake/Modules/**'
- '**/CMakeLists.txt'
build-qec:
- '.github/actions/build-lib/action.yaml'
- '.github/actions/build-lib/build_qec.sh'
- '.github/workflows/lib_qec.yaml'
- 'cmake/Modules/**'
- 'libs/core/**/*.cpp'
- 'libs/core/**/*.h'
- 'libs/core/**/CMakeLists.txt'
- 'libs/qec/**/*.cpp'
- 'libs/qec/**/*.h'
- 'libs/qec/**/*.in'
- 'libs/qec/**/*.py'
- 'libs/qec/**/CMakeLists.txt'
build-solvers:
- '.github/actions/build-lib/action.yaml'
- '.github/actions/build-lib/build_solvers.sh'
- '.github/workflows/lib_solvers.yaml'
- 'cmake/Modules/**'
- 'libs/core/**/*.cpp'
- 'libs/core/**/*.h'
- 'libs/core/**/CMakeLists.txt'
- 'libs/solvers/**/*.cpp'
- 'libs/solvers/**/*.h'
- 'libs/solvers/**/*.in'
- 'libs/solvers/**/*.py'
- 'libs/solvers/**/CMakeLists.txt'
build-cudaq:
name: Build CUDAQ
needs: [check-changes]
if: needs.check-changes.outputs.build-cudaq == 'true'
strategy:
fail-fast: false
matrix:
platform: ['amd64', 'arm64']
runs-on: ${{ startsWith(github.repository, 'NVIDIA/cudaqx') && format('linux-{0}-cpu32', matrix.platform) || 'ubuntu-latest' }}
container: ghcr.io/nvidia/cuda-quantum-devdeps:ext-cu12.0-gcc11-main
permissions:
actions: write
contents: read
pull-requests: read
steps:
- name: Get code
uses: actions/checkout@v4
with:
set-safe-directory: true
- name: Lookup PR info
id: get-pr-info
env:
GH_TOKEN: ${{ github.token }}
uses: nv-gha-runners/get-pr-info@main
- name: Get required CUDAQ version
id: get-cudaq-version
uses: ./.github/actions/get-cudaq-version
- name: Get CUDAQ build
uses: ./.github/actions/get-cudaq-build
with:
repo: ${{ steps.get-cudaq-version.outputs.repo }}
ref: ${{ steps.get-cudaq-version.outputs.ref }}
token: ${{ secrets.CUDAQ_ACCESS_TOKEN }}
pr-number: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).number }}
save-build: true
save-ccache: false
platform: ${{ matrix.platform }}
# This is similar to build-cudaq, but it builds the CUDA-Q wheels. It uses a
# CUDA-Q docker file to perform the build and therefore cannot run in a
# container context, so it cannot be done in the same build-cudaq job.
build-cudaq-wheels:
name: Build CUDAQ wheels
needs: [check-changes]
if: needs.check-changes.outputs.build-cudaq == 'true'
strategy:
fail-fast: false
matrix:
platform: ['amd64', 'arm64']
runs-on: ${{ startsWith(github.repository, 'NVIDIA/cudaqx') && format('linux-{0}-cpu32', matrix.platform) || 'ubuntu-latest' }}
permissions:
actions: write
contents: read
pull-requests: read
steps:
- name: Get code
uses: actions/checkout@v4
with:
set-safe-directory: true
- name: Lookup PR info
id: get-pr-info
env:
GH_TOKEN: ${{ github.token }}
uses: nv-gha-runners/get-pr-info@main
- name: Get required CUDAQ version
id: get-cudaq-version
uses: ./.github/actions/get-cudaq-version
- name: Get CUDAQ wheels
uses: ./.github/actions/get-cudaq-wheels
with:
repo: ${{ steps.get-cudaq-version.outputs.repo }}
ref: ${{ steps.get-cudaq-version.outputs.ref }}
token: ${{ secrets.CUDAQ_ACCESS_TOKEN }}
pr-number: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).number }}
save-build: true
platform: ${{ matrix.platform }}
build-docs:
name: Docs
needs: [check-changes, build-cudaq]
if: |
!failure() && !cancelled() &&
needs.check-changes.outputs.build-docs == 'true'
uses: ./.github/workflows/docs.yaml
build-all:
name: All libs
needs: [check-changes, build-cudaq]
if: |
!failure() && !cancelled() &&
(needs.check-changes.outputs.build-all == 'true' || needs.check-changes.outputs.build-cudaq == 'true')
uses: ./.github/workflows/all_libs.yaml
build-qec:
name: QEC
needs: [check-changes, build-cudaq]
if: |
!failure() && !cancelled() &&
(needs.check-changes.outputs.build-qec == 'true' || needs.check-changes.outputs.build-cudaq == 'true')
uses: ./.github/workflows/lib_qec.yaml
build-solvers:
name: Solvers
needs: [check-changes, build-cudaq]
if: |
!failure() && !cancelled() &&
(needs.check-changes.outputs.build-solvers == 'true' || needs.check-changes.outputs.build-cudaq == 'true')
uses: ./.github/workflows/lib_solvers.yaml
# This job is used for branch protection checks.
verify:
name: Verify PR
if: ${{ always() }}
needs:
- build-cudaq
- build-all
- build-qec
- build-solvers
runs-on: ubuntu-latest
steps:
- name: Check results
run: |
status="success"
check_result() {
name=$1
result=$2
# NOTE: "skipped" is considered success.
if [[ "$result" == "failure" || "$result" == "cancelled" ]]; then
echo "$name job failed"
status="failed"
fi
}
check_result "build-cudaq" "${{needs.build-cudaq.result}}"
check_result "build-all" "${{needs.build-all.result}}"
check_result "build-qec" "${{needs.build-qec.result}}"
check_result "build-solvers" "${{needs.build-solvers.result}}"
if [[ "$status" != "success" ]]; then
exit 1
fi