diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 343bfb47d..9052927d3 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -8,6 +8,7 @@ on: required: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TOTAL_SHARDS: 10 jobs: test: @@ -21,6 +22,14 @@ jobs: go-version: [1.22.x, 1.23.x] platform: [ubuntu-latest, macos-latest, windows-latest] feature-flags: ["DEFAULT", "PULUMI_TF_BRIDGE_ACCURATE_BRIDGE_PREVIEW"] + shard: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + exclude: + - platform: windows-latest + feature-flags: "PULUMI_TF_BRIDGE_ACCURATE_BRIDGE_PREVIEW" + - platform: macos-latest + feature-flags: "PULUMI_TF_BRIDGE_ACCURATE_BRIDGE_PREVIEW" + - platform: windows-latest + # TODO FIX runs-on: ${{ matrix.platform }} steps: - name: Install pulumi @@ -45,8 +54,15 @@ jobs: run: make build - name: Build PF run: cd pkg/pf && make build + - name: Shard tests + run: go run github.com/VenelinMartinov/shard@7112b4d --total ${{ env.TOTAL_SHARDS }} --index ${{ matrix.shard }} --output env --exclude "(.*vendor.*)|(.\/tools)" >> "$GITHUB_ENV" + - run: echo "$SHARD_TESTS" + - name: Test + run: make VERBOSE=true test_shard + if: ${{ matrix.platform == 'ubuntu-latest' }} - name: Test run: make test + if: ${{ matrix.platform != 'ubuntu-latest' }} - name: Upload coverage reports to Codecov # If we have a CODECOV_TOKEN secret, then we upload it to get a coverage report. # diff --git a/Makefile b/Makefile index d54e5c5ec..00a883544 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,12 @@ test:: install_plugins PULUMI_TERRAFORM_BRIDGE_TEST_PROVIDER=$(shell pwd)/bin/pulumi-terraform-bridge-test-provider \ go test -count=1 -coverprofile="coverage.txt" -coverpkg=./... -timeout 2h -parallel ${TESTPARALLELISM} ./... +test_shard:: install_plugins + @mkdir -p bin + go build -o bin ./internal/testing/pulumi-terraform-bridge-test-provider + PULUMI_TERRAFORM_BRIDGE_TEST_PROVIDER=$(shell pwd)/bin/pulumi-terraform-bridge-test-provider \ + go test -count=1 -coverprofile="coverage.txt" -coverpkg=./... -timeout 2h -parallel ${TESTPARALLELISM} -run "${SHARD_TESTS}$$" ${SHARD_PATHS} + # Run tests while accepting current output as expected output "golden" # tests. In case where system behavior changes intentionally this can # be useful to run to review the differences with git diff. diff --git a/pkg/pf/tests/provider_configure_test.go b/pkg/pf/tests/provider_configure_test.go index a1602b2df..9c5fc871b 100644 --- a/pkg/pf/tests/provider_configure_test.go +++ b/pkg/pf/tests/provider_configure_test.go @@ -534,7 +534,7 @@ func TestConfigureBooleans(t *testing.T) { }`) } -func TestConfigureErrorReplacement(t *testing.T) { +func TestConfigureErrorReplacementPF(t *testing.T) { t.Parallel() t.Run("replace_config_properties", func(t *testing.T) { errString := `some error with "config_property" and "config" but not config` diff --git a/pkg/tfbridge/provider_test.go b/pkg/tfbridge/provider_test.go index 38b903b87..14bae1b1e 100644 --- a/pkg/tfbridge/provider_test.go +++ b/pkg/tfbridge/provider_test.go @@ -1988,7 +1988,7 @@ func TestConfigure(t *testing.T) { }) } -func TestConfigureErrorReplacement(t *testing.T) { +func TestConfigureErrorReplacementSDKv2(t *testing.T) { t.Parallel() t.Run("replace_config_properties", func(t *testing.T) { p := testprovider.ProviderV2()