Skip to content

Commit 2665e75

Browse files
authored
Allow running the acceptance tests in pulumi/examples as part of the test suite (#823)
This change adds a new optional flag `testPulumiExamples` that can be set in .ci-mgmt.yaml. When set, the acceptance tests in pulumi/examples will be run as part of the test suite. The goal is to increase test coverage in provider PRs or releases. `pulumi/examples` has a rich set of realistic programs that can be used for this via ProgramTest. Providers don't necessarily need to gate PRs on these tests, they can be informational only. This requires that the provider's test suite in `examples/` is enabled for this. See pulumi/pulumi-azure#1717 for an example. It's not enough to just run the test suite in pulumi/examples because we want to use or inject the locally built provider and SDKs of the current PR. I chose the approach using the test job's matrix because the new pulumi/examples tests should run concurrently to the regular ones, but to run them in a separate job would require copying the lengthy setup steps of the test job, or extracting the setup into a composite action which I thought could be avoided.
1 parent e74fbee commit 2665e75

File tree

5 files changed

+66
-8
lines changed

5 files changed

+66
-8
lines changed

provider-ci/internal/pkg/templates/bridged-provider.config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ extraTests:
6161
# your_test_name:
6262
# name: My Test
6363
# ...
64+
# Run e2e tests using the examples and test suite in the pulumi/examples repo.
65+
testPulumiExamples: false
6466
runner:
6567
default: ubuntu-latest
6668
prerequisites: ubuntu-latest

provider-ci/internal/pkg/templates/bridged-provider/.github/workflows/run-acceptance-tests.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ jobs:
186186
run: exit 1
187187
- name: Workflow is a success
188188
run: echo "🎉🎈🎉🎈🎉"
189+
189190
test:
190191
if: github.event_name == 'repository_dispatch' ||
191192
github.event.pull_request.head.repo.full_name == github.repository
@@ -209,6 +210,12 @@ jobs:
209210
path: ci-scripts
210211
repository: pulumi/scripts
211212
ref: #{{ .Config.pulumiScriptsRef }}#
213+
- name: Checkout p/examples
214+
if: matrix.testTarget == 'pulumiExamples'
215+
uses: #{{ .Config.actionVersions.checkout }}#
216+
with:
217+
repository: pulumi/examples
218+
path: p-examples
212219
- name: Unshallow clone for tags
213220
run: git fetch --prune --unshallow --tags
214221
#{{ .Config.actions.setupGo | toYaml | indent 4 }}#
@@ -315,15 +322,20 @@ jobs:
315322
#{{ .Config.actions.preTest | toYaml | indent 4 }}#
316323
#{{- end }}#
317324
- name: Run tests
325+
if: matrix.testTarget == 'local'
318326
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{
319-
matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
320-
- if: failure() && github.event_name == 'push'
327+
matrix.language }} -skip TestPulumiExamples -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
328+
- if: failure() && github.event_name == 'push' && matrix.testTarget == 'local'
321329
name: Notify Slack
322330
uses: #{{ .Config.actionVersions.notifySlack }}#
323331
with:
324332
author_name: Failure in running ${{ matrix.language }} tests
325333
fields: repo,commit,author,action
326334
status: ${{ job.status }}
335+
- name: Run pulumi/examples tests
336+
if: matrix.testTarget == 'pulumiExamples'
337+
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{
338+
matrix.language }} -run TestPulumiExamples -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
327339
strategy:
328340
fail-fast: false
329341
matrix:
@@ -333,6 +345,11 @@ jobs:
333345
- dotnet
334346
- go
335347
- java
348+
#{{- if .Config.testPulumiExamples }}#
349+
testTarget: [local, pulumiExamples]
350+
#{{- else }}#
351+
testTarget: [local]
352+
#{{- end }}#
336353
license_check:
337354
name: License Check
338355
uses: ./.github/workflows/license.yml

provider-ci/test-workflows/aws/.github/workflows/run-acceptance-tests.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ jobs:
289289
run: exit 1
290290
- name: Workflow is a success
291291
run: echo "🎉🎈🎉🎈🎉"
292+
292293
test:
293294
if: github.event_name == 'repository_dispatch' ||
294295
github.event.pull_request.head.repo.full_name == github.repository
@@ -310,6 +311,12 @@ jobs:
310311
path: ci-scripts
311312
repository: pulumi/scripts
312313
ref: deca2c5c6015ad7aaea6f572a1c2b198ca323592
314+
- name: Checkout p/examples
315+
if: matrix.testTarget == 'pulumiExamples'
316+
uses: actions/checkout@v4
317+
with:
318+
repository: pulumi/examples
319+
path: p-examples
313320
- name: Unshallow clone for tags
314321
run: git fetch --prune --unshallow --tags
315322
- name: Install Go
@@ -395,15 +402,20 @@ jobs:
395402
- name: Make upstream
396403
run: make upstream
397404
- name: Run tests
405+
if: matrix.testTarget == 'local'
398406
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{
399-
matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
400-
- if: failure() && github.event_name == 'push'
407+
matrix.language }} -skip TestPulumiExamples -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
408+
- if: failure() && github.event_name == 'push' && matrix.testTarget == 'local'
401409
name: Notify Slack
402410
uses: 8398a7/action-slack@v3
403411
with:
404412
author_name: Failure in running ${{ matrix.language }} tests
405413
fields: repo,commit,author,action
406414
status: ${{ job.status }}
415+
- name: Run pulumi/examples tests
416+
if: matrix.testTarget == 'pulumiExamples'
417+
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{
418+
matrix.language }} -run TestPulumiExamples -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
407419
strategy:
408420
fail-fast: false
409421
matrix:
@@ -413,6 +425,7 @@ jobs:
413425
- dotnet
414426
- go
415427
- java
428+
testTarget: [local]
416429
license_check:
417430
name: License Check
418431
uses: ./.github/workflows/license.yml

provider-ci/test-workflows/cloudflare/.github/workflows/run-acceptance-tests.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ jobs:
283283
run: exit 1
284284
- name: Workflow is a success
285285
run: echo "🎉🎈🎉🎈🎉"
286+
286287
test:
287288
if: github.event_name == 'repository_dispatch' ||
288289
github.event.pull_request.head.repo.full_name == github.repository
@@ -303,6 +304,12 @@ jobs:
303304
path: ci-scripts
304305
repository: pulumi/scripts
305306
ref: deca2c5c6015ad7aaea6f572a1c2b198ca323592
307+
- name: Checkout p/examples
308+
if: matrix.testTarget == 'pulumiExamples'
309+
uses: actions/checkout@v4
310+
with:
311+
repository: pulumi/examples
312+
path: p-examples
306313
- name: Unshallow clone for tags
307314
run: git fetch --prune --unshallow --tags
308315
- name: Install Go
@@ -377,15 +384,20 @@ jobs:
377384
token: ${{ secrets.GITHUB_TOKEN }}
378385
version: v2.5.0
379386
- name: Run tests
387+
if: matrix.testTarget == 'local'
380388
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{
381-
matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
382-
- if: failure() && github.event_name == 'push'
389+
matrix.language }} -skip TestPulumiExamples -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
390+
- if: failure() && github.event_name == 'push' && matrix.testTarget == 'local'
383391
name: Notify Slack
384392
uses: 8398a7/action-slack@v3
385393
with:
386394
author_name: Failure in running ${{ matrix.language }} tests
387395
fields: repo,commit,author,action
388396
status: ${{ job.status }}
397+
- name: Run pulumi/examples tests
398+
if: matrix.testTarget == 'pulumiExamples'
399+
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{
400+
matrix.language }} -run TestPulumiExamples -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
389401
strategy:
390402
fail-fast: false
391403
matrix:
@@ -395,6 +407,7 @@ jobs:
395407
- dotnet
396408
- go
397409
- java
410+
testTarget: [local]
398411
license_check:
399412
name: License Check
400413
uses: ./.github/workflows/license.yml

provider-ci/test-workflows/docker/.github/workflows/run-acceptance-tests.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ jobs:
296296
run: exit 1
297297
- name: Workflow is a success
298298
run: echo "🎉🎈🎉🎈🎉"
299+
299300
test:
300301
if: github.event_name == 'repository_dispatch' ||
301302
github.event.pull_request.head.repo.full_name == github.repository
@@ -316,6 +317,12 @@ jobs:
316317
path: ci-scripts
317318
repository: pulumi/scripts
318319
ref: deca2c5c6015ad7aaea6f572a1c2b198ca323592
320+
- name: Checkout p/examples
321+
if: matrix.testTarget == 'pulumiExamples'
322+
uses: actions/checkout@v4
323+
with:
324+
repository: pulumi/examples
325+
path: p-examples
319326
- name: Unshallow clone for tags
320327
run: git fetch --prune --unshallow --tags
321328
- name: Install Go
@@ -419,15 +426,20 @@ jobs:
419426
- name: Expose GitHub Actions runtime
420427
uses: crazy-max/ghaction-github-runtime@v3
421428
- name: Run tests
429+
if: matrix.testTarget == 'local'
422430
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{
423-
matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
424-
- if: failure() && github.event_name == 'push'
431+
matrix.language }} -skip TestPulumiExamples -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
432+
- if: failure() && github.event_name == 'push' && matrix.testTarget == 'local'
425433
name: Notify Slack
426434
uses: 8398a7/action-slack@v3
427435
with:
428436
author_name: Failure in running ${{ matrix.language }} tests
429437
fields: repo,commit,author,action
430438
status: ${{ job.status }}
439+
- name: Run pulumi/examples tests
440+
if: matrix.testTarget == 'pulumiExamples'
441+
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{
442+
matrix.language }} -run TestPulumiExamples -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
431443
strategy:
432444
fail-fast: false
433445
matrix:
@@ -437,6 +449,7 @@ jobs:
437449
- dotnet
438450
- go
439451
- java
452+
testTarget: [local]
440453
license_check:
441454
name: License Check
442455
uses: ./.github/workflows/license.yml

0 commit comments

Comments
 (0)