docs: added sample yaml pipelines

This commit is contained in:
Pratik Bhattacharya 2021-12-19 17:51:37 +05:30
Родитель 1d63476972
Коммит b4b840221c
2 изменённых файлов: 223 добавлений и 0 удалений

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

@ -0,0 +1,124 @@
resources:
repositories:
- repository: FeatureFlightingGithub
type: github
endpoint: github.com
name: microsoft/FeatureFlightingManagement
trigger:
- main
variables:
BuildPlatform: 'any cpu'
BuildConfiguration: 'release'
stages:
- stage: Build
jobs:
- job: Build
displayName: "Build & Publish Artifact"
pool:
vmImage: vs2017-win2016
steps:
- checkout: FeatureFlightingGithub
- checkout: self
- task: NuGetToolInstaller@1
displayName: Use NuGet 4.3.0
inputs:
versionSpec: 4.3.0
checkLatest: true
- task: UseDotNet@2
displayName: Use .Net Core sdk 3.1.x
inputs:
version: 3.1.x
includePreviewVersions: true
- task: DotNetCoreCLI@2
displayName: Restore API (Microsoft.FeatureFlighting.sln)
inputs:
command: restore
projects: '**/Microsoft.FeatureFlighting.sln'
- task: DotNetCoreCLI@2
displayName: Build API (Microsoft.FeatureFlighting.sln)
inputs:
projects: '**/Microsoft.FeatureFlighting.sln'
- task: DotNetCoreCLI@2
displayName: Test API (*.Tests.csproj)
continueOnError: false
inputs:
command: test
projects: '**/*Tests.csproj'
- task: DotNetCoreCLI@2
displayName: Publish API (Microsoft.FeatureFlighting.sln)
inputs:
command: publish
publishWebProjects: false
projects: '**/Microsoft.FeatureFlighting.API.csproj'
arguments: --output $(Build.artifactstagingdirectory)
- task: DotNetCoreCLI@2
displayName: Restore Functional Tests (Microsoft.FeatureFlighting.Tests.Functional.sln)
inputs:
command: restore
projects: '**/Microsoft.FeatureFlighting.Tests.Functional.sln'
- task: DotNetCoreCLI@2
displayName: Build Functional Tests (Microsoft.FeatureFlighting.Tests.Functional.sln)
inputs:
projects: '**/Microsoft.FeatureFlighting.Tests.Functional.sln'
- task: DotNetCoreCLI@2
displayName: Publish Functional Tests (Microsoft.FeatureFlighting.Tests.Functional.sln)
inputs:
command: publish
publishWebProjects: false
projects: tests/functional/Tests/Microsoft.FeatureFlighting.Tests.Functional.csproj
arguments: --output $(Build.artifactstagingdirectory)
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
- stage: Pre_Prod_Deploy
dependsOn:
- Build
condition: succeeded('Build')
jobs:
- deployment: Pre_Prod_Deploy_EUS
displayName: Pre-Production Deployment EUS
pool:
name: Azure Pipelines
vmImage: 'vs2017-win2016'
demands: vstest
variables:
KeyVault: '__KEY_VAULT_NAME__'
AppService: '__APP_SERVICE_NAME (not the URL, just the name)__'
AppService-Staging: '__APP_SERVICE_STAGING_NAME__'
ResourceGroup: '__RESOURCE_GROUP_NAME__'
environment: '__VSO_ENVIRONMENT__'
strategy:
runOnce:
deploy:
steps:
- powershell: |
[string] $branchName = "refs/heads/master"
[string] $branchNameHotfix = "hotfix"
if ($env:BUILD_SOURCEBRANCH -eq $branchName -Or $env:BUILD_SOURCEBRANCH -contains $branchNameHotfix)
{
Write-Host $branchName "branch check passed. Release triggered" from $env:BUILD_SOURCEBRANCH branch.
}
else
{
[string] $text1 = "##vso[task.logissue type=error;]"
[string] $text2 = "Branch Policy Violation:"
[string] $text3 = " !="
[string] $text4 = "branch. Deployment stopped from"
[string] $text5 = "branch."
Write-Host "$text1 $text2 $env:BUILD_SOURCEBRANCH $text3 $branchName $text4 $env:BUILD_SOURCEBRANCH $text5"
exit 1
}
displayName: 'Stop Release if not from master branch'
enabled: true
- template: templates/app-service-deploy.yml
parameters:
KeyVault: $(KeyVault)
AppService: $(AppService)
ResourceGroup: $(ResourceGroup)
FunctionalTestRunSettingsFile: 'PreProduction.runsettings'
AppServiceStaging: $(AppService-Staging)
DeploymentAppSettings: 'AppConfiguration:ConfigurationCommonLabel Feature-Flight-Management-Config -AppConfiguration:ConfigurationEnvLabel Feature-Flight-Management-Config-PPE -AppConfiguration:FeatureFlightsLabel PPE -Keyvault:Name: $(KeyVault) -Keyvault:EndpointUrl https://$(KeyVault).azure.net/ -FeatureManagement:* true'

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

@ -0,0 +1,99 @@
parameters:
- name: KeyVault
type: string
- name: AppService
type: string
- name: ResourceGroup
type: string
- name: FunctionalTestRunSettingsFile
type: string
- name: AppServiceStaging
type: string
- name: DeploymentAppSettings
type: string
steps:
- checkout: self
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'all'
downloadPath: '$(System.ArtifactsDirectory)'
- task: 7zExtract@1
enabled: false
displayName: 'Extract Functional Tests package'
inputs:
Archive: '$(System.ArtifactsDirectory)/drop/Microsoft.FXP.Flighting.Tests.FunctionalTest.zip'
Folder: '$(System.ArtifactsDirectory)/drop/FunctionalTests'
- task: UseDotNet@2
displayName: 'Use .Net Core sdk 3.1.x'
inputs:
version: 3.1.x
- task: AzureKeyVault@1
displayName: 'Azure Key Vault: Download Secrets'
inputs:
azureSubscription: 'FXP-Azure-Subscription (SPA)'
KeyVaultName: '${{parameters.KeyVault}}'
SecretsFilter: 'Authentication-Secret'
- task: AzureAppServiceManage@0
displayName: 'Stop Azure App Service: ${{parameters.AppService}} Staging'
inputs:
azureSubscription: 'FXP-Azure-Subscription (SPA)'
Action: 'Stop Azure App Service'
WebAppName: '${{parameters.AppService}}'
SpecifySlotOrASE: true
ResourceGroupName: '${{parameters.ResourceGroup}}'
Slot: staging
- task: AzureRmWebAppDeployment@4
displayName: 'Azure App Service Deploy: ${{parameters.AppService}} Staging'
inputs:
azureSubscription: 'FXP-Azure-Subscription (SPA)'
WebAppName: '${{parameters.AppService}}'
deployToSlotOrASE: true
ResourceGroupName: '${{parameters.ResourceGroup}}'
SlotName: staging
packageForLinux: '$(System.ArtifactsDirectory)/drop/Api.zip'
AppSettings: '${{parameters.DeploymentAppSettings}}'
enableCustomDeployment: true
DeploymentType: zipDeploy
- task: AzureAppServiceManage@0
displayName: 'Start Azure App Service: ${{parameters.AppService}} Staging'
inputs:
azureSubscription: 'FXP-Azure-Subscription (SPA)'
Action: 'Start Azure App Service'
WebAppName: '${{parameters.AppService}}'
SpecifySlotOrASE: true
ResourceGroupName: '${{parameters.ResourceGroup}}'
Slot: staging
- powershell: |
'Start-Sleep -Seconds 60'
displayName: 'Pause: 1 min (Warming up app service)'
- task: VSTest@2
displayName: 'Test Staging'
inputs:
testAssemblyVer2: |
**\Microsoft.FeatureFlighting.Tests.Functional.dll
**\Microsoft.FeatureFlighting.Tests.Functional.runtimeconfig
searchFolder: '$(System.ArtifactsDirectory)/drop/FunctionalTests'
runSettingsFile: '$(System.DefaultWorkingDirectory)/tests/functional/Tests/${{parameters.FunctionalTestRunSettingsFile}}'
overrideTestrunParameters: '-FunctionalTest:InvalidAAD:ClientSecret "$(MS-Graph-Secret)" -FunctionalTest:AAD:ClientSecret "$(Authentication-Secret)" -FunctionalTest:FxpFlighting:Endpoint https://${{parameters.AppServiceStaging}}.azurewebsites.net'
runInParallel: true
runTestsInIsolation: true
otherConsoleOptions: '/Framework:.NETCoreApp,Version=v3.1'
rerunFailedTests: true
- task: AzureAppServiceManage@0
displayName: 'Swap Azure App Service: ${{parameters.AppService}}'
inputs:
azureSubscription: 'FXP-Azure-Subscription (SPA)'
WebAppName: '${{parameters.AppService}}'
ResourceGroupName: '${{parameters.ResourceGroup}}'
SourceSlot: staging