-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'GoogleCloudPlatform:main' into alloydb-crr-support
- Loading branch information
Showing
78 changed files
with
5,817 additions
and
1,085 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"magician/github" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
type ttGithub interface { | ||
CreateWorkflowDispatchEvent(string, map[string]any) error | ||
} | ||
|
||
var testTPGCmd = &cobra.Command{ | ||
Use: "test-tpg", | ||
Short: "Run provider unit tests via workflow dispatch", | ||
Long: `This command runs provider unit tests via workflow dispatch | ||
The following PR details are expected as environment variables: | ||
1. VERSION (beta or ga) | ||
2. COMMIT_SHA | ||
3. PR_NUMBER | ||
`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
version := os.Getenv("VERSION") | ||
commit := os.Getenv("COMMIT_SHA") | ||
pr := os.Getenv("PR_NUMBER") | ||
|
||
gh := github.NewGithubService() | ||
|
||
execTestTPG(version, commit, pr, gh) | ||
}, | ||
} | ||
|
||
func execTestTPG(version, commit, pr string, gh ttGithub) { | ||
var repo string | ||
if version == "ga" { | ||
repo = "terraform-provider-google" | ||
} else if version == "beta" { | ||
repo = "terraform-provider-google-beta" | ||
} else { | ||
fmt.Println("invalid version specified") | ||
os.Exit(1) | ||
} | ||
|
||
inputs := map[string]any{ | ||
"owner": "modular-magician", | ||
"repo": repo, | ||
"branch": "auto-pr-" + pr, | ||
"sha": commit, | ||
} | ||
|
||
if err := gh.CreateWorkflowDispatchEvent("test-tpg.yml", inputs); err != nil { | ||
fmt.Printf("Error creating workflow dispatch event: %v\n", err) | ||
} | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(testTPGCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestExecTestTPG(t *testing.T) { | ||
gh := &mockGithub{ | ||
calledMethods: make(map[string]bool), | ||
} | ||
|
||
execTestTPG("beta", "sha1", "pr1", gh) | ||
|
||
if !gh.calledMethods["CreateWorkflowDispatchEvent"] { | ||
t.Fatal("workflow dispatch event not created") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.