Skip to content

Commit

Permalink
Tidy test execution
Browse files Browse the repository at this point in the history
- Make: Skip expanding then passing the list of go packages. `./...` does this for us.
- Use gotestfmt in CI/CD for better output. Still set same coverage flags as in make.
- Increase explicit `-parallel` from program test in CI to 16. Tests are not bound on local resources but rather on waiting for external services.
  • Loading branch information
danielrbradley committed Oct 4, 2023
1 parent 20b23aa commit ba605ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ jobs:
OIDC_ARM_CLIENT_ID: ${{ inputs.oidc_arm_client_id }}
run: |
set -euo pipefail
cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
cd examples && go test -v -json -cover -timeout 2h -tags=${{ matrix.language }} -parallel 16 . 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Run short tests
if: inputs.short_test
run: |
set -euo pipefail
cd examples && go test -v -json -count=1 -cover -timeout 15m -short -tags=${{ matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
cd examples && go test -v -json -cover -timeout 15m -short -tags=${{ matrix.language }} -parallel 16 . 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Tar SDK folder
if: ${{ matrix.language != 'go' }}
Expand Down Expand Up @@ -207,6 +207,12 @@ jobs:
with:
skip_dotnet_and_java: "true"

- name: Install gotestfmt
uses: jaxxstorm/[email protected]
with:
tag: v2.4.0
repo: GoTestTools/gotestfmt

- run: make ensure

- name: Prerequisites artifact restore
Expand All @@ -216,7 +222,9 @@ jobs:
run: make --touch codegen schema provider

- name: Test Provider Library
run: PROVIDER_TEST_TAGS=all make test_provider
run: |
set -euo pipefail
cd provider && go test -v -json -coverprofile="coverage.txt" -coverpkg=./... -timeout 1h -parallel 16 ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ PROJECT := github.com/pulumi/pulumi-azure-native
PROVIDER := pulumi-resource-azure-native
CODEGEN := pulumi-gen-azure-native

PROVIDER_PKGS := $(shell cd ./provider && go list ./pkg/...)
WORKING_DIR := $(shell pwd)

# azure-quickstart-templates is generated by arm2pulumi_coverage_report
Expand Down Expand Up @@ -126,7 +125,7 @@ arm2pulumi_coverage_report: .make/provider_mod_download provider/cmd/$(PROVIDER)
PROVIDER_TEST_TAGS ?= unit # Default to unit tests only for quick local feedback
.PHONY: test_provider
test_provider: .make/provider_mod_download .make/provider_prebuild provider/cmd/$(PROVIDER)/*.go $(PROVIDER_PKG)
cd provider && go test -v --tags=$(PROVIDER_TEST_TAGS) -coverprofile="coverage.txt" -coverpkg=./... $(PROVIDER_PKGS)
cd provider && go test -v --tags=$(PROVIDER_TEST_TAGS) -coverprofile="coverage.txt" -coverpkg=./... ./...

.PHONY: lint_provider
lint_provider: .make/provider_mod_download provider/cmd/$(PROVIDER)/*.go $(PROVIDER_PKG)
Expand Down

0 comments on commit ba605ac

Please sign in to comment.