Switch CI build to use yaml and docker (#978)

Add new build scripts for CI build that use docker
This commit is contained in:
Robert Johnson 2020-05-07 16:43:58 -04:00 коммит произвёл GitHub
Родитель 0549def1b7
Коммит 67925fe17c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
20 изменённых файлов: 370 добавлений и 61 удалений

Просмотреть файл

@ -2,7 +2,7 @@
A .NET Core implementation of the FHIR standard.
[![CI Status](https://microsofthealthoss.vsrm.visualstudio.com/_apis/public/Release/badge/7621b231-1a7d-4364-935b-2f72b911c43d/1/1)](https://microsofthealthoss.visualstudio.com/FhirServer/_releases2)
[![Build Status](https://microsofthealthoss.visualstudio.com/FhirServer/_apis/build/status/CI%20Build%20%26%20Deploy?branchName=master)](https://microsofthealthoss.visualstudio.com/FhirServer/_build/latest?definitionId=27&branchName=master)
FHIR Server for Azure is an open-source implementation of the emerging[HL7 Fast Healthcare Interoperability Resources (FHIR) specification](https://www.hl7.org/fhir/)designed for the Microsoft cloud. The FHIR specification defines how clinical health data can be made interoperable across systems, and the FHIR Server for Azure helps facilitate that interoperability in the cloud. The goal of this Microsoft Healthcare project is to enable developers to rapidly deploy a FHIR service.

Просмотреть файл

@ -1,24 +0,0 @@
# DESCRIPTION:
# Builds, tests and packages the solution for the CI build configuration.
name: $(SourceBranchName)-$(Date:yyyyMMdd)$(Rev:-r)
variables:
- template: build-variables.yml
jobs:
- job: Windows
pool:
vmImage: 'windows-2019'
steps:
- template: build.yml
- job: Linux
pool:
vmImage: 'ubuntu-latest'
steps:
- template: build.yml
parameters:
packageArtifacts: false
- template: docker-build-all.yml
parameters:
tag: $(build.sourceBranchName)

Просмотреть файл

@ -28,4 +28,4 @@ jobs:
& build/Update-Packages.ps1 -PackageName "Hl7.Fhir.Stu3" -PackageVersion $packageStu3Version | Out-Null
& build/Update-Packages.ps1 -PackageName "Hl7.Fhir.R4" -PackageVersion $packageR4Version | Out-Null
workingDirectory: $(Build.SourcesDirectory)
- template: build.yml
- template: ./jobs/build.yml

Просмотреть файл

@ -6,3 +6,20 @@ variables:
azureSubscriptionEndpoint: 'docker-build'
azureContainerRegistry: 'healthplatformregistry.azurecr.io'
composeLocation: 'build/docker/docker-compose.yaml'
DeploymentEnvironmentNameSql: '$(DeploymentEnvironmentName)-sql'
DeploymentEnvironmentNameR4: '$(DeploymentEnvironmentName)-r4'
DeploymentEnvironmentNameR4Sql: '$(DeploymentEnvironmentNameR4)-sql'
DeploymentEnvironmentNameR5: '$(DeploymentEnvironmentName)-r5'
DeploymentEnvironmentNameR5Sql: '$(DeploymentEnvironmentNameR5)-sql'
TestEnvironmentUrl: 'https://$(DeploymentEnvironmentName).azurewebsites.net'
# These variables are not used in the deployment scripts, but are used in the E2E tests files.
TestEnvironmentUrl_Sql: 'https://$(DeploymentEnvironmentName)-sql.azurewebsites.net'
TestEnvironmentUrl_R4: 'https://$(DeploymentEnvironmentName)-r4.azurewebsites.net'
TestEnvironmentUrl_R4_Sql: 'https://$(DeploymentEnvironmentName)-r4-sql.azurewebsites.net'
TestEnvironmentUrl_R5: 'https://$(DeploymentEnvironmentName)-r5.azurewebsites.net'
TestEnvironmentUrl_R5_Sql: 'https://$(DeploymentEnvironmentName)-r5-sql.azurewebsites.net'
#-----------------------------------------------------------------------------------------
CrucibleEnvironmentUrl: 'https://crucible.mshapis.com/'
TestClientUrl: 'https://$(DeploymentEnvironmentName)-client/'
ConnectedServiceName: 'Microsoft Health Open Source Subscription'
WindowsVmImage: 'windows-latest'

148
build/ci-deploy.yml Normal file
Просмотреть файл

@ -0,0 +1,148 @@
# DESCRIPTION:
# Deploys the CI environment in case the persistant resources are deleted or broken.
name: $(SourceBranchName)-$(Date:yyyyMMdd)$(Rev:-r)
trigger: none
variables:
- template: ci-variables.yml
- template: build-variables.yml
stages:
- stage: DockerBuild
displayName: 'Build images'
dependsOn: []
jobs:
- template: ./jobs/docker-build-all.yml
parameters:
tag: $(ImageTag)
- stage: provisionEnvironment
displayName: Provision Environment
dependsOn: []
jobs:
- template: ./jobs/cleanup.yml
- job: provision
dependsOn: DeleteResourceGroup
steps:
- task: AzurePowerShell@4
displayName: Provision Resource Group
inputs:
azureSubscription: $(ConnectedServiceName)
azurePowerShellVersion: latestVersion
ScriptType: inlineScript
Inline: |
New-AzResourceGroup -Name "$(DeploymentEnvironmentName)" -Location "$(ResourceGroupRegion)" -Force
- stage: aadTestEnvironment
displayName: Setup AAD Test Environment
dependsOn:
- provisionEnvironment
- DockerBuild
jobs:
- template: ./jobs/add-aad-test-environment.yml
- stage: deployStu3
displayName: 'Deploy STU3 Site'
dependsOn:
- provisionEnvironment
- DockerBuild
jobs:
- template: ./jobs/provision-deploy.yml
parameters:
version: Stu3
webAppName: $(DeploymentEnvironmentName)
appServicePlanName: $(appServicePlanName)
appServicePlanResourceGroup: $(appServicePlanResourceGroup)
subscription: $(ConnectedServiceName)
resourceGroup: $(DeploymentEnvironmentName)
testEnvironmentUrl: $(TestEnvironmentUrl)
imageTag: $(ImageTag)
- stage: deployStu3Sql
displayName: 'Deploy STU3 SQL Site'
dependsOn:
- provisionEnvironment
- DockerBuild
jobs:
- template: ./jobs/provision-deploy.yml
parameters:
version: Stu3
sql: true
webAppName: $(DeploymentEnvironmentNameSql)
appServicePlanName: $(appServicePlanName)
appServicePlanResourceGroup: $(appServicePlanResourceGroup)
subscription: $(ConnectedServiceName)
resourceGroup: $(DeploymentEnvironmentName)
testEnvironmentUrl: $(TestEnvironmentUrl)
imageTag: $(ImageTag)
- stage: deployR4
displayName: 'Deploy R4 Site'
dependsOn:
- provisionEnvironment
- DockerBuild
jobs:
- template: ./jobs/provision-deploy.yml
parameters:
version: R4
webAppName: $(DeploymentEnvironmentNameR4)
appServicePlanName: $(appServicePlanName)
appServicePlanResourceGroup: $(appServicePlanResourceGroup)
subscription: $(ConnectedServiceName)
resourceGroup: $(DeploymentEnvironmentName)
testEnvironmentUrl: $(TestEnvironmentUrl)
imageTag: $(ImageTag)
- stage: deployR4Sql
displayName: 'Deploy R4 SQL Site'
dependsOn:
- provisionEnvironment
- DockerBuild
jobs:
- template: ./jobs/provision-deploy.yml
parameters:
version: R4
sql: true
webAppName: $(DeploymentEnvironmentNameR4Sql)
appServicePlanName: $(appServicePlanName)
appServicePlanResourceGroup: $(appServicePlanResourceGroup)
subscription: $(ConnectedServiceName)
resourceGroup: $(DeploymentEnvironmentName)
testEnvironmentUrl: $(TestEnvironmentUrl)
imageTag: $(ImageTag)
- stage: deployR5
displayName: 'Deploy R5 Site'
dependsOn:
- provisionEnvironment
- DockerBuild
jobs:
- template: ./jobs/provision-deploy.yml
parameters:
version: R5
webAppName: $(DeploymentEnvironmentNameR5)
appServicePlanName: $(appServicePlanName)
appServicePlanResourceGroup: $(appServicePlanResourceGroup)
subscription: $(ConnectedServiceName)
resourceGroup: $(DeploymentEnvironmentName)
testEnvironmentUrl: $(TestEnvironmentUrl)
imageTag: $(ImageTag)
- stage: deployR5Sql
displayName: 'Deploy R5 SQL Site'
dependsOn:
- provisionEnvironment
- DockerBuild
jobs:
- template: ./jobs/provision-deploy.yml
parameters:
version: R5
sql: true
webAppName: $(DeploymentEnvironmentNameR5Sql)
appServicePlanName: $(appServicePlanName)
appServicePlanResourceGroup: $(appServicePlanResourceGroup)
subscription: $(ConnectedServiceName)
resourceGroup: $(DeploymentEnvironmentName)
testEnvironmentUrl: $(TestEnvironmentUrl)
imageTag: $(ImageTag)

160
build/ci-pipeline.yml Normal file
Просмотреть файл

@ -0,0 +1,160 @@
# DESCRIPTION:
# Builds, tests, and packages the solution for all PR requests.
name: $(SourceBranchName)-$(Date:yyyyMMdd)$(Rev:-r)
trigger: none
variables:
- template: ci-variables.yml
- template: build-variables.yml
stages:
- stage: BuildUnitTests
displayName: 'Build and run unit tests'
dependsOn: []
jobs:
- job: Windows
pool:
vmImage: $(WindowsVmImage)
steps:
- template: ./jobs/build.yml
- job: Linux
pool:
vmImage: 'ubuntu-latest'
steps:
- template: ./jobs/build.yml
parameters:
packageArtifacts: false
- stage: DockerBuild
displayName: 'Build images'
dependsOn: []
jobs:
- template: ./jobs/docker-build-all.yml
parameters:
tag: $(ImageTag)
- stage: redeployStu3
displayName: 'Redeploy STU3 Site'
dependsOn:
- DockerBuild
jobs:
- template: ./jobs/redeploy-webapp.yml
parameters:
version: Stu3
webAppName: $(DeploymentEnvironmentName)
subscription: $(ConnectedServiceName)
imageTag: $(ImageTag)
- stage: redeployStu3Sql
displayName: 'Redeploy STU3 SQL Site'
dependsOn:
- DockerBuild
jobs:
- template: ./jobs/redeploy-webapp.yml
parameters:
version: Stu3
webAppName: $(DeploymentEnvironmentNameSql)
subscription: $(ConnectedServiceName)
imageTag: $(ImageTag)
- stage: redeployR4
displayName: 'Redeploy R4 Site'
dependsOn:
- DockerBuild
jobs:
- template: ./jobs/redeploy-webapp.yml
parameters:
version: R4
webAppName: $(DeploymentEnvironmentNameR4)
subscription: $(ConnectedServiceName)
imageTag: $(ImageTag)
- stage: redeployR4Sql
displayName: 'Redeploy R4 SQL Site'
dependsOn:
- DockerBuild
jobs:
- template: ./jobs/redeploy-webapp.yml
parameters:
version: R4
webAppName: $(DeploymentEnvironmentNameR4Sql)
subscription: $(ConnectedServiceName)
imageTag: $(ImageTag)
- stage: redeployR5
displayName: 'Redeploy R5 Site'
dependsOn:
- DockerBuild
jobs:
- template: ./jobs/redeploy-webapp.yml
parameters:
version: R5
webAppName: $(DeploymentEnvironmentNameR5)
subscription: $(ConnectedServiceName)
imageTag: $(ImageTag)
- stage: redeployR5Sql
displayName: 'Redeploy R5 SQL Site'
dependsOn:
- DockerBuild
jobs:
- template: ./jobs/redeploy-webapp.yml
parameters:
version: R5
webAppName: $(DeploymentEnvironmentNameR5Sql)
subscription: $(ConnectedServiceName)
imageTag: $(ImageTag)
- stage: testStu3
displayName: 'Run Stu3 Tests'
dependsOn:
- BuildUnitTests
- redeployStu3
- redeployStu3Sql
jobs:
- template: ./jobs/run-tests.yml
parameters:
version: Stu3
keyVaultName: $(DeploymentEnvironmentName)
- stage: testR4
displayName: 'Run R4 Tests'
dependsOn:
- BuildUnitTests
- redeployR4
- redeployR4Sql
jobs:
- template: ./jobs/run-tests.yml
parameters:
version: R4
keyVaultName: $(DeploymentEnvironmentNameR4)
- stage: testR5
displayName: 'Run R5 Tests'
dependsOn:
- BuildUnitTests
- redeployR5
- redeployR5Sql
jobs:
- template: ./jobs/run-tests.yml
parameters:
version: R5
keyVaultName: $(DeploymentEnvironmentNameR5)
- stage: securityScan
displayName: Security Scan
dependsOn: []
jobs:
- job: runScan
pool:
vmImage: $(WindowsVmImage)
steps:
- task: securedevelopmentteam.vss-secure-development-tools.build-task-antimalware.AntiMalware@3
displayName: 'Run MpCmdRun.exe'
inputs:
FileDirPath: '$(System.ArtifactsDirectory)'
EnableServices: true
SignatureFreshness: OneDay
TreatStaleSignatureAs: Warning

7
build/ci-variables.yml Normal file
Просмотреть файл

@ -0,0 +1,7 @@
variables:
ResourceGroupRegion: 'southcentralus'
resourceGroupRoot: 'msh-fhir-ci'
appServicePlanName: '$(resourceGroupRoot)-linux'
DeploymentEnvironmentName: '$(resourceGroupRoot)'
TestEnvironmentName: 'OSS CI'
ImageTag: '$(build.BuildNumber)'

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,7 +1,6 @@
steps:
# Package web
# ------Can be removed once CI uses docker---------------
- template: package-web.yml
parameters:
csproj: '**/Microsoft.Health.Fhir.Stu3.Web.csproj'
@ -13,7 +12,7 @@ steps:
- template: package-web.yml
parameters:
csproj: '**/Microsoft.Health.Fhir.R5.Web.csproj'
# -------------------------------------------------------
- task: DotNetCoreCLI@2
displayName: 'dotnet publish Integration Tests'
inputs:
@ -38,7 +37,6 @@ steps:
nuget_version: 1.0.0-$(build.buildNumber)
# Publish artifacts
# ------Can be removed once CI uses docker---------------
- task: PublishBuildArtifacts@1
displayName: 'publish web artifacts'
inputs:
@ -80,7 +78,6 @@ steps:
pathToPublish: './release/'
artifactName: 'deploy'
artifactType: 'container'
# -------------------------------------------------------
- task: PublishBuildArtifacts@1
displayName: 'publish nuget artifacts'
@ -95,5 +92,3 @@ steps:
pathToPublish: '$(build.binariesdirectory)/IntegrationTests'
artifactName: 'IntegrationTests'
artifactType: 'container'
parallel: true
parallelCount: 8

Просмотреть файл

@ -0,0 +1,24 @@
parameters:
- name: version
type: string
- name: webAppName
type: string
- name: subscription
type: string
- name: imageTag
type: string
jobs:
- job: provisionEnvironment
pool:
vmImage: $(WindowsVmImage)
steps:
- task: AzureRmWebAppDeployment@4
displayName: 'Azure App Service Deploy'
inputs:
azureSubscription: '${{ parameters.subscription }}'
appType: 'webAppContainer'
WebAppName: '${{ parameters.webAppName }}'
DockerNamespace: $(azureContainerRegistry)
DockerRepository: '${{ parameters.version }}_fhir-server'
DockerImageTag: ${{ parameters.imageTag }}

Просмотреть файл

@ -5,8 +5,8 @@ name: pr$(system.pullRequest.pullRequestNumber)-$(Date:yyyyMMdd)$(Rev:-r)
trigger: none
variables:
- template: build-variables.yml
- template: pr-variables.yml
- template: build-variables.yml
stages:
- stage: BuildUnitTests
@ -17,13 +17,13 @@ stages:
pool:
vmImage: $(WindowsVmImage)
steps:
- template: build.yml
- template: ./jobs/build.yml
- job: Linux
pool:
vmImage: 'ubuntu-latest'
steps:
- template: build.yml
- template: ./jobs/build.yml
parameters:
packageArtifacts: false
@ -31,7 +31,7 @@ stages:
displayName: 'Build images'
dependsOn: []
jobs:
- template: docker-build-all.yml
- template: ./jobs/docker-build-all.yml
parameters:
tag: $(ImageTag)

Просмотреть файл

@ -1,26 +1,8 @@
variables:
ConnectedServiceName: 'Microsoft Health Open Source Subscription'
ResourceGroupRegion: 'southcentralus'
resourceGroupRoot: 'msh-fhir-pr'
appServicePlanResourceGroup: '$(resourceGroupRoot)-$(prNumber)'
appServicePlanName: '$(resourceGroupRoot)-$(prNumber)-asp'
prNumber: $(system.pullRequest.pullRequestNumber)
DeploymentEnvironmentName: '$(resourceGroupRoot)-$(prNumber)'
DeploymentEnvironmentNameSql: '$(DeploymentEnvironmentName)-sql'
DeploymentEnvironmentNameR4: '$(DeploymentEnvironmentName)-r4'
DeploymentEnvironmentNameR4Sql: '$(DeploymentEnvironmentNameR4)-sql'
DeploymentEnvironmentNameR5: '$(DeploymentEnvironmentName)-r5'
DeploymentEnvironmentNameR5Sql: '$(DeploymentEnvironmentNameR5)-sql'
CrucibleEnvironmentUrl: 'https://crucible.mshapis.com/'
TestEnvironmentUrl: 'https://$(DeploymentEnvironmentName).azurewebsites.net'
# These variables are not used in the deployment scripts, but are used in the E2E tests files.
TestEnvironmentUrl_Sql: 'https://$(DeploymentEnvironmentName)-sql.azurewebsites.net'
TestEnvironmentUrl_R4: 'https://$(DeploymentEnvironmentName)-r4.azurewebsites.net'
TestEnvironmentUrl_R4_Sql: 'https://$(DeploymentEnvironmentName)-r4-sql.azurewebsites.net'
TestEnvironmentUrl_R5: 'https://$(DeploymentEnvironmentName)-r5.azurewebsites.net'
TestEnvironmentUrl_R5_Sql: 'https://$(DeploymentEnvironmentName)-r5-sql.azurewebsites.net'
#-----------------------------------------------------------------------------------------
TestClientUrl: 'https://$(DeploymentEnvironmentName)-client/'
TestEnvironmentName: 'OSS PR$(prNumber)'
WindowsVmImage: 'windows-latest'
ImageTag: 'pr$(prNumber)'
ImageTag: '$(build.BuildNumber)'

Просмотреть файл

Просмотреть файл

@ -133,7 +133,7 @@
},
"imageTag": {
"type": "string",
"defaultValue": "latest",
"defaultValue": "release",
"metadata": {
"description": "Tag of the docker image to deploy."
}
@ -384,7 +384,7 @@
{
"type": "Microsoft.Storage/storageAccounts/providers/roleAssignments",
"apiVersion": "2018-09-01-preview",
"name": "[concat(variables('storageAccountName'), '/Microsoft.Authorization/', guid(uniqueString(variables('storageAccountName'), parameters('fhirVersion'), variables('serviceName'))))]",
"name": "[concat(variables('storageAccountName'), '/Microsoft.Authorization/', guid(variables('storageAccountName'), parameters('fhirVersion'), variables('serviceName')))]",
"condition": "[parameters('enableExport')]",
"dependsOn": [
"[variables('storageAccountName')]",

Просмотреть файл

@ -129,7 +129,7 @@
},
"imageTag": {
"type": "string",
"defaultValue": "latest",
"defaultValue": "release",
"metadata": {
"description": "Tag of the docker image to deploy."
}
@ -362,7 +362,7 @@
{
"type": "Microsoft.Storage/storageAccounts/providers/roleAssignments",
"apiVersion": "2018-09-01-preview",
"name": "[concat(variables('storageAccountName'), '/Microsoft.Authorization/', guid(uniqueString(variables('storageAccountName'), parameters('fhirVersion'), variables('serviceName'))))]",
"name": "[concat(variables('storageAccountName'), '/Microsoft.Authorization/', guid(variables('storageAccountName'), parameters('fhirVersion'), variables('serviceName')))]",
"condition": "[parameters('enableExport')]",
"dependsOn": [
"[variables('storageAccountName')]",

Просмотреть файл

@ -171,7 +171,7 @@
},
"combinedFhirServerConfigProperties": "[union(variables('staticFhirServerConfigProperties'), parameters('additionalFhirServerConfigProperties'))]",
"computedSqlServerReference": "[concat('Microsoft.Sql/servers/', variables('serviceName'))]",
"storageAccountName": "[concat(substring(replace(variables('serviceName'), '-', ''), 0, min(11, length(variables('serviceName')))), uniquestring(resourceGroup().id, variables('serviceName')))]"
"storageAccountName": "[concat(substring(replace(variables('serviceName'), '-', ''), 0, min(11, length(replace(variables('serviceName'), '-', '')))), uniquestring(resourceGroup().id, variables('serviceName')))]"
},
"resources": [
{

Просмотреть файл

@ -165,7 +165,7 @@
"FhirServer:Operations:Export:StorageAccountUri": "[if(parameters('enableExport'), concat('https://', variables('storageAccountName'), variables('blobStorageUri')), 'null')]"
},
"combinedFhirServerConfigProperties": "[union(variables('staticFhirServerConfigProperties'), parameters('additionalFhirServerConfigProperties'))]",
"storageAccountName": "[concat(substring(replace(variables('serviceName'), '-', ''), 0, min(11, length(variables('serviceName')))), uniquestring(resourceGroup().id, variables('serviceName')))]"
"storageAccountName": "[concat(substring(replace(variables('serviceName'), '-', ''), 0, min(11, length(replace(variables('serviceName'), '-', '')))), uniquestring(resourceGroup().id, variables('serviceName')))]"
},
"resources": [
{