-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
add github submodule support for codebuild project #13285
add github submodule support for codebuild project #13285
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @raobystorm 👋 Thank you for submitting this! It is looking good so far. Would you mind adding covering testing for this as well? Then this can be verified by running the acceptance testing with the TestAccAWSCodeBuildProject_
pattern. In particular:
- Renaming
TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig
toTestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_CodeCommit
- Adding two tests under it:
func TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_GitHub(t *testing.T) {
var project codebuild.Project
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_codebuild_project.test"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSCodeBuild(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCodeBuildProjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSCodeBuildProjectConfig_Source_GitSubmodulesConfig_GitHub(rName, true),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCodeBuildProjectExists(resourceName, &project),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAWSCodeBuildProjectConfig_Source_GitSubmodulesConfig_GitHub(rName, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCodeBuildProjectExists(resourceName, &project),
),
},
},
})
}
func TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_GitHubEnterprise(t *testing.T) {
var project codebuild.Project
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_codebuild_project.test"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSCodeBuild(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCodeBuildProjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSCodeBuildProjectConfig_Source_GitSubmodulesConfig_GitHubEnterprise(rName, true),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCodeBuildProjectExists(resourceName, &project),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAWSCodeBuildProjectConfig_Source_GitSubmodulesConfig_GitHubEnterprise(rName, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCodeBuildProjectExists(resourceName, &project),
),
},
},
})
}
- Renaming
TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig
toTestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_CodeCommit
- Adding two tests under it:
func TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_GitHub(t *testing.T) {
var project codebuild.Project
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_codebuild_project.test"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSCodeBuild(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCodeBuildProjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSCodeBuildProjectConfig_SecondarySources_GitSubmodulesConfig_GitHub(rName, true),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCodeBuildProjectExists(resourceName, &project),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAWSCodeBuildProjectConfig_SecondarySources_GitSubmodulesConfig_GitHub(rName, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCodeBuildProjectExists(resourceName, &project),
),
},
},
})
}
func TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_GitHubEnterprise(t *testing.T) {
var project codebuild.Project
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_codebuild_project.test"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSCodeBuild(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCodeBuildProjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSCodeBuildProjectConfig_SecondarySources_GitSubmodulesConfig_GitHubEnterprise(rName, true),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCodeBuildProjectExists(resourceName, &project),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAWSCodeBuildProjectConfig_SecondarySources_GitSubmodulesConfig_GitHubEnterprise(rName, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCodeBuildProjectExists(resourceName, &project),
),
},
},
})
}
- Renaming
testAccAWSCodeBuildProjectConfig_Source_GitSubmodulesConfig
totestAccAWSCodeBuildProjectConfig_Source_GitSubmodulesConfig_CodeCommit
- Adding two test configurations under it:
func testAccAWSCodeBuildProjectConfig_Source_GitSubmodulesConfig_GitHub(rName string, fetchSubmodules bool) string {
return testAccAWSCodeBuildProjectConfig_Base_ServiceRole(rName) + fmt.Sprintf(`
resource "aws_codebuild_project" "test" {
name = "%s"
service_role = "${aws_iam_role.test.arn}"
artifacts {
type = "NO_ARTIFACTS"
}
environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "2"
type = "LINUX_CONTAINER"
}
source {
location = "https://github.com/hashicorp/packer.git"
type = "GITHUB"
git_submodules_config {
fetch_submodules = %t
}
}
}
`, rName, fetchSubmodules)
}
func testAccAWSCodeBuildProjectConfig_Source_GitSubmodulesConfig_GitHubEnterprise(rName string, fetchSubmodules bool) string {
return testAccAWSCodeBuildProjectConfig_Base_ServiceRole(rName) + fmt.Sprintf(`
resource "aws_codebuild_project" "test" {
name = "%s"
service_role = "${aws_iam_role.test.arn}"
artifacts {
type = "NO_ARTIFACTS"
}
environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "2"
type = "LINUX_CONTAINER"
}
source {
location = "https://example.com/organization/repository.git"
type = "GITHUB_ENTERPRISE"
git_submodules_config {
fetch_submodules = %t
}
}
}
`, rName, fetchSubmodules)
}
- Renaming
testAccAWSCodeBuildProjectConfig_SecondarySources_GitSubmodulesConfig
totestAccAWSCodeBuildProjectConfig_SecondarySources_GitSubmodulesConfig_CodeCommit
- Adding two test configurations under it:
func testAccAWSCodeBuildProjectConfig_SecondarySources_GitSubmodulesConfig_GitHub(rName string, fetchSubmodules bool) string {
return testAccAWSCodeBuildProjectConfig_Base_ServiceRole(rName) + fmt.Sprintf(`
resource "aws_codebuild_project" "test" {
name = "%[1]s"
service_role = "${aws_iam_role.test.arn}"
artifacts {
type = "NO_ARTIFACTS"
}
environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "2"
type = "LINUX_CONTAINER"
}
source {
location = "https://github.com/hashicorp/packer.git"
type = "GITHUB"
git_submodules_config {
fetch_submodules = %[2]t
}
}
secondary_sources {
location = "https://github.com/hashicorp/terraform.git"
type = "GITHUB"
source_identifier = "secondarySource1"
git_submodules_config {
fetch_submodules = %[2]t
}
}
secondary_sources {
location = "https://github.com/hashicorp/vault.git"
type = "GITHUB"
source_identifier = "secondarySource2"
git_submodules_config {
fetch_submodules = %[2]t
}
}
}
`, rName, fetchSubmodules)
}
func testAccAWSCodeBuildProjectConfig_SecondarySources_GitSubmodulesConfig_GitHubEnterprise(rName string, fetchSubmodules bool) string {
return testAccAWSCodeBuildProjectConfig_Base_ServiceRole(rName) + fmt.Sprintf(`
resource "aws_codebuild_project" "test" {
name = "%[1]s"
service_role = "${aws_iam_role.test.arn}"
artifacts {
type = "NO_ARTIFACTS"
}
environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "2"
type = "LINUX_CONTAINER"
}
source {
location = "https://example.com/organization/repository-1.git"
type = "GITHUB_ENTERPRISE"
git_submodules_config {
fetch_submodules = %[2]t
}
}
secondary_sources {
location = "https://example.com/organization/repository-2.git"
type = "GITHUB_ENTERPRISE"
source_identifier = "secondarySource1"
git_submodules_config {
fetch_submodules = %[2]t
}
}
secondary_sources {
location = "https://example.com/organization/repository-3.git"
type = "GITHUB_ENTERPRISE"
source_identifier = "secondarySource2"
git_submodules_config {
fetch_submodules = %[2]t
}
}
}
`, rName, fetchSubmodules)
}
Thanks so much!
Hi @bflad ! Thank you for kindly remind me to add covering test. I Added those tests and configurations for github / github enterprise submodule. Please have a look! Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @raobystorm! 🚀
Output from acceptance testing:
--- PASS: TestAccAWSCodeBuildProject_ARMContainer (38.85s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_ArtifactIdentifier (123.86s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_EncryptionDisabled (73.22s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Location (66.05s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Name (53.15s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_NamespaceType (104.99s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_OverrideArtifactName (63.90s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Packaging (47.87s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Path (76.47s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Type (52.04s)
--- PASS: TestAccAWSCodeBuildProject_BadgeEnabled (64.22s)
--- PASS: TestAccAWSCodeBuildProject_basic (66.51s)
--- PASS: TestAccAWSCodeBuildProject_BuildTimeout (142.70s)
--- PASS: TestAccAWSCodeBuildProject_Cache (492.80s)
--- PASS: TestAccAWSCodeBuildProject_Description (118.05s)
--- PASS: TestAccAWSCodeBuildProject_EncryptionKey (24.36s)
--- PASS: TestAccAWSCodeBuildProject_Environment_Certificate (35.56s)
--- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable (137.21s)
--- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable_Type (125.69s)
--- PASS: TestAccAWSCodeBuildProject_Environment_RegistryCredential (42.96s)
--- PASS: TestAccAWSCodeBuildProject_LogsConfig_CloudWatchLogs (114.15s)
--- PASS: TestAccAWSCodeBuildProject_LogsConfig_S3Logs (127.95s)
--- PASS: TestAccAWSCodeBuildProject_QueuedTimeout (59.77s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts (59.42s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_ArtifactIdentifier (121.77s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_EncryptionDisabled (59.14s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Location (152.24s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_NamespaceType (43.80s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_OverrideArtifactName (57.07s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Packaging (52.05s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Path (47.08s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Type (28.57s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_CodeCommit (42.53s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_CodeCommit (43.31s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_GitHub (49.07s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_GitHubEnterprise (213.67s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitCloneDepth (51.10s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_CodeCommit (75.27s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_GitHub (132.44s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_GitHubEnterprise (38.49s)
--- PASS: TestAccAWSCodeBuildProject_Source_InsecureSSL (110.79s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_Bitbucket (112.36s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHub (263.79s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHubEnterprise (89.94s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_Bitbucket (63.16s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_CodeCommit (75.09s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_CodePipeline (134.04s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_GitHubEnterprise (68.32s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_NoSource (143.63s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_NoSourceInvalid (12.03s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_S3 (82.56s)
--- PASS: TestAccAWSCodeBuildProject_SourceVersion (55.28s)
--- PASS: TestAccAWSCodeBuildProject_Tags (59.02s)
--- PASS: TestAccAWSCodeBuildProject_WindowsContainer (31.46s)
This has been released in version 2.62.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
…`GITHUB` and `GITHUB_ENTERPRISE` source types (hashicorp#13285) Output from acceptance testing: ``` --- PASS: TestAccAWSCodeBuildProject_ARMContainer (38.85s) --- PASS: TestAccAWSCodeBuildProject_Artifacts_ArtifactIdentifier (123.86s) --- PASS: TestAccAWSCodeBuildProject_Artifacts_EncryptionDisabled (73.22s) --- PASS: TestAccAWSCodeBuildProject_Artifacts_Location (66.05s) --- PASS: TestAccAWSCodeBuildProject_Artifacts_Name (53.15s) --- PASS: TestAccAWSCodeBuildProject_Artifacts_NamespaceType (104.99s) --- PASS: TestAccAWSCodeBuildProject_Artifacts_OverrideArtifactName (63.90s) --- PASS: TestAccAWSCodeBuildProject_Artifacts_Packaging (47.87s) --- PASS: TestAccAWSCodeBuildProject_Artifacts_Path (76.47s) --- PASS: TestAccAWSCodeBuildProject_Artifacts_Type (52.04s) --- PASS: TestAccAWSCodeBuildProject_BadgeEnabled (64.22s) --- PASS: TestAccAWSCodeBuildProject_basic (66.51s) --- PASS: TestAccAWSCodeBuildProject_BuildTimeout (142.70s) --- PASS: TestAccAWSCodeBuildProject_Cache (492.80s) --- PASS: TestAccAWSCodeBuildProject_Description (118.05s) --- PASS: TestAccAWSCodeBuildProject_EncryptionKey (24.36s) --- PASS: TestAccAWSCodeBuildProject_Environment_Certificate (35.56s) --- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable (137.21s) --- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable_Type (125.69s) --- PASS: TestAccAWSCodeBuildProject_Environment_RegistryCredential (42.96s) --- PASS: TestAccAWSCodeBuildProject_LogsConfig_CloudWatchLogs (114.15s) --- PASS: TestAccAWSCodeBuildProject_LogsConfig_S3Logs (127.95s) --- PASS: TestAccAWSCodeBuildProject_QueuedTimeout (59.77s) --- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts (59.42s) --- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_ArtifactIdentifier (121.77s) --- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_EncryptionDisabled (59.14s) --- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Location (152.24s) --- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_NamespaceType (43.80s) --- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_OverrideArtifactName (57.07s) --- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Packaging (52.05s) --- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Path (47.08s) --- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Type (28.57s) --- PASS: TestAccAWSCodeBuildProject_SecondarySources_CodeCommit (42.53s) --- PASS: TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_CodeCommit (43.31s) --- PASS: TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_GitHub (49.07s) --- PASS: TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_GitHubEnterprise (213.67s) --- PASS: TestAccAWSCodeBuildProject_Source_GitCloneDepth (51.10s) --- PASS: TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_CodeCommit (75.27s) --- PASS: TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_GitHub (132.44s) --- PASS: TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_GitHubEnterprise (38.49s) --- PASS: TestAccAWSCodeBuildProject_Source_InsecureSSL (110.79s) --- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_Bitbucket (112.36s) --- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHub (263.79s) --- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHubEnterprise (89.94s) --- PASS: TestAccAWSCodeBuildProject_Source_Type_Bitbucket (63.16s) --- PASS: TestAccAWSCodeBuildProject_Source_Type_CodeCommit (75.09s) --- PASS: TestAccAWSCodeBuildProject_Source_Type_CodePipeline (134.04s) --- PASS: TestAccAWSCodeBuildProject_Source_Type_GitHubEnterprise (68.32s) --- PASS: TestAccAWSCodeBuildProject_Source_Type_NoSource (143.63s) --- PASS: TestAccAWSCodeBuildProject_Source_Type_NoSourceInvalid (12.03s) --- PASS: TestAccAWSCodeBuildProject_Source_Type_S3 (82.56s) --- PASS: TestAccAWSCodeBuildProject_SourceVersion (55.28s) --- PASS: TestAccAWSCodeBuildProject_Tags (59.02s) --- PASS: TestAccAWSCodeBuildProject_WindowsContainer (31.46s) ```
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Relates OR Closes #13254
Release note for CHANGELOG:
Output from acceptance testing: