From ba605ac10de75aca0db4e5a5e0881533599695c1 Mon Sep 17 00:00:00 2001 From: Daniel Bradley Date: Wed, 4 Oct 2023 10:27:38 +0100 Subject: [PATCH] Tidy test execution - 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. --- .github/workflows/build-test.yml | 14 +++++++++++--- Makefile | 3 +-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index fee19915671a..8f9950077566 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -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' }} @@ -207,6 +207,12 @@ jobs: with: skip_dotnet_and_java: "true" + - name: Install gotestfmt + uses: jaxxstorm/action-install-gh-release@v1.9.0 + with: + tag: v2.4.0 + repo: GoTestTools/gotestfmt + - run: make ensure - name: Prerequisites artifact restore @@ -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 diff --git a/Makefile b/Makefile index a212645fd416..e58907e16085 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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)