This repository has been archived by the owner on Dec 4, 2024. It is now read-only.
forked from pulumi/pulumi
-
Notifications
You must be signed in to change notification settings - Fork 0
356 lines (331 loc) · 14 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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
name: CI
permissions:
contents: read
id-token: write
on:
workflow_call:
inputs:
ref:
required: true
description: "GitHub ref to use"
type: string
version:
required: true
description: "Version to produce"
type: string
build-all-targets:
required: false
default: true
description: "Build targets to produce, false builds only for Linux amd64."
type: boolean
test-codegen:
required: false
default: true
description: "Whether to run per-language codegen tests."
type: boolean
lint:
required: false
default: true
description: "Whether to run lints"
type: boolean
test-version-sets:
required: false
default: minimum current
description: Version sets on which to run integration tests
type: string
integration-test-platforms:
required: false
default: ubuntu-latest
description: Platforms on which to run integration tests, as a space delimited list
type: string
acceptance-test-platforms:
required: false
default: windows-latest macos-latest
description: Platforms on which to run integration tests, as a space delimited list
type: string
enable-coverage:
description: "Collects coverage stats; requires cov-enabled builds"
default: false
required: false
type: boolean
secrets:
PULUMI_BOT_TOKEN:
required: true
description: "GitHub access token, required to mitigate GitHub rate limits"
PULUMI_PROD_ACCESS_TOKEN:
required: false
description: "Pulumi access token, required to run tests against the service"
jobs:
matrix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Configure Go Cache Key
env:
CACHE_KEY: "matrix-setup"
run: echo "$CACHE_KEY" > .gocache.tmp
- name: Setup Go Caching
uses: actions/setup-go@v3 # only used by gotestsum
with:
go-version: '>=1.19.0' # decoupled from version sets, only used by gotestsum
cache: true
cache-dependency-path: |
pkg/go.sum
.gocache.tmp
- uses: actions/checkout@v3
with:
repository: dnephin/gotestsum
ref: d09768c81065b404caed0855eb3ab8f11a2a4431
path: vendor/gotestsum
- run: |
cd vendor/gotestsum
go install .
- uses: actions/cache@v3
with:
path: test-results
key: read-gotestsum-timing-${{ github.run_number }}
restore-keys: gotestsum-timing-
- name: build matrix
id: matrix
env:
BUILD_ALL_TARGETS: ${{ inputs.build-all-targets }}
TEST_CODEGEN: ${{ inputs.test-codegen }}
TEST_VERSION_SETS: ${{ inputs.test-version-sets }}
INPUT_INTEGRATION_TEST_PLATFORMS: ${{ inputs.integration-test-platforms }}
INPUT_ACCEPTANCE_TEST_PLATFORMS: ${{ inputs.acceptance-test-platforms }}
run: |
echo "::group::Prime test timing data"
mkdir -p test-results
find test-results -type f -empty -print -delete || true
echo "::endgroup::"
echo "::group::Remove old test timing data"
# Timing data prior to this date is unreliable. Codegen tests modified in #11052 and
# merged Monday Oct 17 at 6PM Pacific.
find test-results -type f ! -newermt "2022-10-17T18:00-07:00" -print -delete || true
echo "::endgroup::"
echo "::group::Test matrix variables"
readarray -td' ' VERSION_SETS_TO_TEST < <(echo -n "$TEST_VERSION_SETS"); declare -p VERSION_SETS_TO_TEST;
readarray -td' ' INTEGRATION_PLATFORMS < <(echo -n "$INPUT_INTEGRATION_TEST_PLATFORMS"); declare -p INTEGRATION_PLATFORMS;
readarray -td' ' ACCEPTANCE_PLATFORMS < <(echo -n "$INPUT_ACCEPTANCE_TEST_PLATFORMS"); declare -p ACCEPTANCE_PLATFORMS;
BUILD_TARGETS='[
{ "os": "linux", "arch": "amd64", "build-platform": "ubuntu-latest" }
]'
if [ "${BUILD_ALL_TARGETS}" = "true" ]; then
BUILD_TARGETS='[
{ "os": "linux", "arch": "amd64", "build-platform": "ubuntu-latest" },
{ "os": "linux", "arch": "arm64", "build-platform": "ubuntu-latest" },
{ "os": "windows", "arch": "amd64", "build-platform": "ubuntu-latest" },
{ "os": "windows", "arch": "arm64", "build-platform": "ubuntu-latest" },
{ "os": "darwin", "arch": "amd64", "build-platform": "ubuntu-latest" },
{ "os": "darwin", "arch": "arm64", "build-platform": "ubuntu-latest" }
]'
fi
CODEGEN_TESTS_FLAG=--codegen-tests
PKG_UNIT_TEST_PARTITIONS=7
if [ "${TEST_CODEGEN}" = "false" ]; then
CODEGEN_TESTS_FLAG=--no-codegen-tests
PKG_UNIT_TEST_PARTITIONS=3
fi
UNIT_TEST_MATRIX=$(
./scripts/get-job-matrix.py \
-vvv \
generate-matrix \
--kind unit-test \
"$CODEGEN_TESTS_FLAG" \
--platform ubuntu-latest \
--version-set current \
--partition-module pkg "$PKG_UNIT_TEST_PARTITIONS" \
--partition-module sdk 1 \
--partition-module sdk/go/pulumi-language-go 1 \
--partition-module sdk/nodejs/cmd/pulumi-language-nodejs 1 \
--partition-module sdk/python/cmd/pulumi-language-python 1 \
--partition-module tests 2
)
INTEGRATION_TEST_MATRIX=$(
./scripts/get-job-matrix.py \
-vvv \
generate-matrix \
--kind integration-test \
"$CODEGEN_TESTS_FLAG" \
--platform "${INTEGRATION_PLATFORMS[@]}" \
--version-set "${VERSION_SETS_TO_TEST[@]}" \
--partition-module pkg 1 \
--partition-module sdk 1 \
--partition-module tests 2 \
--partition-package github.com/pulumi/pulumi/tests/integration tests/integration 8
)
ACCEPTANCE_TEST_MATRIX=$(
./scripts/get-job-matrix.py \
-vvv \
generate-matrix \
--kind acceptance-test \
"$CODEGEN_TESTS_FLAG" \
--tags all xplatform_acceptance \
--platform "${ACCEPTANCE_PLATFORMS[@]}" \
--version-set current \
--partition-module pkg 1 \
--partition-module sdk 1 \
--partition-module tests 1 \
--partition-package github.com/pulumi/pulumi/tests/integration tests/integration 2
)
echo "::endgroup::"
echo "::group::Version set variable"
VERSION_SET=$(./scripts/get-job-matrix.py \
generate-version-set \
--version-set current
)
echo "::endgroup::"
echo "::group::Unit test matrix"
echo "$UNIT_TEST_MATRIX" | yq -P '.'
echo "::endgroup::"
echo "::group::Integration test matrix"
echo "$INTEGRATION_TEST_MATRIX" | yq -P '.'
echo "::endgroup::"
echo "::group::acceptance test matrix"
echo "$ACCEPTANCE_TEST_MATRIX" | yq -P '.'
echo "::endgroup::"
echo "::group::Version set"
echo "$VERSION_SET" | yq -P '.'
echo "::endgroup::"
echo "::group::Set outputs"
./.github/scripts/set-output unit-test-matrix "${UNIT_TEST_MATRIX}"
./.github/scripts/set-output integration-test-matrix "${INTEGRATION_TEST_MATRIX}"
./.github/scripts/set-output acceptance-test-matrix "${ACCEPTANCE_TEST_MATRIX}"
./.github/scripts/set-output version-set "${VERSION_SET}"
./.github/scripts/set-output build-targets "${BUILD_TARGETS}"
echo "::endgroup::"
outputs:
unit-test-matrix: "${{ fromJson(steps.matrix.outputs.unit-test-matrix) }}"
integration-test-matrix: "${{ fromJson(steps.matrix.outputs.integration-test-matrix) }}"
acceptance-test-matrix: "${{ fromJson(steps.matrix.outputs.acceptance-test-matrix) }}"
version-set: "${{ fromJson(steps.matrix.outputs.version-set) }}"
build-targets: "${{ fromJson(steps.matrix.outputs.build-targets) }}"
lint:
name: Lint
needs: [matrix]
if: ${{ inputs.lint }}
uses: ./.github/workflows/ci-lint.yml
with:
ref: ${{ inputs.ref }}
version-set: ${{ needs.matrix.outputs.version-set }}
build-binaries:
name: build binaries
needs: [matrix]
strategy:
# To avoid tying up macOS runners:
# If using IDE, ignore yaml-schema error: 'Incorrect type. Expected "boolean"'
fail-fast: ${{ contains(needs.matrix.outputs.build-targets, 'macos') }}
matrix:
target: ${{ fromJson(needs.matrix.outputs.build-targets) }}
uses: ./.github/workflows/ci-build-binaries.yml
with:
ref: ${{ inputs.ref }}
version: ${{ inputs.version }}
os: ${{ matrix.target.os }}
arch: ${{ matrix.target.arch }}
build-platform: ${{ matrix.target.build-platform }}
version-set: ${{ needs.matrix.outputs.version-set }}
enable-coverage: ${{ inputs.enable-coverage }}
secrets: inherit
build-sdks:
name: Build SDKs
needs: [matrix]
uses: ./.github/workflows/ci-build-sdks.yml
with:
ref: ${{ inputs.ref }}
version: ${{ inputs.version }}
version-set: ${{ needs.matrix.outputs.version-set }}
secrets: inherit
# Tests that can run concurrently with builds.
unit-test:
# By putting a variable in the name, we remove GitHub's auto-generated matrix parameters from
# appearing in the rendered title of the job name: It changes this:
# CI / Unit Test (cd sdk/dotnet && make dotnet_test, cd sdk/dotnet && make dotnet_test, macos-11, mi... / sdk/dotnet dotnet_test on macos-11/current
# (See: https://github.com/pulumi/pulumi/runs/8241055084?check_suite_focus=true#logs)
# To this:
# CI / Unit Test / sdk/dotnet dotnet_test on macos-11/current
name: Unit Test${{ matrix.platform && '' }}
needs: [matrix, lint]
if: ${{ needs.matrix.outputs.unit-test-matrix != '{}' }}
strategy:
fail-fast: ${{ contains(needs.matrix.outputs.unit-test-matrix, 'macos') }}
matrix: ${{ fromJson(needs.matrix.outputs.unit-test-matrix) }}
uses: ./.github/workflows/ci-run-test.yml
with:
ref: ${{ inputs.ref }}
version: ${{ inputs.version }}
platform: ${{ matrix.platform }}
test-name: ${{ matrix.test-suite.name || matrix.test-suite.command }} on ${{ matrix.platform }}/${{ matrix.version-set.name }}
test-command: ${{ matrix.test-suite.command }}
is-integration-test: false
enable-coverage: ${{ inputs.enable-coverage }}
# require-build: false # TODO, remove ${{ matrix.require-build || false }}
version-set: ${{ toJson(matrix.version-set) }}
secrets: inherit
# Tests that depend on builds
integration-test:
# By putting a variable in the name, we remove GitHub's auto-generated matrix parameters from
# appearing in the rendered title of the job name. See: unit test.
name: Integration Test${{ matrix.platform && '' }}
needs: [matrix, build-binaries, build-sdks, lint]
if: ${{ needs.matrix.outputs.integration-test-matrix != '{}' }}
strategy:
fail-fast: ${{ contains(needs.matrix.outputs.integration-test-matrix, 'macos') }}
matrix: ${{ fromJson(needs.matrix.outputs.integration-test-matrix) }}
uses: ./.github/workflows/ci-run-test.yml
with:
ref: ${{ inputs.ref }}
version: ${{ inputs.version }}
platform: ${{ matrix.platform }}
test-name: ${{ matrix.test-suite.name || matrix.test-suite.command }} on ${{ matrix.platform }}/${{ matrix.version-set.name }}
test-command: ${{ matrix.test-suite.command }}
is-integration-test: true # TODO: set to true here
enable-coverage: ${{ inputs.enable-coverage }}
# require-build: false # TODO, remove ${{ matrix.require-build || false }}
version-set: ${{ toJson(matrix.version-set) }}
secrets: inherit
# Tests that depend on builds, but a smaller subset against Windows & MacOS platforms.
acceptance-test:
# By putting a variable in the name, we remove GitHub's auto-generated matrix parameters from
# appearing in the rendered title of the job name. See: unit test.
name: Acceptance Test${{ matrix.platform && '' }}
needs: [matrix, build-binaries, build-sdks]
if: ${{ needs.matrix.outputs.acceptance-test-matrix != '{}' }}
# alow jobs to fail if the platform contains windows
strategy:
fail-fast: ${{ contains(needs.matrix.outputs.acceptance-test-matrix, 'macos') }}
matrix: ${{ fromJson(needs.matrix.outputs.acceptance-test-matrix) }}
uses: ./.github/workflows/ci-run-test.yml
with:
ref: ${{ inputs.ref }}
version: ${{ inputs.version }}
platform: ${{ matrix.platform }}
test-name: ${{ matrix.test-suite.name || matrix.test-suite.command }} on ${{ matrix.platform }}/${{ matrix.version-set.name }}
test-command: ${{ matrix.test-suite.command }}
is-integration-test: true # TODO: set to true here
enable-coverage: ${{ inputs.enable-coverage }}
# require-build: false # TODO, remove ${{ matrix.require-build || false }}
version-set: ${{ toJson(matrix.version-set) }}
secrets: inherit
test-collect-reports:
needs: [unit-test, integration-test, acceptance-test]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
with:
path: test-results
key: gotestsum-timing-${{ github.run_number }}
restore-keys: gotestsum-timing-
- uses: actions/download-artifact@v3
continue-on-error: true
with:
name: gotestsum-test-results
path: test-results
- name: List and clean up test results
continue-on-error: true
run: |
ls -lhR test-results
find test-results -mindepth 1 -name '*.json' -mtime +7 -delete