diff --git a/provider-ci/internal/pkg/config.go b/provider-ci/internal/pkg/config.go index fae84025a5..42062dbbc1 100644 --- a/provider-ci/internal/pkg/config.go +++ b/provider-ci/internal/pkg/config.go @@ -317,6 +317,7 @@ type actionVersions struct { UpgradeProviderAction string `yaml:"upgradeProviderAction"` FreeDiskSpace string `yaml:"freeDiskSpace"` ProviderVersionAction string `yaml:"providerVersionAction"` + Codecov string `yaml:"codeCov"` } type toolVersions struct { @@ -345,8 +346,6 @@ type publish struct { func loadDefaultConfig() (Config, error) { var config Config - var wf workflow - // Parse our actions file while preserving comments. var doc yaml.Node err := yaml.Unmarshal(defaultActionVersions, &doc) @@ -394,6 +393,8 @@ func loadDefaultConfig() (Config, error) { config.ActionVersions.FreeDiskSpace = uses case "pulumi/provider-version-action": config.ActionVersions.ProviderVersionAction = uses + case "codecov/codecov-action": + config.ActionVersions.Codecov = uses } } } @@ -401,35 +402,6 @@ func loadDefaultConfig() (Config, error) { } } - for _, j := range wf.Jobs { - for _, s := range j.Steps { - switch s.Name { - case "aws-actions/configure-aws-credentials": - config.ActionVersions.ConfigureAwsCredentials = s.Uses - case "google-github-actions/setup-gcloud": - config.ActionVersions.SetupGcloud = s.Uses - case "google-github-actions/auth": - config.ActionVersions.GoogleAuth = s.Uses - case "actions/checkout": - config.ActionVersions.Checkout = s.Uses - case "actions/download-artifact": - config.ActionVersions.DownloadArtifact = s.Uses - case "dorny/paths-filter": - config.ActionVersions.PathsFilter = s.Uses - case "thollander/actions-comment-pull-request": - config.ActionVersions.PrComment = s.Uses - case "actions/upload-artifact": - config.ActionVersions.UploadArtifact = s.Uses - case "pulumi/pulumi-upgrade-provider-action": - config.ActionVersions.UpgradeProviderAction = s.Uses - case "jlumbroso/free-disk-space": - config.ActionVersions.FreeDiskSpace = s.Uses - case "pulumi/provider-version-action": - config.ActionVersions.ProviderVersionAction = s.Uses - } - } - } - configBytes, err := templateFS.ReadFile(filepath.Join("templates", "defaults.config.yaml")) if err != nil { return Config{}, fmt.Errorf("error reading embedded defaults config file: %w", err) @@ -479,16 +451,3 @@ func (x *intOrDuration) UnmarshalYAML(unmarshal func(interface{}) error) error { *x = intOrDuration(i * int64(time.Minute)) return nil } - -type workflow struct { - Jobs map[string]job -} - -type job struct { - Steps []step -} - -type step struct { - Name string - Uses string -} diff --git a/provider-ci/internal/pkg/templates/bridged-provider/.github/workflows/prerequisites.yml b/provider-ci/internal/pkg/templates/bridged-provider/.github/workflows/prerequisites.yml index d8577cd1dc..e48e903df6 100644 --- a/provider-ci/internal/pkg/templates/bridged-provider/.github/workflows/prerequisites.yml +++ b/provider-ci/internal/pkg/templates/bridged-provider/.github/workflows/prerequisites.yml @@ -72,6 +72,10 @@ jobs: run: make provider - name: Unit-test provider code run: make test_provider + - name: Upload coverage reports to Codecov + uses: #{{ .Config.ActionVersions.Codecov }}# + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - if: inputs.is_pr name: Check Schema is Valid run: | diff --git a/provider-ci/internal/pkg/templates/bridged-provider/Makefile b/provider-ci/internal/pkg/templates/bridged-provider/Makefile index b08d51f7c1..26440f4295 100644 --- a/provider-ci/internal/pkg/templates/bridged-provider/Makefile +++ b/provider-ci/internal/pkg/templates/bridged-provider/Makefile @@ -262,7 +262,11 @@ test: .PHONY: test test_provider: - cd provider && go test -v -short ./... -parallel $(TESTPARALLELISM) + cd provider && go test -v -short \ + -coverprofile="coverage.txt" \ + -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ + -parallel $(TESTPARALLELISM) \ + ./... .PHONY: test_provider tfgen: schema diff --git a/provider-ci/test-providers/acme/.github/workflows/prerequisites.yml b/provider-ci/test-providers/acme/.github/workflows/prerequisites.yml index df175b32a8..5110425715 100644 --- a/provider-ci/test-providers/acme/.github/workflows/prerequisites.yml +++ b/provider-ci/test-providers/acme/.github/workflows/prerequisites.yml @@ -68,6 +68,10 @@ jobs: run: make provider - name: Unit-test provider code run: make test_provider + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@c2fcb216de2b0348de0100baa3ea2cad9f100a01 # v5.1.0 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - if: inputs.is_pr name: Check Schema is Valid run: | diff --git a/provider-ci/test-providers/acme/Makefile b/provider-ci/test-providers/acme/Makefile index f83513c612..539cf5f5e7 100644 --- a/provider-ci/test-providers/acme/Makefile +++ b/provider-ci/test-providers/acme/Makefile @@ -226,7 +226,11 @@ test: .PHONY: test test_provider: - cd provider && go test -v -short ./... -parallel $(TESTPARALLELISM) + cd provider && go test -v -short \ + -coverprofile="coverage.txt" \ + -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ + -parallel $(TESTPARALLELISM) \ + ./... .PHONY: test_provider tfgen: schema diff --git a/provider-ci/test-providers/aws/.github/workflows/prerequisites.yml b/provider-ci/test-providers/aws/.github/workflows/prerequisites.yml index d48da63489..6f612df939 100644 --- a/provider-ci/test-providers/aws/.github/workflows/prerequisites.yml +++ b/provider-ci/test-providers/aws/.github/workflows/prerequisites.yml @@ -79,6 +79,10 @@ jobs: run: make provider - name: Unit-test provider code run: make test_provider + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@c2fcb216de2b0348de0100baa3ea2cad9f100a01 # v5.1.0 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - if: inputs.is_pr name: Check Schema is Valid run: | diff --git a/provider-ci/test-providers/aws/Makefile b/provider-ci/test-providers/aws/Makefile index a7fd985de9..2c2b2fdddb 100644 --- a/provider-ci/test-providers/aws/Makefile +++ b/provider-ci/test-providers/aws/Makefile @@ -236,7 +236,11 @@ test: .PHONY: test test_provider: - cd provider && go test -v -short ./... -parallel $(TESTPARALLELISM) + cd provider && go test -v -short \ + -coverprofile="coverage.txt" \ + -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ + -parallel $(TESTPARALLELISM) \ + ./... .PHONY: test_provider tfgen: schema diff --git a/provider-ci/test-providers/cloudflare/.github/workflows/prerequisites.yml b/provider-ci/test-providers/cloudflare/.github/workflows/prerequisites.yml index 6a64f2bcec..fa82778889 100644 --- a/provider-ci/test-providers/cloudflare/.github/workflows/prerequisites.yml +++ b/provider-ci/test-providers/cloudflare/.github/workflows/prerequisites.yml @@ -72,6 +72,10 @@ jobs: run: make provider - name: Unit-test provider code run: make test_provider + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@c2fcb216de2b0348de0100baa3ea2cad9f100a01 # v5.1.0 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - if: inputs.is_pr name: Check Schema is Valid run: | diff --git a/provider-ci/test-providers/cloudflare/Makefile b/provider-ci/test-providers/cloudflare/Makefile index 6687d57105..4f7832d094 100644 --- a/provider-ci/test-providers/cloudflare/Makefile +++ b/provider-ci/test-providers/cloudflare/Makefile @@ -236,7 +236,11 @@ test: .PHONY: test test_provider: - cd provider && go test -v -short ./... -parallel $(TESTPARALLELISM) + cd provider && go test -v -short \ + -coverprofile="coverage.txt" \ + -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ + -parallel $(TESTPARALLELISM) \ + ./... .PHONY: test_provider tfgen: schema diff --git a/provider-ci/test-providers/docker/.github/workflows/prerequisites.yml b/provider-ci/test-providers/docker/.github/workflows/prerequisites.yml index 7b393f7bf8..7a7885e8f2 100644 --- a/provider-ci/test-providers/docker/.github/workflows/prerequisites.yml +++ b/provider-ci/test-providers/docker/.github/workflows/prerequisites.yml @@ -85,6 +85,10 @@ jobs: run: make provider - name: Unit-test provider code run: make test_provider + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@c2fcb216de2b0348de0100baa3ea2cad9f100a01 # v5.1.0 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - if: inputs.is_pr name: Check Schema is Valid run: | diff --git a/provider-ci/test-providers/docker/Makefile b/provider-ci/test-providers/docker/Makefile index 3d174fbbfe..0f2c19da8e 100644 --- a/provider-ci/test-providers/docker/Makefile +++ b/provider-ci/test-providers/docker/Makefile @@ -239,7 +239,11 @@ test: .PHONY: test test_provider: - cd provider && go test -v -short ./... -parallel $(TESTPARALLELISM) + cd provider && go test -v -short \ + -coverprofile="coverage.txt" \ + -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ + -parallel $(TESTPARALLELISM) \ + ./... .PHONY: test_provider tfgen: schema