Skip to content

Commit 02497ba

Browse files
committed
Merge remote-tracking branch 'origin/main' into keyvault-pandora-sdk
2 parents 0fb38f0 + 5dcf200 commit 02497ba

File tree

493 files changed

+22791
-4570
lines changed

Some content is hidden

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

493 files changed

+22791
-4570
lines changed

.github/labeler-issue-triage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,4 @@ service/vmware:
357357
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(vmware_cluster\W+|vmware_express_route_authorization\W+|vmware_netapp_volume_attachment\W+|vmware_private_cloud\W+|voice_services_communications_gateway\W+|voice_services_communications_gateway_test_line\W+)((.|\n)*)###'
358358

359359
service/workloads:
360-
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(chaos_studio_|container_connected_registry\W+|container_registry_cache_rule\W+|container_registry_credential_set\W+|container_registry_task\W+|container_registry_task_schedule_run_now\W+|container_registry_token_password\W+|kubernetes_cluster_extension\W+|kubernetes_cluster_trusted_access_role_binding\W+|kubernetes_fleet_manager\W+|kubernetes_fleet_member\W+|kubernetes_fleet_update_run\W+|kubernetes_fleet_update_strategy\W+|kubernetes_flux_configuration\W+|kubernetes_node_pool_snapshot\W+|workloads_sap_)((.|\n)*)###'
360+
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(chaos_studio_|container_connected_registry\W+|container_registry_cache_rule\W+|container_registry_credential_set\W+|container_registry_task\W+|container_registry_task_schedule_run_now\W+|container_registry_token_password\W+|kubernetes_cluster_deployment_safeguard\W+|kubernetes_cluster_extension\W+|kubernetes_cluster_trusted_access_role_binding\W+|kubernetes_fleet_manager\W+|kubernetes_fleet_member\W+|kubernetes_fleet_update_run\W+|kubernetes_fleet_update_strategy\W+|kubernetes_flux_configuration\W+|kubernetes_node_pool_snapshot\W+|workloads_sap_)((.|\n)*)###'
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
name: Run TeamCity Tests on Comment
3+
4+
on:
5+
issue_comment:
6+
types: [created]
7+
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
issues: write
12+
13+
jobs:
14+
check-team-membership:
15+
runs-on: ubuntu-latest
16+
# Only run on pull request comments that starts with /test
17+
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/test')
18+
outputs:
19+
is-team-member: ${{ steps.check-membership.outputs.is-member }}
20+
env:
21+
AUTHORIZED_TEAM: terraform-azure
22+
steps:
23+
- name: Check team membership
24+
id: check-membership
25+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
26+
with:
27+
github-token: ${{ secrets.GH_MEMEBERSHIP_CHECK_TOKEN }}
28+
script: |
29+
const teamSlug = "${{ env.AUTHORIZED_TEAM }}";
30+
const org = context.repo.owner;
31+
const username = context.actor;
32+
33+
try {
34+
const response = await github.rest.teams.getMembershipForUserInOrg({
35+
org: org,
36+
team_slug: teamSlug,
37+
username: username,
38+
});
39+
40+
const isMember = response.data.state === 'active';
41+
core.setOutput('is-member', isMember);
42+
43+
if (isMember) {
44+
core.info(`User ${username} is a member of team ${teamSlug}`);
45+
} else {
46+
core.warning(`User ${username} is not an active member of team ${teamSlug}`);
47+
}
48+
49+
return isMember;
50+
} catch (error) {
51+
if (error.status === 404) {
52+
core.warning(`User ${username} is not a member of team ${teamSlug}`);
53+
core.setOutput('is-member', false);
54+
return false;
55+
}
56+
throw error;
57+
}
58+
59+
run-tests:
60+
runs-on: ubuntu-latest
61+
needs: check-team-membership
62+
if: needs.check-team-membership.outputs.is-team-member == 'true'
63+
env:
64+
TCTEST_SERVER: ${{ secrets.TCTEST_SERVER }}
65+
TCTEST_FILEREGEX: 'internal/services/[a-z]*/[_a-zA-Z]*(resource|data_source)'
66+
TCTEST_SKIP_QUEUE: 'true'
67+
TCTEST_TOKEN_TC: ${{ secrets.TCTEST_TOKEN_TC }}
68+
TCTEST_BUILDTYPEID: TF_AzureRM_AZURERM_SERVICE_PUBLIC
69+
TCTEST_REPO: terraform-providers/terraform-provider-azurerm
70+
steps:
71+
- name: Setup Go
72+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.2.0
73+
with:
74+
go-version: '1.25'
75+
76+
- name: Get tctest version
77+
id: tctest-version
78+
run: |
79+
LATEST_RELEASE=$(curl -s https://api.github.com/repos/katbyte/tctest/releases/latest | grep "tag_name" | cut -d '"' -f 4)
80+
echo "version=${LATEST_RELEASE}" >> $GITHUB_OUTPUT
81+
echo "Latest tctest release: $LATEST_RELEASE"
82+
83+
- name: Cache tctest binary
84+
id: cache-tctest
85+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
86+
with:
87+
path: ~/go/bin/tctest
88+
key: tctest-${{ runner.os }}-${{ steps.tctest-version.outputs.version }}
89+
90+
- name: Install tctest
91+
if: steps.cache-tctest.outputs.cache-hit != 'true'
92+
run: |
93+
go install github.com/katbyte/tctest@latest
94+
95+
- name: Run tctest
96+
run: |
97+
PR_NUMBER=${{ github.event.issue.number }}
98+
COMMENT_BODY="${{ github.event.comment.body }}"
99+
echo "Running tctest for PR #${PR_NUMBER}"
100+
tctest pr ${PR_NUMBER} --properties "POST_GITHUB_COMMENT=true"
101+
102+
- name: Comment on success
103+
if: success()
104+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
105+
with:
106+
github-token: ${{ secrets.GITHUB_TOKEN }}
107+
script: |
108+
await github.rest.reactions.createForIssueComment({
109+
owner: context.repo.owner,
110+
repo: context.repo.repo,
111+
comment_id: context.payload.comment.id,
112+
content: 'rocket'
113+
});
114+
115+
- name: Comment on failure
116+
if: failure()
117+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
118+
with:
119+
github-token: ${{ secrets.GITHUB_TOKEN }}
120+
script: |
121+
await github.rest.issues.createComment({
122+
owner: context.repo.owner,
123+
repo: context.repo.repo,
124+
issue_number: context.issue.number,
125+
body: '❌ Failed to trigger TeamCity tests. Please check the workflow logs for details.'
126+
});
127+
128+
unauthorized-comment:
129+
runs-on: ubuntu-latest
130+
needs: check-team-membership
131+
if: needs.check-team-membership.outputs.is-team-member == 'false'
132+
steps:
133+
- name: Comment unauthorized
134+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
135+
with:
136+
github-token: ${{ secrets.GITHUB_TOKEN }}
137+
script: |
138+
await github.rest.issues.createComment({
139+
owner: context.repo.owner,
140+
repo: context.repo.repo,
141+
issue_number: context.issue.number,
142+
body: '⚠️ You are not authorized to run tests. Only members of the designated team can trigger test runs.'
143+
});

.release/provider-schema.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

.teamcity/components/build_azure.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ class ClientConfiguration(var clientId: String,
1313
val principalIdAltTenant : String,
1414
val vcsRootId : String,
1515
val enableTestTriggersGlobally : Boolean,
16-
val emailAddressAccTests : String,)
16+
val emailAddressAccTests : String,
17+
val gitHubRepo : String,
18+
val gitPat : String,
19+
)
1720

1821
class LocationConfiguration(var primary : String, var secondary : String, var tertiary : String, var rotate : Boolean)
1922

@@ -43,4 +46,8 @@ fun ParametrizedWithType.ConfigureAzureSpecificTestParameters(environment: Strin
4346
hiddenVariable("env.ARM_TEST_LOCATION_ALT2", locationsForEnv.tertiary, "The Tertiary region which should be used for testing")
4447
hiddenVariable("env.ARM_FIVEPOINTZERO_BETA", "false", "Opt into the 5.0 beta")
4548
hiddenVariable("env.ARM_TEST_ACC_EMAIL_ADDRESS", config.emailAddressAccTests, "email address for the Acceptance Tests User")
49+
hiddenPasswordVariable("env.GIT_PAT", config.gitPat, "Personal Access Token for GitHub")
50+
hiddenVariable("env.GITHUB_REPO", config.gitHubRepo, "GitHub Repository")
51+
hiddenVariable("env.POST_GITHUB_COMMENT", "false", "Whether to post a comment on the PR with the results of the tests")
52+
hiddenVariable("env.POST_GITHUB_COMMENT_DETAILED", "false", "Whether to post a detailed comment on the PR with the results of the tests")
4653
}

.teamcity/components/build_components.kt

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import jetbrains.buildServer.configs.kotlin.*
2+
import java.io.File
3+
import jetbrains.buildServer.configs.kotlin.buildFeatures.BuildCacheFeature
24
import jetbrains.buildServer.configs.kotlin.buildFeatures.GolangFeature
35
import jetbrains.buildServer.configs.kotlin.buildSteps.ScriptBuildStep
46
import jetbrains.buildServer.configs.kotlin.triggers.schedule
@@ -20,6 +22,14 @@ fun BuildFeatures.Golang() {
2022
}
2123
}
2224

25+
// Requires the creation of build_config_cache for the project:
26+
fun BuildFeatures.BuildCacheFeature() {
27+
feature(BuildCacheFeature {
28+
name = "terraform-provider-azurerm-build-cache"
29+
publish = false
30+
})
31+
}
32+
2333
fun BuildSteps.ConfigureGoEnv() {
2434
step(ScriptBuildStep {
2535
name = "Configure Go Version"
@@ -58,14 +68,18 @@ fun BuildSteps.RunAcceptanceTests(packageName: String) {
5868
} else {
5969
step(ScriptBuildStep {
6070
name = "Compile Test Binary"
61-
scriptContent = "go test -c -o test-binary"
71+
scriptContent = """
72+
mkdir -p %env.GOMODCACHE%
73+
mkdir -p %env.GOCACHE%
74+
go test -c -o test-binary
75+
""".trimIndent()
6276
workingDir = "%SERVICE_PATH%"
6377
})
6478

6579
step(ScriptBuildStep {
6680
// ./test-binary -test.list=TestAccAzureRMResourceGroup_ | teamcity-go-test -test ./test-binary -timeout 1s
6781
name = "Run via jen20/teamcity-go-test"
68-
scriptContent = "./test-binary -test.list=\"%TEST_PREFIX%\" | teamcity-go-test -test ./test-binary -parallelism \"%PARALLELISM%\" -timeout \"%TIMEOUT%h\""
82+
scriptContent = "./test-binary -test.list=\"%TEST_PREFIX%\" | teamcity-go-test -test ./test-binary -parallelism \"%PARALLELISM%\" -timeout \"%TIMEOUT%h\" | tee results.txt"
6983
workingDir = "%SERVICE_PATH%"
7084
})
7185
}
@@ -87,15 +101,25 @@ fun BuildSteps.RunAcceptanceTestsForPullRequest(packageName: String) {
87101

88102
step(ScriptBuildStep {
89103
name = "Run Tests"
90-
scriptContent = "GOFLAGS=\"-mod=vendor\" ./teamcity-go-test-json_linux_amd64 -scope \"$servicePath\" -prefix \"%TEST_PREFIX%\" -count=1 -parallelism=%PARALLELISM% -timeout %TIMEOUT%"
104+
scriptContent = "GOFLAGS=\"-mod=vendor\" ./teamcity-go-test-json_linux_amd64 -scope \"$servicePath\" -prefix \"%TEST_PREFIX%\" -count=1 -parallelism=%PARALLELISM% -timeout %TIMEOUT% | tee results.txt"
91105
})
92106
}
93107
}
94108

109+
fun BuildSteps.PostTestResultsToGitHubPullRequest() {
110+
step(ScriptBuildStep {
111+
name = "Post Test Results to GitHub Pull Request"
112+
scriptContent = File("scripts/post_github_comment.sh").readText()
113+
workingDir = "%SERVICE_PATH%"
114+
})
115+
}
116+
95117
fun ParametrizedWithType.TerraformAcceptanceTestParameters(parallelism : Int, prefix : String, timeout: Int) {
96118
text("PARALLELISM", "%d".format(parallelism))
97119
text("TEST_PREFIX", prefix)
98120
text("TIMEOUT", "%d".format(timeout))
121+
text("POST_GITHUB_COMMENT", "false")
122+
text("POST_GITHUB_COMMENT_DETAILED", "false")
99123
}
100124

101125
fun ParametrizedWithType.ReadOnlySettings() {
@@ -119,6 +143,11 @@ fun ParametrizedWithType.WorkingDirectory(packageName: String) {
119143
text("SERVICE_PATH", servicePath(packageName), "", "The path at which to run - automatically updated", ParameterDisplay.HIDDEN)
120144
}
121145

146+
fun ParametrizedWithType.GoCache() {
147+
text("env.GOMODCACHE", "%teamcity.agent.work.dir%/go-cache/mod", "The location of the Go Module Cache")
148+
text("env.GOCACHE", "%teamcity.agent.work.dir%/go-cache/build", "The location of the Go Cache")
149+
}
150+
122151
fun ParametrizedWithType.hiddenVariable(name: String, value: String, description: String) {
123152
text(name, value, "", description, ParameterDisplay.HIDDEN)
124153
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import jetbrains.buildServer.configs.kotlin.AbsoluteId
2+
import jetbrains.buildServer.configs.kotlin.BuildType
3+
import jetbrains.buildServer.configs.kotlin.buildFeatures.BuildCacheFeature
4+
import jetbrains.buildServer.configs.kotlin.buildSteps.ScriptBuildStep
5+
6+
class buildCacheConfiguration(environment: String, vcsRootId: String) {
7+
val environment = environment
8+
val vcsRootId = vcsRootId
9+
10+
fun buildConfiguration(providerName: String): BuildType {
11+
return BuildType {
12+
id(uniqueID(providerName))
13+
14+
name = "Cache Build Dependencies"
15+
16+
vcs {
17+
root(rootId = AbsoluteId(vcsRootId))
18+
cleanCheckout = true
19+
}
20+
21+
steps {
22+
ConfigureGoEnv()
23+
step(ScriptBuildStep {
24+
name = "Compile Test Binary"
25+
scriptContent = """
26+
mkdir -p %env.GOCACHE%
27+
mkdir -p %env.GOMODCACHE%
28+
go test -c -o test-binary
29+
""".trimIndent()
30+
})
31+
}
32+
33+
triggers {
34+
RunNightly(
35+
nightlyTestsEnabled = true,
36+
startHour = 23,
37+
daysOfWeek = "*",
38+
daysOfMonth = "*"
39+
)
40+
}
41+
42+
failureConditions {
43+
errorMessage = true
44+
executionTimeoutMin = 60
45+
}
46+
47+
features {
48+
feature(BuildCacheFeature {
49+
name = "terraform-provider-azurerm-build-cache"
50+
publish = true
51+
use = false
52+
rules = """
53+
%env.GOCACHE%
54+
%env.GOMODCACHE%
55+
""".trimIndent()
56+
})
57+
}
58+
59+
cleanup {
60+
baseRule {
61+
artifacts(days = 7, artifactPatterns = "+:**/*")
62+
}
63+
}
64+
65+
params {
66+
GoCache()
67+
ReadOnlySettings()
68+
}
69+
}
70+
}
71+
72+
fun uniqueID(provider: String): String {
73+
return "%s_CACHE_%s".format(provider.uppercase(), environment.uppercase())
74+
}
75+
}

.teamcity/components/build_config_pull_request.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class pullRequest(displayName: String, environment: String, vcsRootId : String)
2424
ConfigureGoEnv()
2525
DownloadTerraformBinary()
2626
RunAcceptanceTestsForPullRequest(packageName)
27+
PostTestResultsToGitHubPullRequest()
2728
}
2829

2930
failureConditions {
@@ -32,6 +33,7 @@ class pullRequest(displayName: String, environment: String, vcsRootId : String)
3233

3334
features {
3435
Golang()
36+
BuildCacheFeature()
3537
}
3638

3739
params {
@@ -40,6 +42,7 @@ class pullRequest(displayName: String, environment: String, vcsRootId : String)
4042
TerraformShouldPanicForSchemaErrors()
4143
TerraformCoreBinaryTesting()
4244
ReadOnlySettings()
45+
GoCache()
4346

4447
text("SERVICES", "portal")
4548
}

.teamcity/components/build_config_service.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class serviceDetails(name: String, displayName: String, environment: String, vcs
2222
ConfigureGoEnv()
2323
DownloadTerraformBinary()
2424
RunAcceptanceTests(packageName)
25+
PostTestResultsToGitHubPullRequest()
2526
}
2627

2728
failureConditions {
@@ -31,6 +32,7 @@ class serviceDetails(name: String, displayName: String, environment: String, vcs
3132

3233
features {
3334
Golang()
35+
BuildCacheFeature()
3436
}
3537

3638
params {
@@ -40,6 +42,7 @@ class serviceDetails(name: String, displayName: String, environment: String, vcs
4042
TerraformShouldPanicForSchemaErrors()
4143
ReadOnlySettings()
4244
WorkingDirectory(packageName)
45+
GoCache()
4346
}
4447

4548
triggers {

0 commit comments

Comments
 (0)