Skip to content

Commit 05337e6

Browse files
Merge pull request #8552 from GoogleCloudPlatform/main_copy (#15413)
Sync 5.0.0 with main Part 3 Signed-off-by: Modular Magician <[email protected]>
1 parent 84b790e commit 05337e6

File tree

192 files changed

+12801
-1751
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+12801
-1751
lines changed

.changelog/8552.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

.teamcity/components/build_config_package.kt

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
/*
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
16
// this file is copied from mmv1, any changes made here will be overwritten
27

38
import jetbrains.buildServer.configs.kotlin.*
49
import jetbrains.buildServer.configs.kotlin.AbsoluteId
510

6-
class packageDetails(name: String, displayName: String, environment: String) {
11+
class packageDetails(name: String, displayName: String, environment: String, branchRef: String) {
712
val packageName = name
813
val displayName = displayName
914
val environment = environment
15+
val branchRef = branchRef
1016

17+
// buildConfiguration returns a BuildType for a service package
18+
// For BuildType docs, see https://teamcity.jetbrains.com/app/dsl-documentation/root/build-type/index.html
1119
fun buildConfiguration(providerName : String, path : String, manualVcsRoot: AbsoluteId, nightlyTestsEnabled: Boolean, startHour: Int, parallelism: Int, daysOfWeek: String, daysOfMonth: String) : BuildType {
1220
return BuildType {
1321
// TC needs a consistent ID for dynamically generated packages
@@ -50,12 +58,18 @@ class packageDetails(name: String, displayName: String, environment: String) {
5058
}
5159

5260
triggers {
53-
RunNightly(nightlyTestsEnabled, startHour, daysOfWeek, daysOfMonth)
61+
RunNightly(nightlyTestsEnabled, startHour, daysOfWeek, daysOfMonth, branchRef)
5462
}
5563
}
5664
}
5765

5866
fun uniqueID(provider : String) : String {
59-
return "%s_SERVICE_%s_%s".format(provider.replace("-", "").toUpperCase(), environment.toUpperCase(), packageName.toUpperCase())
67+
// Replacing chars can be necessary, due to limitations on IDs
68+
// "ID should start with a latin letter and contain only latin letters, digits and underscores (at most 225 characters)."
69+
var pv = provider.replace("-", "").toUpperCase()
70+
var env = environment.toUpperCase().replace("-", "").replace(".", "").toUpperCase()
71+
var pkg = packageName.toUpperCase()
72+
73+
return "%s_SERVICE_%s_%s".format(pv, env, pkg)
6074
}
6175
}

.teamcity/components/build_google.kt

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
16
// this file is copied from mmv1, any changes made here will be overwritten
27

38
import jetbrains.buildServer.configs.kotlin.ParametrizedWithType
@@ -19,6 +24,9 @@ class ClientConfiguration(var custId: String,
1924
val identityUser : String ) {
2025
}
2126

27+
// ParametrizedWithType.ConfigureGoogleSpecificTestParameters allows build configs to be created
28+
// with the environment variables needed to configure the provider and/or configure test code.
29+
// Extension of ParametrizedWithType. For docs, see https://teamcity.jetbrains.com/app/dsl-documentation/root/parametrized-with-type/index.html
2230
fun ParametrizedWithType.ConfigureGoogleSpecificTestParameters(config: ClientConfiguration) {
2331
hiddenPasswordVariable("env.GOOGLE_CUST_ID", config.custId, "The ID of the Google Identity Customer")
2432
hiddenPasswordVariable("env.GOOGLE_ORG", config.org, "The Google Organization Id")

.teamcity/components/generated/build_components.kt

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
16
// this file is auto-generated with mmv1, any changes made here will be overwritten
27

38
import jetbrains.buildServer.configs.kotlin.*
@@ -12,6 +17,15 @@ import jetbrains.buildServer.configs.kotlin.triggers.schedule
1217
//
1318
// Until that changes, we'll continue to use `teamcity-go-test` to run
1419
// each test individually
20+
21+
// NOTE: this file includes Extensions of Kotlin DSL classes
22+
// See
23+
// - BuildFeatures https://teamcity.jetbrains.com/app/dsl-documentation/root/build-features/index.html
24+
// - BuildSteps https://teamcity.jetbrains.com/app/dsl-documentation/root/build-steps/index.html
25+
// - ParametrizedWithType https://teamcity.jetbrains.com/app/dsl-documentation/root/parametrized-with-type/index.html
26+
// - Triggers https://teamcity.jetbrains.com/app/dsl-documentation/root/triggers/index.html
27+
28+
1529
const val useTeamCityGoTest = false
1630

1731
fun BuildFeatures.Golang() {
@@ -120,10 +134,12 @@ fun ParametrizedWithType.hiddenPasswordVariable(name: String, value: String, des
120134
password(name, value, "", description, ParameterDisplay.HIDDEN)
121135
}
122136

123-
fun Triggers.RunNightly(nightlyTestsEnabled: Boolean, startHour: Int, daysOfWeek: String, daysOfMonth: String) {
137+
fun Triggers.RunNightly(nightlyTestsEnabled: Boolean, startHour: Int, daysOfWeek: String, daysOfMonth: String, branchRef: String) {
138+
val filter = "+:" + branchRef // e.g. "+:refs/heads/main"
139+
124140
schedule{
125141
enabled = nightlyTestsEnabled
126-
branchFilter = "+:refs/heads/main"
142+
branchFilter = filter
127143

128144
schedulingPolicy = cron {
129145
hours = startHour.toString()
+33-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
16
// this file is auto-generated with mmv1, any changes made here will be overwritten
27

38
import jetbrains.buildServer.configs.kotlin.BuildType
@@ -6,28 +11,34 @@ import jetbrains.buildServer.configs.kotlin.AbsoluteId
611

712
const val providerName = "google"
813

9-
fun Google(environment: String, manualVcsRoot: AbsoluteId, configuration: ClientConfiguration) : Project {
14+
// Google returns an instance of Project,
15+
// which has multiple build configurations defined within it.
16+
// See https://teamcity.jetbrains.com/app/dsl-documentation/root/project/index.html
17+
fun Google(environment: String, manualVcsRoot: AbsoluteId, branchRef: String, configuration: ClientConfiguration) : Project {
1018
return Project{
1119

12-
var buildConfigs = buildConfigurationsForPackages(packages, providerName, "google", environment, manualVcsRoot, configuration)
20+
// Create build configs for each package defined in packages.kt
21+
var buildConfigs = buildConfigurationsForPackages(packages, providerName, "google", environment, manualVcsRoot, branchRef, configuration)
1322
buildConfigs.forEach { buildConfiguration ->
1423
buildType(buildConfiguration)
1524
}
1625
}
1726
}
1827

19-
fun buildConfigurationsForPackages(packages: Map<String, String>, providerName : String, path : String, environment: String, manualVcsRoot: AbsoluteId, config: ClientConfiguration): List<BuildType> {
28+
fun buildConfigurationsForPackages(packages: Map<String, String>, providerName : String, path : String, environment: String, manualVcsRoot: AbsoluteId, branchRef: String, config: ClientConfiguration): List<BuildType> {
2029
var list = ArrayList<BuildType>()
2130

2231
packages.forEach { (packageName, displayName) ->
2332
if (packageName == "services") {
24-
var serviceList = buildConfigurationsForPackages(services, providerName, path+"/"+packageName, environment, manualVcsRoot, config)
33+
// `services` is a folder containing packages, not a package itself; call buildConfigurationsForPackages to iterate through directories found within `services`
34+
var serviceList = buildConfigurationsForPackages(services, providerName, path+"/"+packageName, environment, manualVcsRoot, branchRef, config)
2535
list.addAll(serviceList)
2636
} else {
27-
var defaultTestConfig = testConfiguration()
37+
// other folders assumed to be packages
38+
var testConfig = testConfiguration(environment)
2839

29-
var pkg = packageDetails(packageName, displayName, environment)
30-
var buildConfig = pkg.buildConfiguration(providerName, path, manualVcsRoot, true, defaultTestConfig.startHour, defaultTestConfig.parallelism, defaultTestConfig.daysOfWeek, defaultTestConfig.daysOfMonth)
40+
var pkg = packageDetails(packageName, displayName, environment, branchRef)
41+
var buildConfig = pkg.buildConfiguration(providerName, path, manualVcsRoot, true, testConfig.startHour, testConfig.parallelism, testConfig.daysOfWeek, testConfig.daysOfMonth)
3142

3243
buildConfig.params.ConfigureGoogleSpecificTestParameters(config)
3344

@@ -38,9 +49,23 @@ fun buildConfigurationsForPackages(packages: Map<String, String>, providerName :
3849
return list
3950
}
4051

41-
class testConfiguration(parallelism: Int = defaultParallelism, startHour: Int = defaultStartHour, daysOfWeek: String = defaultDaysOfWeek, daysOfMonth: String = defaultDaysOfMonth) {
52+
class testConfiguration(environment: String, parallelism: Int = defaultParallelism, startHour: Int = defaultStartHour, daysOfWeek: String = defaultDaysOfWeek, daysOfMonth: String = defaultDaysOfMonth) {
53+
54+
// Default values are present if init doesn't change them
4255
var parallelism = parallelism
4356
var startHour = startHour
4457
var daysOfWeek = daysOfWeek
4558
var daysOfMonth = daysOfMonth
59+
60+
init {
61+
// If the environment parameter is set to the value of MAJOR_RELEASE_TESTING,
62+
// change the days of week to the day for v5.0.0 feature branch testing
63+
if (environment == MAJOR_RELEASE_TESTING) {
64+
this.parallelism = parallelism
65+
this.startHour = startHour
66+
this.daysOfWeek = "4" // Thursday for GA
67+
this.daysOfMonth = daysOfMonth
68+
}
69+
}
70+
4671
}

.teamcity/components/generated/services.kt

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
16
// this file is auto-generated by magic-modules/tools/teamcity-generator, any changes made here will be overwritten
27

38
var services = mapOf(
@@ -56,6 +61,7 @@ var services = mapOf(
5661
"dialogflowcx" to "Dialogflowcx",
5762
"dns" to "Dns",
5863
"documentai" to "Documentai",
64+
"documentaiwarehouse" to "Documentaiwarehouse",
5965
"essentialcontacts" to "Essentialcontacts",
6066
"eventarc" to "Eventarc",
6167
"filestore" to "Filestore",
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
// this file is auto-generated with mmv1, any changes made here will be overwritten
7+
8+
// specifies the default hour (UTC) at which tests should be triggered, if enabled
9+
var defaultStartHour = 4
10+
11+
// specifies the default level of parallelism per-service-package
12+
var defaultParallelism = 12
13+
14+
// specifies the default version of Terraform Core which should be used for testing
15+
var defaultTerraformCoreVersion = "1.2.5"
16+
17+
// This represents a cron view of days of the week
18+
const val defaultDaysOfWeek = "1-3,5-7" // All nights except Thursday for GA; feature branch testing happens on Thursdays
19+
20+
// Cron value for any day of month
21+
const val defaultDaysOfMonth = "*"
22+
23+
// Values that `environment` parameter is checked against,
24+
// when deciding to change how TeamCity objects are configured
25+
const val MAJOR_RELEASE_TESTING = "major-release-5.0.0-testing"

.teamcity/components/packages.kt

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
16
// this file is copied from mmv1, any changes made here will be overwritten
27

38
var packages = mapOf(

.teamcity/components/settings.kt

-16
This file was deleted.

.teamcity/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
<format>kotlin</format>
9696
<dstDir>target/generated-configs</dstDir>
9797
<contextParameters>
98-
<environment>public</environment>
98+
<environment>default</environment>
9999
</contextParameters>
100100
</configuration>
101101
</plugin>

.teamcity/settings.kts

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
16
// this file is auto-generated with mmv1, any changes made here will be overwritten
27

38
import Google
@@ -6,6 +11,12 @@ import jetbrains.buildServer.configs.kotlin.*
611

712
version = "2023.05"
813

14+
// The code below pulls context parameters from the TeamCity project.
15+
// Context parameters aren't stored in VCS, and are managed manually.
16+
// Due to this, the code needs to explicitly pull in values via the DSL and pass the values into other code.
17+
// For DslContext docs, see https://teamcity.jetbrains.com/app/dsl-documentation/root/dsl-context/index.html
18+
19+
// Values of these parameters are used to set ENVs needed for acceptance tests within the build configurations.
920
var custId = DslContext.getParameter("custId", "")
1021
var org = DslContext.getParameter("org", "")
1122
var org2 = DslContext.getParameter("org2", "")
@@ -19,14 +30,19 @@ var region = DslContext.getParameter("region", "")
1930
var serviceAccount = DslContext.getParameter("serviceAccount", "")
2031
var zone = DslContext.getParameter("zone", "")
2132
var credentials = DslContext.getParameter("credentials", "")
22-
var environment = DslContext.getParameter("environment", "public")
2333
var firestoreProject = DslContext.getParameter("firestoreProject", "")
2434
var identityUser = DslContext.getParameter("identityUser", "")
2535

2636
// Get details of the VCS Root that's manually made when VCS is first
2737
// connected to the Project in TeamCity
2838
var manualVcsRoot = DslContext.settingsRootId
2939

40+
// Values of these parameters change configuration code behaviour.
41+
var environment = DslContext.getParameter("environment", "default")
42+
var branchRef = DslContext.getParameter("branch", "refs/heads/main")
43+
3044
var clientConfig = ClientConfiguration(custId, org, org2, billingAccount, billingAccount2, masterBillingAccount, credentials, project, orgDomain, projectNumber, region, serviceAccount, zone, firestoreProject, identityUser)
3145

32-
project(Google(environment, manualVcsRoot, clientConfig))
46+
// This is the entry point of the code in .teamcity/
47+
// See https://teamcity.jetbrains.com/app/dsl-documentation/root/project.html
48+
project(Google(environment, manualVcsRoot, branchRef, clientConfig))

.teamcity/tests/generated/configuration.kt

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
16
// this file is auto-generated with mmv1, any changes made here will be overwritten
27

38
package tests
@@ -10,15 +15,15 @@ import useTeamCityGoTest
1015
class ConfigurationTests {
1116
@Test
1217
fun buildShouldFailOnError() {
13-
val project = Google("public", TestVcsRootId(), TestConfiguration())
18+
val project = Google("public", TestVcsRootId(), "refs/heads/main", TestConfiguration())
1419
project.buildTypes.forEach { bt ->
1520
assertTrue("Build '${bt.id}' should fail on errors!", bt.failureConditions.errorMessage)
1621
}
1722
}
1823

1924
@Test
2025
fun buildShouldHaveGoTestFeature() {
21-
val project = Google("public", TestVcsRootId(), TestConfiguration())
26+
val project = Google("public", TestVcsRootId(), "refs/heads/main",TestConfiguration())
2227
project.buildTypes.forEach{ bt ->
2328
var exists = false
2429
bt.features.items.forEach { f ->
@@ -35,7 +40,7 @@ class ConfigurationTests {
3540

3641
@Test
3742
fun buildShouldHaveTrigger() {
38-
val project = Google("public", TestVcsRootId(), TestConfiguration())
43+
val project = Google("public", TestVcsRootId(), "refs/heads/main", TestConfiguration())
3944
var exists = false
4045
project.buildTypes.forEach{ bt ->
4146
bt.triggers.items.forEach { t ->

.teamcity/tests/generated/vcs_roots.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
16
// this file is auto-generated with mmv1, any changes made here will be overwritten
27

38
package tests
@@ -9,7 +14,7 @@ import org.junit.Test
914
class VcsTests {
1015
@Test
1116
fun buildsHaveCleanCheckOut() {
12-
val project = Google("public", TestVcsRootId(), TestConfiguration())
17+
val project = Google("public", TestVcsRootId(), "refs/heads/main", TestConfiguration())
1318
project.buildTypes.forEach { bt ->
1419
assertTrue("Build '${bt.id}' doesn't use clean checkout", bt.vcs.cleanCheckout)
1520
}

.teamcity/tests/helpers.kt

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
16
// this file is copied from mmv1, any changes made here will be overwritten
27

38
package tests

0 commit comments

Comments
 (0)