Skip to content

Commit

Permalink
Merge branch 'GoogleCloudPlatform:main' into tflint_provider
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 authored Jul 23, 2024
2 parents 89bb69f + 6440099 commit 9f5ca4c
Show file tree
Hide file tree
Showing 3,082 changed files with 344,325 additions and 8,994 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
68 changes: 28 additions & 40 deletions .ci/gcb-push-downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ steps:
id: tpg-sync
waitFor: ["build-magician-binary"]
args:
- wait-for-commit
- 'wait-for-commit'
- 'tpg-sync'
- $BRANCH_NAME
- $COMMIT_SHA
Expand All @@ -46,7 +46,7 @@ steps:
id: tpgb-sync
waitFor: ["build-magician-binary"]
args:
- wait-for-commit
- 'wait-for-commit'
- 'tpgb-sync'
- $BRANCH_NAME
- $COMMIT_SHA
Expand All @@ -57,7 +57,7 @@ steps:
id: tgc-sync
waitFor: ["build-magician-binary"]
args:
- wait-for-commit
- 'wait-for-commit'
- 'tgc-sync'
- $BRANCH_NAME
- $COMMIT_SHA
Expand All @@ -68,7 +68,7 @@ steps:
id: tf-oics-sync
waitFor: ["build-magician-binary"]
args:
- wait-for-commit
- 'wait-for-commit'
- 'tf-oics-sync'
- $BRANCH_NAME
- $COMMIT_SHA
Expand All @@ -88,18 +88,15 @@ steps:
- 'ga'
- $COMMIT_SHA

- name: 'gcr.io/cloud-builders/git'
- name: 'gcr.io/graphite-docker-images/go-plus'
waitFor: ["tpg-push"]
secretEnv: ["GITHUB_TOKEN_CLASSIC"]
entrypoint: 'bash'
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
args:
- -c
- |
if [ "$BRANCH_NAME" == "main" ]; then
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tpg-sync
else
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tpg-sync-$BRANCH_NAME
fi
- 'sync-branch'
- 'tpg-sync'
- $BRANCH_NAME
- $COMMIT_SHA

# TPGB
- name: 'gcr.io/graphite-docker-images/build-environment'
Expand All @@ -116,18 +113,15 @@ steps:
- 'beta'
- $COMMIT_SHA

- name: 'gcr.io/cloud-builders/git'
- name: 'gcr.io/graphite-docker-images/go-plus'
waitFor: ["tpgb-push"]
secretEnv: ["GITHUB_TOKEN_CLASSIC"]
entrypoint: 'bash'
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
args:
- -c
- |
if [ "$BRANCH_NAME" == "main" ]; then
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tpgb-sync
else
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tpgb-sync-$BRANCH_NAME
fi
- 'sync-branch'
- 'tpgb-sync'
- $BRANCH_NAME
- $COMMIT_SHA

# TGC
- name: 'gcr.io/graphite-docker-images/build-environment'
Expand All @@ -144,18 +138,15 @@ steps:
- 'beta'
- $COMMIT_SHA

- name: 'gcr.io/cloud-builders/git'
- name: 'gcr.io/graphite-docker-images/go-plus'
waitFor: ["tgc-push"]
secretEnv: ["GITHUB_TOKEN_CLASSIC"]
entrypoint: 'bash'
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
args:
- -c
- |
if [ "$BRANCH_NAME" == "main" ]; then
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tgc-sync
else
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tgc-sync-$BRANCH_NAME
fi
- 'sync-branch'
- 'tgc-sync'
- $BRANCH_NAME
- $COMMIT_SHA

# TF-OICS
- name: 'gcr.io/graphite-docker-images/build-environment'
Expand All @@ -172,18 +163,15 @@ steps:
- 'beta'
- $COMMIT_SHA

- name: 'gcr.io/cloud-builders/git'
- name: 'gcr.io/graphite-docker-images/go-plus'
waitFor: ["tf-oics-push"]
secretEnv: ["GITHUB_TOKEN_CLASSIC"]
entrypoint: 'bash'
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
args:
- -c
- |
if [ "$BRANCH_NAME" == "main" ]; then
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tf-oics-sync
else
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tf-oics-sync-$BRANCH_NAME
fi
- 'sync-branch'
- 'tf-oics-sync'
- $BRANCH_NAME
- $COMMIT_SHA

- name: 'gcr.io/graphite-docker-images/go-plus'
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
Expand Down
17 changes: 16 additions & 1 deletion .ci/magician/cmd/DIFF_COMMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,22 @@ If you believe this detection to be incorrect please raise the concern with your
If you intend to make this change you will need to wait for a [major release](https://www.terraform.io/plugin/sdkv2/best-practices/versioning#example-major-number-increments) window.
An `override-breaking-change` label can be added to allow merging.
{{end}}
{{.MissingTests}}

{{if gt (len .MissingTests) 0}}
## Missing test report
Your PR includes resource fields which are not covered by any test.
{{ range $resourceName, $missingTestInfo := .MissingTests }}
Resource: `{{ $resourceName }}` ({{ len $missingTestInfo.Tests }} total tests)
Please add an acceptance test which includes these fields. The test should include the following:

```hcl
{{ $missingTestInfo.SuggestedTest }}
```

{{- end }}
{{end}}

{{- $errorsLength := len .Errors}}
{{- if gt $errorsLength 0}}
## Errors
Expand Down
4 changes: 2 additions & 2 deletions .ci/magician/cmd/SCHEDULED_PR_WAITING_FOR_CONTRIBUTOR.md.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ if lt .SinceDays 30 -}}
@{{.PullRequest.User.Login}}, this PR is waiting for action from you. Please address any comments or change requests, or [re-request review](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/requesting-a-pull-request-review) from a core reviewer if no action is required.
@{{.User}}, this PR is waiting for action from you. Please address any comments or change requests, or [re-request review](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/requesting-a-pull-request-review) from a core reviewer if no action is required.

![Image showing the re-request review button](https://docs.github.com/assets/cb-28785/mw-1440/images/help/pull_requests/request-re-review.webp)

Expand All @@ -10,5 +10,5 @@ If no action is taken, this PR will be closed in

This notification can be disabled with the `disable-automatic-closure` label.
{{ else -}}
@{{.PullRequest.User.Login}}, this PR is being closed due to inactivity.
@{{.User}}, this PR is being closed due to inactivity.
{{ end -}}
2 changes: 1 addition & 1 deletion .ci/magician/cmd/SCHEDULED_PR_WAITING_FOR_MERGE.md.tmpl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
This PR is approved and has been waiting for merge for {{if eq .SinceDays 5}}1 week{{else}}{{weekdaysToWeeks .SinceDays}} weeks{{end}}. Is it ready to merge? Use the label `disable-review-reminders` to disable these notifications.
{{range .CoreReviewers}}@{{ . }} {{end}}This PR is approved and has been waiting for merge for {{if eq .SinceDays 5}}1 week{{else}}{{weekdaysToWeeks .SinceDays}} weeks{{end}}. Is it ready to merge? Use the label `disable-review-reminders` to disable these notifications.
2 changes: 1 addition & 1 deletion .ci/magician/cmd/SCHEDULED_PR_WAITING_FOR_REVIEW.md.tmpl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{if ge .SinceDays 5}}@GoogleCloudPlatform/terraform-team {{end}}This PR has been waiting for review for {{if lt .SinceDays 5}}{{.SinceDays}} weekdays{{else if eq .SinceDays 5}}1 week{{else}}{{weekdaysToWeeks .SinceDays}} weeks{{end}}. Please take a look! Use the label `disable-review-reminders` to disable these notifications.
{{if ge .SinceDays 5}}@GoogleCloudPlatform/terraform-team {{end}}{{range .CoreReviewers}}@{{ . }} {{end}}This PR has been waiting for review for {{if lt .SinceDays 5}}{{.SinceDays}} weekdays{{else if eq .SinceDays 5}}1 week{{else}}{{weekdaysToWeeks .SinceDays}} weeks{{end}}. Please take a look! Use the label `disable-review-reminders` to disable these notifications.
31 changes: 12 additions & 19 deletions .ci/magician/cmd/check_cassettes.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,33 @@ var checkCassettesCmd = &cobra.Command{
` + listCCEnvironmentVariables() + `
It prints a list of tests that failed in replaying mode along with all test output.`,
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
env := make(map[string]string, len(ccEnvironmentVariables))
for _, ev := range ccEnvironmentVariables {
val, ok := os.LookupEnv(ev)
if !ok {
fmt.Printf("Did not provide %s environment variable\n", ev)
os.Exit(1)
return fmt.Errorf("did not provide %s environment variable", ev)
}
env[ev] = val
}

githubToken, ok := lookupGithubTokenOrFallback("GITHUB_TOKEN_DOWNSTREAMS")
if !ok {
fmt.Println("Did not provide GITHUB_TOKEN_DOWNSTREAMS or GITHUB_TOKEN environment variables")
os.Exit(1)
return fmt.Errorf("did not provide GITHUB_TOKEN_DOWNSTREAMS or GITHUB_TOKEN environment variables")
}

rnr, err := exec.NewRunner()
if err != nil {
fmt.Println("Error creating Runner: ", err)
os.Exit(1)
return fmt.Errorf("error creating Runner: %w", err)
}

ctlr := source.NewController(env["GOPATH"], "modular-magician", githubToken, rnr)

vt, err := vcr.NewTester(env, rnr)
if err != nil {
fmt.Println("Error creating VCR tester: ", err)
os.Exit(1)
return fmt.Errorf("error creating VCR tester: %w", err)
}
execCheckCassettes(env["COMMIT_SHA"], vt, ctlr)
return execCheckCassettes(env["COMMIT_SHA"], vt, ctlr)
},
}

Expand All @@ -93,10 +89,9 @@ func listCCEnvironmentVariables() string {
return result
}

func execCheckCassettes(commit string, vt *vcr.Tester, ctlr *source.Controller) {
func execCheckCassettes(commit string, vt *vcr.Tester, ctlr *source.Controller) error {
if err := vt.FetchCassettes(provider.Beta, "main", ""); err != nil {
fmt.Println("Error fetching cassettes: ", err)
os.Exit(1)
return fmt.Errorf("error fetching cassettes: %w", err)
}

providerRepo := &source.Repo{
Expand All @@ -105,8 +100,7 @@ func execCheckCassettes(commit string, vt *vcr.Tester, ctlr *source.Controller)
}
ctlr.SetPath(providerRepo)
if err := ctlr.Clone(providerRepo); err != nil {
fmt.Println("Error cloning provider: ", err)
os.Exit(1)
return fmt.Errorf("error cloning provider: %w", err)
}
vt.SetRepoPath(provider.Beta, providerRepo.Path)

Expand All @@ -115,18 +109,17 @@ func execCheckCassettes(commit string, vt *vcr.Tester, ctlr *source.Controller)
fmt.Println("Error running VCR: ", err)
}
if err := vt.UploadLogs("vcr-check-cassettes", "", "", false, false, vcr.Replaying, provider.Beta); err != nil {
fmt.Println("Error uploading logs: ", err)
os.Exit(1)
return fmt.Errorf("error uploading logs: %w", err)
}
fmt.Println(len(result.FailedTests), " failed tests: ", result.FailedTests)
// TODO(trodge) report these failures to bigquery
fmt.Println(len(result.PassedTests), " passed tests: ", result.PassedTests)
fmt.Println(len(result.SkippedTests), " skipped tests: ", result.SkippedTests)

if err := vt.Cleanup(); err != nil {
fmt.Println("Error cleaning up vcr tester: ", err)
os.Exit(1)
return fmt.Errorf("error cleaning up vcr tester: %w", err)
}
return nil
}

func init() {
Expand Down
14 changes: 6 additions & 8 deletions .ci/magician/cmd/community_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"
"magician/cloudbuild"
"magician/github"
"os"

"github.com/spf13/cobra"
)
Expand All @@ -42,7 +41,7 @@ var communityApprovalCmd = &cobra.Command{
1. Trigger cloud presubmits with specific substitutions for the PR.
2. Remove the 'awaiting-approval' label from the PR.
`,
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
prNumber := args[0]
fmt.Println("PR Number: ", prNumber)

Expand All @@ -63,16 +62,15 @@ var communityApprovalCmd = &cobra.Command{

githubToken, ok := lookupGithubTokenOrFallback("GITHUB_TOKEN_MAGIC_MODULES")
if !ok {
fmt.Println("Did not provide GITHUB_TOKEN_MAGIC_MODULES or GITHUB_TOKEN environment variables")
os.Exit(1)
return fmt.Errorf("did not provide GITHUB_TOKEN_MAGIC_MODULES or GITHUB_TOKEN environment variables")
}
gh := github.NewClient(githubToken)
cb := cloudbuild.NewClient()
execCommunityChecker(prNumber, commitSha, branchName, headRepoUrl, headBranch, baseBranch, gh, cb)
return execCommunityChecker(prNumber, commitSha, branchName, headRepoUrl, headBranch, baseBranch, gh, cb)
},
}

func execCommunityChecker(prNumber, commitSha, branchName, headRepoUrl, headBranch, baseBranch string, gh GithubClient, cb CloudbuildClient) {
func execCommunityChecker(prNumber, commitSha, branchName, headRepoUrl, headBranch, baseBranch string, gh GithubClient, cb CloudbuildClient) error {
substitutions := map[string]string{
"BRANCH_NAME": branchName,
"_PR_NUMBER": prNumber,
Expand All @@ -85,13 +83,13 @@ func execCommunityChecker(prNumber, commitSha, branchName, headRepoUrl, headBran
// (explicitly or via membership-checker)
err := cb.TriggerMMPresubmitRuns(commitSha, substitutions)
if err != nil {
fmt.Println(err)
os.Exit(1)
return err
}

// in community-checker job:
// remove awaiting-approval label from external contributor PRs
gh.RemoveLabel(prNumber, "awaiting-approval")
return nil
}

func init() {
Expand Down
Loading

0 comments on commit 9f5ca4c

Please sign in to comment.