Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload unit test coverage for bridged providers by default #1224

Merged
merged 5 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 3 additions & 44 deletions provider-ci/internal/pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -394,42 +393,15 @@ 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
}
}
}
}
}
}

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
}
}
}

Comment on lines -404 to -432
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused / leftover.

This is some hairy logic to preserve YAML comments. It would probably be simpler to forgo config.ActionVersions and just let Renovate manage the template files directly, but we can do that later.

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)
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
6 changes: 5 additions & 1 deletion provider-ci/internal/pkg/templates/bridged-provider/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
6 changes: 5 additions & 1 deletion provider-ci/test-providers/acme/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
6 changes: 5 additions & 1 deletion provider-ci/test-providers/aws/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
6 changes: 5 additions & 1 deletion provider-ci/test-providers/cloudflare/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
6 changes: 5 additions & 1 deletion provider-ci/test-providers/docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading