Skip to content

Commit a83a3b3

Browse files
authored
chore: deploy limited test resources (#452)
* chore: provide limited test resources for deployment * pr-fix: correct default value * pr-fix: correct connection string key vault secret * pr-fix: pass objectId * pr-fix: pass secret * temp commit * pr-fix: use new deployed resources w/ Arcus.Testing * pr-fix: correct temp event hub * pr-fix: get keys from namespace * pr-fix: correct rg token name * pr-fix: remove unnecessary event model * pr-fix: inject subscription ID * pr-fix: remove unnecessary packages * pr-fix: use correct arcus package * pr-fix: use correct arcus package * pr-fix: use correct arcus package * pr-fix: use correct subscription id * pr-fix: typo subscription id * pr-fix: correct authentication * pr-fix: correct key vault injection * pr-fix: correct managed identity connection * pr-fix: skip for now * pr-fix: more stable assertion
1 parent cd6d613 commit a83a3b3

File tree

60 files changed

+1266
-1788
lines changed

Some content is hidden

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

60 files changed

+1266
-1788
lines changed

build/ci-build.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ parameters:
2121
- name: 'Package.Version.ManualTrigger'
2222
type: string
2323
default: 'preview'
24+
- name: azureServiceConnection
25+
displayName: 'Azure service connection'
26+
type: string
27+
default: 'Azure Codit-Arcus Service Principal'
2428

2529
resources:
2630
repositories:
@@ -30,8 +34,6 @@ resources:
3034
endpoint: arcus-azure
3135

3236
variables:
33-
- group: 'Arcus Messaging - Integration Testing'
34-
- group: 'Arcus - GitHub Package Registry'
3537
- group: 'Build Configuration'
3638
- template: ./variables/build.yml
3739
- template: ./variables/test.yml
@@ -93,35 +95,24 @@ stages:
9395
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
9496
projectName: '$(Project).Tests.Unit'
9597

96-
- stage: SelfContainingIntegrationTests
97-
displayName: Self-Containing Integration Tests
98+
- stage: IntegrationTests
99+
displayName: Integration Tests
98100
dependsOn: Build
99101
condition: succeeded()
100-
variables:
101-
- name: 'Arcus.Health.Port.Queue'
102-
value: '42063'
103102
jobs:
104-
- job: SelfContainingIntegrationTests
105-
displayName: 'Run self-containing integration tests'
103+
- job: RunIntegrationTests
104+
displayName: 'Run integration tests'
106105
pool:
107106
vmImage: '$(Vm.Image)'
108107
steps:
109-
- task: UseDotNet@2
110-
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.PreviousVersion))'
111-
inputs:
112-
packageType: 'sdk'
113-
version: '$(DotNet.Sdk.PreviousVersion)'
114-
- template: test/run-integration-tests.yml@templates
108+
- template: templates/integration-tests.yml
115109
parameters:
116-
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
117-
includePreviewVersions: $(DotNet.Sdk.IncludePreviewVersions)
118-
projectName: '$(Project).Tests.Integration'
119-
category: 'Integration'
110+
azureServiceConnection: ${{ parameters.azureServiceConnection }}
120111

121-
- stage: ReleaseToMyget
112+
- stage: ReleaseToMyGet
122113
displayName: 'Release to MyGet'
123114
dependsOn:
124-
[SelfContainingIntegrationTests, UnitTests]
115+
[IntegrationTests, UnitTests]
125116
condition: succeeded()
126117
jobs:
127118
- job: PushToMyGet

build/deploy-test-resources.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Arcus Messaging - Deploy test resources
2+
3+
trigger: none
4+
pr: none
5+
6+
parameters:
7+
- name: azureServiceConnection
8+
displayName: 'Azure service connection'
9+
type: string
10+
default: 'Azure Codit-Arcus Service Principal'
11+
- name: resourceGroupName
12+
displayName: 'Resource group name'
13+
default: arcus-messaging-dev-we-rg
14+
- name: keyVaultName
15+
displayName: 'Key vault name'
16+
default: 'arcus-messaging-kv'
17+
18+
variables:
19+
- template: ./variables/build.yml
20+
- template: ./variables/test.yml
21+
22+
resources:
23+
repositories:
24+
- repository: templates
25+
type: github
26+
name: arcus-azure/azure-devops-templates
27+
endpoint: arcus-azure
28+
29+
stages:
30+
- stage: Deploy
31+
jobs:
32+
- job: DeployBicep
33+
displayName: 'Deploy test resources'
34+
pool:
35+
vmImage: $(Vm.Image)
36+
steps:
37+
- task: AzureCLI@2
38+
inputs:
39+
azureSubscription: '${{ parameters.azureServiceConnection }}'
40+
addSpnToEnvironment: true
41+
scriptType: 'pscore'
42+
scriptLocation: 'inlineScript'
43+
inlineScript: |
44+
az deployment sub create `
45+
--location westeurope `
46+
--template-file ./build/templates/resource-group.bicep `
47+
--parameters resourceGroupName=$env:ARCUS_MESSAGING_RESOURCEGROUP_NAME `
48+
--parameters location=westeurope
49+
50+
$objectId = (az ad sp show --id $env:servicePrincipalId | ConvertFrom-Json).id
51+
52+
az deployment group create `
53+
--resource-group $env:ARCUS_MESSAGING_RESOURCEGROUP_NAME `
54+
--template-file ./build/templates/test-resources.bicep `
55+
--parameters serviceBusNamespace=$env:ARCUS_MESSAGING_SERVICEBUS_NAMESPACE `
56+
--parameters eventHubsNamespace=$env:ARCUS_MESSAGING_EVENTHUBS_NAMESPACE `
57+
--parameters storageAccountName=$env:ARCUS_MESSAGING_STORAGEACCOUNT_NAME `
58+
--parameters keyVaultName=$env:ARCUS_MESSAGING_KEYVAULT_NAME `
59+
--parameters servicePrincipal_objectId=$objectId
60+
61+
$accountKey = (az storage account keys list --account-name $env:ARCUS_MESSAGING_STORAGEACCOUNT_NAME | ConvertFrom-Json)[0].value
62+
az keyvault secret set `
63+
--name $env:ARCUS_MESSAGING_STORAGEACCOUNT_KEY_SECRETNAME `
64+
--value $accountKey `
65+
--vault-name ${{ parameters.keyVaultName }}
66+
67+
$serviceBusKeys = az servicebus namespace authorization-rule keys list `
68+
--resource-group $env:ARCUS_MESSAGING_RESOURCEGROUP_NAME `
69+
--namespace-name $env:ARCUS_MESSAGING_SERVICEBUS_NAMESPACE `
70+
--authorization-rule-name 'RootManageSharedAccessKey' `
71+
| ConvertFrom-Json
72+
az keyvault secret set `
73+
--name $env:ARCUS_MESSAGING_SERVICEBUS_CONNECTIONSTRING_SECRETNAME `
74+
--value $serviceBusKeys.primaryConnectionString `
75+
--vault-name ${{ parameters.keyVaultName }}
76+
77+
$eventHubsKeys = az eventhubs namespace authorization-rule keys list `
78+
--resource-group $env:ARCUS_MESSAGING_RESOURCEGROUP_NAME `
79+
--namespace-name $env:ARCUS_MESSAGING_EVENTHUBS_NAMESPACE `
80+
--authorization-rule-name 'RootManageSharedAccessKey' `
81+
| ConvertFrom-Json
82+
az keyvault secret set `
83+
--name $env:ARCUS_MESSAGING_EVENTHUBS_CONNECTIONSTRING_SECRETNAME `
84+
--value $eventHubsKeys.primaryConnectionString `
85+
--vault-name ${{ parameters.keyVaultName }}

build/nuget-release.yml

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ pr: none
66
parameters:
77
- name: 'Package.Version'
88
type: 'string'
9+
- name: azureServiceConnection
10+
displayName: 'Azure service connection'
11+
type: string
12+
default: 'Azure Codit-Arcus Service Principal'
913

1014
resources:
1115
repositories:
@@ -15,9 +19,6 @@ resources:
1519
endpoint: arcus-azure
1620

1721
variables:
18-
- group: 'Arcus Messaging - Integration Testing'
19-
- group: 'Arcus Security - Integration Testing'
20-
- group: 'Arcus - GitHub Package Registry'
2122
- group: 'Build Configuration'
2223
- template: ./variables/build.yml
2324
- template: ./variables/test.yml
@@ -79,35 +80,24 @@ stages:
7980
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
8081
projectName: '$(Project).Tests.Unit'
8182

82-
- stage: SelfContainingIntegrationTests
83-
displayName: Self-Containing Integration Tests
83+
- stage: IntegrationTests
84+
displayName: Integration Tests
8485
dependsOn: Build
8586
condition: succeeded()
86-
variables:
87-
- name: 'Arcus.Health.Port.Queue'
88-
value: '42063'
8987
jobs:
90-
- job: SelfContainingIntegrationTests
91-
displayName: 'Run self-containing integration tests'
88+
- job: RunIntegrationTests
89+
displayName: 'Run integration tests'
9290
pool:
9391
vmImage: '$(Vm.Image)'
9492
steps:
95-
- task: UseDotNet@2
96-
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.PreviousVersion))'
97-
inputs:
98-
packageType: 'sdk'
99-
version: '$(DotNet.Sdk.PreviousVersion)'
100-
includePreviewVersions: $(DotNet.Sdk.IncludePreviewVersions)
101-
- template: test/run-integration-tests.yml@templates
93+
- template: templates/integration-tests.yml
10294
parameters:
103-
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
104-
projectName: '$(Project).Tests.Integration'
105-
category: 'Integration'
95+
azureServiceConnection: ${{ parameters.azureServiceConnection }}
10696

10797
- stage: Release
10898
displayName: 'Release to NuGet.org'
10999
dependsOn:
110-
[SelfContainingIntegrationTests , UnitTests]
100+
[IntegrationTests , UnitTests]
111101
condition: succeeded()
112102
jobs:
113103
- job: PushToNuGet

build/templates/build-and-run-az-func-container.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

build/templates/build-and-run-worker-container.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
parameters:
2+
azureServiceConnection: ''
3+
4+
steps:
5+
- task: UseDotNet@2
6+
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.PreviousVersion))'
7+
inputs:
8+
packageType: 'sdk'
9+
version: '$(DotNet.Sdk.PreviousVersion)'
10+
11+
- task: AzureCLI@2
12+
displayName: 'Import secrets from Azure Key Vault'
13+
inputs:
14+
azureSubscription: '${{ parameters.azureServiceConnection }}'
15+
addSpnToEnvironment: true
16+
scriptType: 'pscore'
17+
scriptLocation: 'inlineScript'
18+
inlineScript: |
19+
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
20+
Install-Module -Name Arcus.Scripting.DevOps -AllowClobber -MinimumVersion 1.3.0
21+
22+
$subscriptionId = (az account show | ConvertFrom-Json).id
23+
$objectId = (az ad sp show --id $env:servicePrincipalId | ConvertFrom-Json).id
24+
Set-AzDevOpsVariable -Name 'Arcus.Infra.SubscriptionId' -Value $subscriptionId
25+
Set-AzDevOpsVariable -Name 'Arcus.Infra.TenantId' -Value $env:tenantId -AsSecret
26+
Set-AzDevOpsVariable -Name 'Arcus.Infra.ServicePrincipal.ObjectId' -Value $objectId
27+
Set-AzDevOpsVariable -Name 'Arcus.Infra.ServicePrincipal.ClientId' -Value $env:servicePrincipalId -AsSecret
28+
Set-AzDevOpsVariable -Name 'Arcus.Infra.ServicePrincipal.ClientSecret' -Value $env:servicePrincipalKey -AsSecret
29+
30+
$accountKey = az keyvault secret show --name $env:ARCUS_MESSAGING_STORAGEACCOUNT_KEY_SECRETNAME --vault-name $env:ARCUS_MESSAGING_KEYVAULT_NAME | ConvertFrom-Json
31+
Set-AzDevOpsVariable -Name 'Arcus.Messaging.StorageAccount.Key' -Value $accountKey.value -AsSecret
32+
33+
$serviceBusConnectionString = az keyvault secret show --name $env:ARCUS_MESSAGING_SERVICEBUS_CONNECTIONSTRING_SECRETNAME --vault-name $env:ARCUS_MESSAGING_KEYVAULT_NAME | ConvertFrom-Json
34+
Set-AzDevOpsVariable -Name 'Arcus.Messaging.ServiceBus.ConnectionString' -Value $serviceBusConnectionString.value -AsSecret
35+
36+
$eventHubsConnectionString = az keyvault secret show --name $env:ARCUS_MESSAGING_EVENTHUBS_CONNECTIONSTRING_SECRETNAME --vault-name $env:ARCUS_MESSAGING_KEYVAULT_NAME | ConvertFrom-Json
37+
Set-AzDevOpsVariable -Name 'Arcus.Messaging.EventHubs.ConnectionString' -Value $eventHubsConnectionString.value -AsSecret
38+
39+
- template: test/run-integration-tests.yml@templates
40+
parameters:
41+
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
42+
includePreviewVersions: $(DotNet.Sdk.IncludePreviewVersions)
43+
projectName: '$(Project).Tests.Integration'
44+
category: 'Integration'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Define the name of the resource group.
2+
param resourceGroupName string
3+
4+
// Define the location for the deployment of the components.
5+
param location string
6+
7+
targetScope='subscription'
8+
9+
module resourceGroup 'br/public:avm/res/resources/resource-group:0.2.3' = {
10+
name: 'resourceGroupDeployment'
11+
params: {
12+
name: resourceGroupName
13+
location: location
14+
}
15+
}

0 commit comments

Comments
 (0)