-
Notifications
You must be signed in to change notification settings - Fork 37
382 lines (336 loc) · 12.9 KB
/
build-test.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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
name: build-test
on:
workflow_call:
inputs:
ref:
required: true
type: string
version:
type: string
description: Version to be used to build the binaries, schema and SDKs
required: true
short_test:
type: boolean
description: Skip longer running tests
default: false
oidc_arm_client_id:
type: string
description: The Azure Active Directory application to authenticate the OIDC tests. Empty skips the OIDC tests.
default: "89380e12-5be6-486a-89ef-eea107af2f47" # AD app 'oidc-test'
retention_days:
type: number
description: The number of days for which we retain assets
default: 90
use_azcore:
type: boolean
description: Whether to use the newer azcore+azidentity backend for REST and auth, or the older autorest
default: true
upload_codecov:
type: boolean
description: Whether to upload coverage reports to Codecov
default: true
env:
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
PROVIDER: azure-native
PROVIDER_VERSION: ${{ inputs.version }}
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
# TRAVIS_OS_NAME required by https://github.com/pulumi/scripts/blob/master/ci/publish-tfgen-package
TRAVIS_OS_NAME: linux
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
PULUMI_GO_DEP_ROOT: ${{ github.workspace }}/..
ARM_CLIENT_ID: 30e520fa-12b4-4e21-b473-9426c5ac2e1e # application id of the "TravisCI" service principal
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_CLIENT_CERTIFICATE_PASSWORD_FOR_TEST: ${{ secrets.ARM_CLIENT_CERTIFICATE_PASSWORD }}
ARM_ENVIRONMENT: public
ARM_LOCATION: westus2
ARM_SUBSCRIPTION_ID: 0282681f-7a9e-424b-80b2-96babd57a8a1
ARM_TENANT_ID: 706143bc-e1d4-4593-aee2-c9dc60ab9be7
PULUMI_API: https://api.pulumi-staging.io
# Feature toggle that's read in provider.go enableAzcoreBackend()
PULUMI_ENABLE_AZCORE_BACKEND: ${{ inputs.use_azcore }}
# This is the content of a ~/.azure/ folder, zipped and base64-encoded, for CLI auth.
# If/when the contained refresh token expires, someone with access to our subscription needs to
# `az login` on their own computer and repeat the steps below.
# Generated by using @mikhail's .azure folder and running:
# cp -R ~/.azure ~/azure
# cd ~/azure
# rm -rf .DS_Store logs/ commands/* cliextensions/ extensionCommandTree.json
# zip -v azure.zip *
# base64 --input azure.zip | clipcopy
# Paste into repo secret
AZURE_CLI_FOLDER: ${{ secrets.AZURE_CLI_FOLDER }}
jobs:
prerequisites:
runs-on: ubuntu-latest
name: Build binaries and schema
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
submodules: true
- name: Install Languages & Frameworks
uses: ./.github/actions/install
with:
skip_dotnet_and_java: "true"
- name: Build schema and binaries
run: make codegen schema provider
- name: Artifact capture
uses: ./.github/actions/prerequisites-artifact-capture
- name: Schema Check
if: github.event_name == 'pull_request'
uses: ./.github/actions/schema-check
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
compare_to: ${{ github.base_ref }}
- name: Check worktree clean
uses: pulumi/git-status-check-action@v1
- if: failure() && github.event_name == 'push'
name: Notify Slack
uses: 8398a7/action-slack@v3
with:
author_name: Failure in building provider prerequisites
fields: repo,commit,author,action
status: ${{ job.status }}
build_sdks:
needs: prerequisites
# Use big runner for dotnet and nodejs because we need more memory and more compute, respectively
runs-on: ${{ (matrix.language == 'dotnet' || matrix.language == 'nodejs' || matrix.language == 'go') && 'pulumi-ubuntu-8core' || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix:
language:
- nodejs
- python
- dotnet
- go
- java
name: Build SDKs
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
submodules: true
- name: Install Languages & Frameworks
uses: ./.github/actions/install
- run: make ensure
- name: Prerequisites artifact restore
uses: ./.github/actions/prerequisites-artifact-restore
- name: Mark prerequisites as up-to-date
run: |
make prebuild
make --touch codegen schema provider
- name: Generate SDK
run: make generate_${{ matrix.language }}
- name: Build SDK
run: make build_${{ matrix.language }}
- name: Check worktree clean
uses: pulumi/git-status-check-action@v1
with:
allowed-changes: |
sdk/**/pulumi-plugin.json
sdk/dotnet/Pulumi.*.csproj
sdk/nodejs/package.json
sdk/python/pyproject.toml
- name: Tar SDK folder
if: ${{ matrix.language != 'go' }}
run: tar -zcf sdk/${{ matrix.language }}.tar.gz -C sdk/${{ matrix.language }} .
- name: Upload artifacts
if: ${{ matrix.language != 'go' }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.language }}-sdk.tar.gz
path: ${{ github.workspace}}/sdk/${{ matrix.language }}.tar.gz
retention-days: ${{ inputs.retention_days }}
- name: Tar split Go SDK folder
if: ${{ matrix.language == 'go' }}
run: tar -zcf sdk/pulumi-azure-native-sdk.tar.gz -C sdk/pulumi-azure-native-sdk .
- name: Upload split Go artifacts
uses: actions/upload-artifact@v4
if: ${{ matrix.language == 'go' }}
with:
name: pulumi-azure-native-sdk.tar.gz
path: ${{ github.workspace}}/sdk/pulumi-azure-native-sdk.tar.gz
retention-days: ${{ inputs.retention_days }}
- if: failure() && github.event_name == 'push'
name: Notify Slack
uses: 8398a7/action-slack@v3
with:
author_name: Failure while building SDKs
fields: repo,commit,author,action
status: ${{ job.status }}
test_sdks:
needs: build_sdks
# Use big runner for dotnet and nodejs because we need more memory and more compute, respectively
runs-on: ${{ (matrix.language == 'dotnet' || matrix.language == 'nodejs' || matrix.language == 'go') && 'pulumi-ubuntu-8core' || 'ubuntu-latest' }}
environment: env-ci
strategy:
fail-fast: false
matrix:
language:
- nodejs
- python
- dotnet
- go
- java
name: Test SDKs
permissions:
id-token: write # required for OIDC auth
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
submodules: true
- name: Setup
uses: ./.github/actions/test-setup
with:
language: ${{ matrix.language }}
- name: Write client certificate
# The provider wants the cert as a path to a cert file but GH secrets can only be strings.
# We store the base64-encoded cert as a secret, decode it here, and write it out to a file.
run: |
echo "${{ secrets.ARM_CLIENT_CERTIFICATE }}" | base64 -d > "${{ runner.temp }}/azure-client-certificate.pfx"
- name: Write .azure.tmp folder
# We write to .azure.tmp, not directly to .azure, because we want only one test to use
# this folder. The test needs to rename it to .azure and then back. This is to avoid other
# tests using it unintentionally since CLI is the fallback auth method.
run: |
set -euxo pipefail
echo "${{ secrets.AZURE_CLI_FOLDER }}" | base64 -d > "${{ runner.temp }}/azure-cli-folder.zip"
# Unzip it to a temp folder to avoid other tests using it unintentionally (since CLI auth is the fallback method).
# We only want one specific test to use it.
unzip -d "$HOME/.azure.tmp" "${{ runner.temp }}/azure-cli-folder.zip"
rm "${{ runner.temp }}/azure-cli-folder.zip"
- name: Run tests
if: ${{ ! inputs.short_test }}
env:
# specifying this id will cause the OIDC test(s) to run against this AD application
OIDC_ARM_CLIENT_ID: ${{ inputs.oidc_arm_client_id }}
ARM_CLIENT_CERTIFICATE_PATH_FOR_TEST: "${{ runner.temp }}/azure-client-certificate.pfx"
run: |
set -euo pipefail
cd examples && go test -cover -timeout 2h -tags=${{ matrix.language }} -skip TestPulumiExamples -parallel 16 . 2>&1 | tee /tmp/gotest.log
- name: Run short tests
if: inputs.short_test
run: |
set -euo pipefail
cd examples && go test -cover -timeout 15m -short -tags=${{ matrix.language }} -skip TestPulumiExamples -parallel 16 . 2>&1 | tee /tmp/gotest.log
test_examples:
needs: build_sdks
runs-on: ubuntu-latest
name: Test pulumi/examples
strategy:
fail-fast: false
matrix:
language:
- nodejs
- python
- dotnet
- go
- java
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
submodules: true
- name: Checkout p/examples
uses: actions/checkout@v4
with:
repository: pulumi/examples
ref: master
path: p-examples
- name: Setup
uses: ./.github/actions/test-setup
with:
language: ${{ matrix.language }}
- name: Free up disk space
run: |-
df -h
rm -rf /opt/hostedtoolcache/CodeQL
rm -rf /opt/hostedtoolcache/go/1.19.*
rm -rf /opt/hostedtoolcache/go/1.20.*
sudo apt clean
df -h
- name: Run pulumi/examples tests
if: ${{ !inputs.short_test }}
env:
# specifying this id will cause the OIDC test(s) to run against this AD application
OIDC_ARM_CLIENT_ID: ${{ inputs.oidc_arm_client_id }}
run: |
set -euo pipefail
cd examples && \
go mod edit -replace github.com/pulumi/examples/misc/test=../p-examples/misc/test/ && \
go mod tidy && \
go test -cover -timeout 2h -tags=${{ matrix.language }} -run TestPulumiExamples -parallel 16 . 2>&1 | tee /tmp/gotest.log
test_provider:
runs-on: ubuntu-latest
name: Test Provider
needs: prerequisites
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
submodules: true
- name: Install Languages & Frameworks
uses: ./.github/actions/install
with:
skip_dotnet_and_java: "true"
- run: make ensure
- name: Prerequisites artifact restore
uses: ./.github/actions/prerequisites-artifact-restore
# This is essentially just copying files from bin to the provider folder
- name: Prebuild provider prerequisites
run: |
make prebuild
make --touch codegen schema
make provider_prebuild
- name: Test Provider Library
run: |
set -euo pipefail
cd provider && go test -coverprofile="coverage.txt" -coverpkg=./... -timeout 1h -parallel 16 ./... 2>&1 | tee /tmp/gotest.log
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
if: inputs.upload_codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
dist:
runs-on: ubuntu-latest
name: Provider Dist
needs: prerequisites
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
submodules: true
ref: ${{ inputs.ref }}
- name: Install Languages & Frameworks
uses: ./.github/actions/install
with:
skip_dotnet_and_java: "true"
- run: make ensure
- name: Prerequisites artifact restore
uses: ./.github/actions/prerequisites-artifact-restore
- name: Prerequisites
run: |
make prebuild
# Don't include provider as that's the bit we're going to rebuild
make --touch codegen schema
make provider_prebuild
- name: Build dist packages
run: make dist
env:
AZURE_SIGNING_CLIENT_ID: ${{ secrets.AZURE_SIGNING_CLIENT_ID }}
AZURE_SIGNING_CLIENT_SECRET: ${{ secrets.AZURE_SIGNING_CLIENT_SECRET }}
AZURE_SIGNING_TENANT_ID: ${{ secrets.AZURE_SIGNING_TENANT_ID }}
AZURE_SIGNING_KEY_VAULT_URI: ${{ secrets.AZURE_SIGNING_KEY_VAULT_URI }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
retention-days: ${{ inputs.retention_days }}