Skip to content

Commit

Permalink
Initial TeamCity DSL configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
gdavison committed Nov 9, 2021
1 parent 9f36b9c commit e0d29ba
Show file tree
Hide file tree
Showing 13 changed files with 609 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ aws/testdata/service/cloudformation/examplecompany-exampleservice-exampleresourc
*.winfile eol=crlf
/.vs
node_modules

.teamcity/target
1 change: 1 addition & 0 deletions .teamcity/.java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
corretto64-11.0.13
18 changes: 18 additions & 0 deletions .teamcity/components/generated/service_orgacct.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
val orgacctServices = mapOf(
"accessanalyzer" to ServiceSpec("Access Analyzer"),
"backup" to ServiceSpec("Backup", "TestAccBackupGlobalSettings_basic"),
"cloudformation" to ServiceSpec(
"CloudFormation",
"TestAccCloudFormationStackSet_PermissionModel_serviceManaged|TestAccCloudFormationStackSetInstance_deploymentTargets"
),
"cloudtrail" to ServiceSpec("CloudTrail"),
"config" to ServiceSpec("Config" /*"TestAccConfig_serial|TestAccConfigConfigurationAggregator_"*/),
"fms" to ServiceSpec("FMS"),
"guardduty" to ServiceSpec("GuardDuty"),
"macie2" to ServiceSpec("Macie2"),
"organizations" to ServiceSpec("Organizations"),
"securityhub" to ServiceSpec(
"SecurityHub",
"TestAccSecurityHub_serial/Account|TestAccSecurityHub_serial/OrganizationAdminAccount|TestAccSecurityHub_serial/OrganizationConfiguration"
),
)
155 changes: 155 additions & 0 deletions .teamcity/components/generated/services_all.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
val services = mapOf(
"accessanalyzer" to ServiceSpec("Access Analyzer"),
"acm" to ServiceSpec("ACM"),
"acmpca" to ServiceSpec("ACM PCA"),
"amplify" to ServiceSpec("Amplify"),
"apigateway" to ServiceSpec("API Gateway"),
"apigatewayv2" to ServiceSpec("API Gateway v2"),
"appautoscaling" to ServiceSpec("Application Auto Scaling"),
"appconfig" to ServiceSpec("AppConfig"),
"appmesh" to ServiceSpec("App Mesh"),
"apprunner" to ServiceSpec("AppRunner"),
"appstream" to ServiceSpec("AppStream"),
"appsync" to ServiceSpec("AppSync"),
"athena" to ServiceSpec("Athena"),
"autoscaling" to ServiceSpec("Auto Scaling"),
"autoscalingplans" to ServiceSpec("Auto Scaling Plans"),
"backup" to ServiceSpec("Backup"),
"batch" to ServiceSpec("Batch"),
"budgets" to ServiceSpec("Budgets"),
"chime" to ServiceSpec("Chime"),
"cloud9" to ServiceSpec("Cloud9"),
"cloudcontrol" to ServiceSpec("CloudControl"),
"cloudformation" to ServiceSpec("CloudFormation"),
"cloudfront" to ServiceSpec("CloudFront"),
"cloudhsmv2" to ServiceSpec("CloudHSM v2"),
"cloudtrail" to ServiceSpec("CloudTrail"),
"cloudwatch" to ServiceSpec("CloudWatch"),
"cloudwatchevents" to ServiceSpec("CloudWatch Events"),
"cloudwatchlogs" to ServiceSpec("CloudWatch Logs"),
"codeartifact" to ServiceSpec("CodeArtifact"),
"codebuild" to ServiceSpec("CodeBuild"),
"codecommit" to ServiceSpec("CodeCommit"),
"codedeploy" to ServiceSpec("CodeDeploy"),
"codepipeline" to ServiceSpec("CodePipeline"),
"codestarconnections" to ServiceSpec("CodeStar Connections"),
"codestarnotifications" to ServiceSpec("CodeStar Notifications"),
"cognitoidentity" to ServiceSpec("Cognito Identity"),
"cognitoidp" to ServiceSpec("Cognito Identity Provider"),
"config" to ServiceSpec("Config Service"),
"connect" to ServiceSpec("Connect"),
"cur" to ServiceSpec("Cost and Usage Report Service"),
"dataexchange" to ServiceSpec("DataExchange"),
"datapipeline" to ServiceSpec("Data Pipeline"),
"datasync" to ServiceSpec("DataSync"),
"dax" to ServiceSpec("DAX"),
"devicefarm" to ServiceSpec("Device Farm"),
"directconnect" to ServiceSpec("Direct Connect"),
"dlm" to ServiceSpec("DLM"),
"dms" to ServiceSpec("Database Migration Service"),
"docdb" to ServiceSpec("DocDB"),
"ds" to ServiceSpec("Directory Service"),
"dynamodb" to ServiceSpec("DynamoDB"),
"ec2" to ServiceSpec("EC2"),
"ecr" to ServiceSpec("ECR"),
"ecrpublic" to ServiceSpec("ECR Public"),
"ecs" to ServiceSpec("ECS"),
"efs" to ServiceSpec("EFS"),
"eks" to ServiceSpec("EKS"),
"elasticache" to ServiceSpec("ElastiCache"),
"elasticbeanstalk" to ServiceSpec("Elastic Beanstalk"),
"elasticsearch" to ServiceSpec("Elasticsearch Service"),
"elastictranscoder" to ServiceSpec("Elastic Transcoder"),
"elb" to ServiceSpec("Elastic Load Balancing"),
"elbv2" to ServiceSpec("Elastic Load Balancing v2"),
"emr" to ServiceSpec("EMR"),
"firehose" to ServiceSpec("Firehose"),
"fms" to ServiceSpec("FMS"),
"fsx" to ServiceSpec("FSx"),
"gamelift" to ServiceSpec("GameLift"),
"glacier" to ServiceSpec("Glacier"),
"globalaccelerator" to ServiceSpec("Global Accelerator"),
"glue" to ServiceSpec("Glue"),
"greengrass" to ServiceSpec("Greengrass"),
"guardduty" to ServiceSpec("GuardDuty"),
"iam" to ServiceSpec("IAM"),
"identitystore" to ServiceSpec("SSO Identitystore"),
"imagebuilder" to ServiceSpec("EC2 Image Builder"),
"inspector" to ServiceSpec("Inspector"),
"iot" to ServiceSpec("IoT"),
"iotanalytics" to ServiceSpec("IoT Analytics"),
"iotevents" to ServiceSpec("IoT Events"),
"kafka" to ServiceSpec("Kafka"),
"kinesis" to ServiceSpec("Kinesis"),
"kinesisanalytics" to ServiceSpec("Kinesis Analytics"),
"kinesisanalyticsv2" to ServiceSpec("Kinesis Analytics v2"),
"kinesisvideo" to ServiceSpec("Kinesis Video"),
"kms" to ServiceSpec("KMS"),
"lakeformation" to ServiceSpec("LakeFormation"),
"lambda" to ServiceSpec("Lambda"),
"lexmodelbuilding" to ServiceSpec("Lex Model Building Service"),
"licensemanager" to ServiceSpec("License Manager"),
"lightsail" to ServiceSpec("Lightsail"),
"macie" to ServiceSpec("Macie"),
"macie2" to ServiceSpec("Macie2"),
"mediaconnect" to ServiceSpec("MediaConnect"),
"mediaconvert" to ServiceSpec("MediaConvert"),
"medialive" to ServiceSpec("MediaLive"),
"mediapackage" to ServiceSpec("MediaPackage"),
"mediastore" to ServiceSpec("MediaStore"),
"meta" to ServiceSpec("Provider-level Data Sources"),
"mq" to ServiceSpec("MQ"),
"mwaa" to ServiceSpec("MWAA"),
"neptune" to ServiceSpec("Neptune"),
"networkfirewall" to ServiceSpec("Network Firewall"),
"networkmanager" to ServiceSpec("NetworkManager"),
"opsworks" to ServiceSpec("OpsWorks"),
"organizations" to ServiceSpec("Organizations"),
"outposts" to ServiceSpec("Outposts"),
"pinpoint" to ServiceSpec("Pinpoint"),
"pricing" to ServiceSpec("Pricing"),
"prometheus" to ServiceSpec("Prometheus"),
"qldb" to ServiceSpec("QLDB"),
"quicksight" to ServiceSpec("QuickSight"),
"ram" to ServiceSpec("RAM"),
"rds" to ServiceSpec("RDS"),
"redshift" to ServiceSpec("Redshift"),
"resourcegroups" to ServiceSpec("Resource Groups"),
"resourcegroupstagging" to ServiceSpec("Resource Groups Tagging API"),
"route53" to ServiceSpec("Route 53"),
"route53recoverycontrolconfig" to ServiceSpec("Route53 Recovery Control Config"),
"route53recoveryreadiness" to ServiceSpec("Route53 Recovery Readiness"),
"route53resolver" to ServiceSpec("Route53Resolver"),
"s3" to ServiceSpec("S3"),
"s3control" to ServiceSpec("S3 Control"),
"s3outposts" to ServiceSpec("S3Outposts"),
"sagemaker" to ServiceSpec("SageMaker"),
"schemas" to ServiceSpec("Schemas"),
"secretsmanager" to ServiceSpec("Secrets Manager"),
"securityhub" to ServiceSpec("SecurityHub"),
"serverlessapprepo" to ServiceSpec("Serverless Application Repository"),
"servicecatalog" to ServiceSpec("Service Catalog"),
"servicediscovery" to ServiceSpec("ServiceDiscovery"),
"servicequotas" to ServiceSpec("Service Quotas"),
"ses" to ServiceSpec("SES"),
"sfn" to ServiceSpec("SFN"),
"shield" to ServiceSpec("Shield"),
"signer" to ServiceSpec("Signer"),
"simpledb" to ServiceSpec("SimpleDB"),
"sns" to ServiceSpec("SNS"),
"sqs" to ServiceSpec("SQS"),
"ssm" to ServiceSpec("SSM"),
"ssoadmin" to ServiceSpec("SSO Admin"),
"storagegateway" to ServiceSpec("Storage Gateway"),
"sts" to ServiceSpec("STS"),
"swf" to ServiceSpec("SWF"),
"synthetics" to ServiceSpec("Synthetics"),
"timestreamwrite" to ServiceSpec("Timestream Write"),
"transfer" to ServiceSpec("Transfer"),
"waf" to ServiceSpec("WAF"),
"wafregional" to ServiceSpec("WAF Regional"),
"wafv2" to ServiceSpec("WAF v2"),
"worklink" to ServiceSpec("WorkLink"),
"workspaces" to ServiceSpec("WorkSpaces"),
"xray" to ServiceSpec("XRay"),
)
55 changes: 55 additions & 0 deletions .teamcity/components/service_build_config.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import jetbrains.buildServer.configs.kotlin.v2019_2.AbsoluteId
import jetbrains.buildServer.configs.kotlin.v2019_2.BuildType
import jetbrains.buildServer.configs.kotlin.v2019_2.DslContext
import jetbrains.buildServer.configs.kotlin.v2019_2.ParameterDisplay
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.script
import java.io.File

data class ServiceSpec(val readableName: String, val patternOverride: String = "")

class Service(name: String, displayName: ServiceSpec) {
val packageName = name
val displayName = displayName

fun buildType(): BuildType {
return BuildType {
id = DslContext.createId("ServiceTest_$packageName")

name = "2. ${displayName.readableName} - Tests"

vcs {
root(AbsoluteId(DslContext.getParameter("vcs_root_id")))
cleanCheckout = true
}

if (displayName.patternOverride != "") {
params {
text("TEST_PATTERN", displayName.patternOverride, display = ParameterDisplay.HIDDEN)
}
}

val serviceDir = "./internal/service/$packageName"
steps {
script {
name = "Setup GOENV"
scriptContent = File("./scripts/setup_goenv.sh").readText()
}
script {
name = "Compile Test Binary"
workingDir = serviceDir
scriptContent = File("./scripts/service_tests/compile_test_binary.sh").readText()
}
script {
name = "Run Unit Tests"
workingDir = serviceDir
scriptContent = File("./scripts/service_tests/unit_tests.sh").readText()
}
script {
name = "Run Acceptance Tests"
workingDir = serviceDir
scriptContent = File("./scripts/service_tests/acceptance_tests.sh").readText()
}
}
}
}
}
108 changes: 108 additions & 0 deletions .teamcity/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
<name>AWS TeamCity Config DSL Script</name>
<groupId>TeamCity-Config-DSL-Script</groupId>
<artifactId>TeamCity-Config-DSL-Script</artifactId>
<version>1.0-SNAPSHOT</version>

<parent>
<groupId>org.jetbrains.teamcity</groupId>
<artifactId>configs-dsl-kotlin-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<repositories>
<repository>
<id>jetbrains-all</id>
<url>https://download.jetbrains.com/teamcity-repository</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>teamcity-server</id>
<url>https://ci-oss.hashicorp.engineering/app/dsl-plugins-repository</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>JetBrains</id>
<url>https://download.jetbrains.com/teamcity-repository</url>
</pluginRepository>
</pluginRepositories>

<build>
<sourceDirectory>${basedir}</sourceDirectory>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>

<configuration/>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>process-test-sources</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.teamcity</groupId>
<artifactId>teamcity-configs-maven-plugin</artifactId>
<version>${teamcity.dsl.version}</version>
<configuration>
<format>kotlin</format>
<dstDir>target/generated-configs</dstDir>
<!-- For testing -->
<!--<contextParameters>
<trigger_time>02:05:00-07:00</trigger_time>
</contextParameters>-->
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.jetbrains.teamcity</groupId>
<artifactId>configs-dsl-kotlin</artifactId>
<version>${teamcity.dsl.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.teamcity</groupId>
<artifactId>configs-dsl-kotlin-plugins</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-script-runtime</artifactId>
<version>${kotlin.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
17 changes: 17 additions & 0 deletions .teamcity/scripts/provider_tests/unit_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -euo pipefail

# All of internal except for internal/service. This list should be generated.
go test \
./internal/acctest/... \
./internal/conns/... \
./internal/create/... \
./internal/experimental/... \
./internal/flex/... \
./internal/generate/... \
./internal/provider/... \
./internal/tags/... \
./internal/tfresource/... \
./internal/vault/... \
./internal/verify/...
26 changes: 26 additions & 0 deletions .teamcity/scripts/service_tests/acceptance_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# shellcheck disable=SC2162

set -euo pipefail

TEST_LIST=$(./test-binary -test.list="%TEST_PATTERN%" 2>/dev/null)

read -a split <<<"${TEST_LIST}"
TEST_COUNT=${#split[@]}

# shellcheck disable=2050 # This isn't a constant string, it's a TeamCity variable substitution
if [ "%TEST_PATTERN%" != "^TestAcc" ]; then
echo "Filtering acceptance tests: %TEST_PATTERN%"
fi
if [ "$TEST_COUNT" == 0 ]; then
echo "Zero acceptance tests"
exit 0
elif [ "$TEST_COUNT" == 1 ]; then
echo "Running 1 acceptance test:"
else
echo "Running ${TEST_COUNT} acceptance tests:"
fi
echo "${TEST_LIST}"
echo

echo "${TEST_LIST}" | TF_ACC=1 teamcity-go-test -test ./test-binary -parallelism "%ACCTEST_PARALLELISM%"
Loading

0 comments on commit e0d29ba

Please sign in to comment.