-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31238 from hashicorp/td-teamcity-assume-role-full…
…-build CI: Enables assuming role for full build
- Loading branch information
Showing
14 changed files
with
248 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Code generated by internal/generate/teamcity/provider_tests.go; DO NOT EDIT. | ||
|
||
set -euo pipefail | ||
|
||
# All of internal except for internal/service. This list should be generated. | ||
# shellcheck disable=2157 # This isn't a constant string, it's a TeamCity variable substitution | ||
if [[ -n "%ACCTEST_ROLE_ARN%" ]]; then | ||
conf=$(pwd)/aws.conf | ||
|
||
function cleanup { | ||
rm "${conf}" | ||
} | ||
trap cleanup EXIT | ||
|
||
touch "${conf}" | ||
chmod 600 "${conf}" | ||
cat <<EOF >"${conf}" | ||
[profile primary] | ||
role_arn = %ACCTEST_ROLE_ARN% | ||
source_profile = primary_user | ||
[profile primary_user] | ||
aws_access_key_id = %AWS_ACCESS_KEY_ID% | ||
aws_secret_access_key = %AWS_SECRET_ACCESS_KEY% | ||
EOF | ||
|
||
unset AWS_ACCESS_KEY_ID | ||
unset AWS_SECRET_ACCESS_KEY | ||
|
||
export AWS_CONFIG_FILE="${conf}" | ||
export AWS_PROFILE=primary | ||
fi | ||
|
||
TF_ACC=1 go test \ | ||
./internal/acctest/... \ | ||
./internal/attrmap/... \ | ||
./internal/conns/... \ | ||
./internal/create/... \ | ||
./internal/enum/... \ | ||
./internal/envvar/... \ | ||
./internal/errs/... \ | ||
./internal/experimental/... \ | ||
./internal/flex/... \ | ||
./internal/framework/... \ | ||
./internal/generate/... \ | ||
./internal/maps/... \ | ||
./internal/provider/... \ | ||
./internal/sdktypes/... \ | ||
./internal/slices/... \ | ||
./internal/sweep/... \ | ||
./internal/tags/... \ | ||
./internal/tfresource/... \ | ||
./internal/types/... \ | ||
./internal/vault/... \ | ||
./internal/verify/... \ | ||
-json -v -count=1 -parallel "%ACCTEST_PARALLELISM%" -timeout=0 -run=TestAcc |
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 |
---|---|---|
@@ -1,18 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Code generated by internal/generate/teamcity/provider_tests.go; DO NOT EDIT. | ||
|
||
set -euo pipefail | ||
|
||
# All of internal except for internal/service. This list should be generated. | ||
go test \ | ||
./internal/acctest/... \ | ||
./internal/attrmap/... \ | ||
./internal/conns/... \ | ||
./internal/create/... \ | ||
./internal/enum/... \ | ||
./internal/envvar/... \ | ||
./internal/errs/... \ | ||
./internal/experimental/... \ | ||
./internal/flex/... \ | ||
./internal/framework/... \ | ||
./internal/generate/... \ | ||
./internal/maps/... \ | ||
./internal/provider/... \ | ||
./internal/sdktypes/... \ | ||
./internal/slices/... \ | ||
./internal/sweep/... \ | ||
./internal/tags/... \ | ||
./internal/tfresource/... \ | ||
./internal/types/... \ | ||
./internal/vault/... \ | ||
./internal/verify/... \ | ||
-json |
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,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Code generated by internal/generate/teamcity/provider_tests.go; DO NOT EDIT. | ||
|
||
set -euo pipefail | ||
|
||
# shellcheck disable=2157 # This isn't a constant string, it's a TeamCity variable substitution | ||
if [[ -n "%ACCTEST_ROLE_ARN%" ]]; then | ||
conf=$(pwd)/aws.conf | ||
|
||
function cleanup { | ||
rm "${conf}" | ||
} | ||
trap cleanup EXIT | ||
|
||
touch "${conf}" | ||
chmod 600 "${conf}" | ||
cat <<EOF >"${conf}" | ||
[profile primary] | ||
role_arn = %ACCTEST_ROLE_ARN% | ||
source_profile = primary_user | ||
[profile primary_user] | ||
aws_access_key_id = %AWS_ACCESS_KEY_ID% | ||
aws_secret_access_key = %AWS_SECRET_ACCESS_KEY% | ||
EOF | ||
|
||
unset AWS_ACCESS_KEY_ID | ||
unset AWS_SECRET_ACCESS_KEY | ||
|
||
export AWS_CONFIG_FILE="${conf}" | ||
export AWS_PROFILE=primary | ||
fi | ||
|
||
TF_ACC=1 go test \ | ||
{{- range . }} | ||
./internal/{{ . }}/... \ | ||
{{- end }} | ||
-json -v -count=1 -parallel "%ACCTEST_PARALLELISM%" -timeout=0 -run=TestAcc |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
//go:generate go run main.go | ||
//go:generate go run services.go | ||
//go:generate go run provider_tests.go | ||
// ONLY generate directives and package declaration! Do not add anything else to this file. | ||
|
||
package teamcity |
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,87 @@ | ||
//go:build generate | ||
// +build generate | ||
|
||
package main | ||
|
||
import ( | ||
_ "embed" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/hashicorp/terraform-provider-aws/internal/generate/common" | ||
) | ||
|
||
type ServiceDatum struct { | ||
ProviderPackage string | ||
HumanFriendly string | ||
VpcLock bool | ||
Parallelism int | ||
Region string | ||
} | ||
|
||
type TemplateData struct { | ||
Services []ServiceDatum | ||
} | ||
|
||
func main() { | ||
const ( | ||
acceptanceTestsScriptFile = `.teamcity/scripts/provider_tests/acceptance_tests.sh` | ||
unitTestsScriptFile = `.teamcity/scripts/provider_tests/unit_tests.sh` | ||
) | ||
g := common.NewGenerator() | ||
|
||
projectRoot, err := filepath.Abs(`../../../`) | ||
if err != nil { | ||
g.Fatalf(err.Error()) | ||
} | ||
|
||
internalDir := filepath.Join(projectRoot, "internal") | ||
|
||
dirs, err := os.ReadDir(internalDir) | ||
if err != nil { | ||
g.Fatalf(err.Error()) | ||
} | ||
|
||
generator := generator{ | ||
g: g, | ||
root: projectRoot, | ||
} | ||
|
||
for _, dir := range dirs { | ||
if dir.IsDir() && dir.Name() != "service" { | ||
generator.dirNames = append(generator.dirNames, dir.Name()) | ||
} | ||
} | ||
|
||
generator.generate(acceptanceTestsScriptFile, acceptanceTestsTmpl) | ||
|
||
generator.generate(unitTestsScriptFile, unitTestsTmpl) | ||
} | ||
|
||
type generator struct { | ||
g *common.Generator | ||
root string | ||
dirNames []string | ||
} | ||
|
||
func (g generator) generate(filename, template string) { | ||
g.g.Infof("Generating %s", filename) | ||
|
||
destFile := filepath.Join(g.root, filename) | ||
|
||
d := g.g.NewUnformattedFileDestination(destFile) | ||
|
||
if err := d.WriteTemplate("teamcity", template, g.dirNames); err != nil { | ||
g.g.Fatalf("generating file (%s): %s", filename, err) | ||
} | ||
|
||
if err := d.Write(); err != nil { | ||
g.g.Fatalf("generating file (%s): %s", filename, err) | ||
} | ||
} | ||
|
||
//go:embed acceptance_tests.tmpl | ||
var acceptanceTestsTmpl string | ||
|
||
//go:embed unit_tests.tmpl | ||
var unitTestsTmpl string |
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
2 changes: 1 addition & 1 deletion
2
internal/generate/teamcity/file.tmpl → internal/generate/teamcity/services.tmpl
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,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Code generated by internal/generate/teamcity/provider_tests.go; DO NOT EDIT. | ||
|
||
set -euo pipefail | ||
|
||
go test \ | ||
{{- range . }} | ||
./internal/{{ . }}/... \ | ||
{{- end }} | ||
-json |
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