diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 747b2005309f..5f4c6c1344d8 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -1,7 +1,13 @@ parameters: - ServiceDirectory: '' - CoverageGoal: 0.95 - RunTests: false + - name: ServiceDirectory + type: string + default: '' + - name: CoverageGoal + type: string + default: '0.95' + - name: RunTests + type: string + default: false stages: - stage: Build diff --git a/eng/pipelines/templates/jobs/live.tests.yml b/eng/pipelines/templates/jobs/live.tests.yml new file mode 100644 index 000000000000..a8416f618a60 --- /dev/null +++ b/eng/pipelines/templates/jobs/live.tests.yml @@ -0,0 +1,101 @@ +parameters: + - name: ServiceDirectory + type: string + default: '' + - name: EnvVars + type: object + default: {} + - name: TimeoutInMinutes + type: number + default: 60 + - name: PreSteps + type: object + default: [] + - name: PostSteps + type: object + default: [] + - name: CloudConfig + type: object + default: {} + - name: Location + type: string + default: '' + - name: Matrix + type: string + - name: DependsOn + type: string + default: '' + - name: UsePlatformContainer + type: boolean + default: false + +jobs: + - job: + displayName: Live Test on + dependsOn: ${{ parameters.DependsOn }} + condition: ne(${{ parameters.Matrix }}, '{}') + strategy: + maxParallel: 0 + matrix: $[ ${{ parameters.Matrix }} ] + + variables: + - template: ../variables/globals.yml + - name: ArmTemplateParameters + value: '@{}' + + pool: + name: $(Pool) + vmImage: $(OSVmImage) + + timeoutInMinutes: ${{ parameters.TimeoutInMinutes }} + + ${{ if eq(parameters.UsePlatformContainer, 'true') }}: + container: $[ variables['Container'] ] + + steps: + - ${{ parameters.PreSteps }} + + - template: /eng/common/pipelines/templates/steps/verify-agent-os.yml + parameters: + AgentImage: $(OSVmImage) + + - template: /eng/common/TestResources/build-test-resource-config.yml + parameters: + SubscriptionConfiguration: ${{ parameters.CloudConfig.SubscriptionConfiguration }} + SubscriptionConfigurations: ${{ parameters.CloudConfig.SubscriptionConfigurations }} + + - template: /eng/common/TestResources/deploy-test-resources.yml + parameters: + ${{ if or(parameters.Location, parameters.CloudConfig.Location) }}: + Location: ${{ coalesce(parameters.Location, parameters.CloudConfig.Location) }} + ServiceDirectory: ${{ parameters.ServiceDirectory }} + SubscriptionConfiguration: $(SubscriptionConfiguration) + ArmTemplateParameters: $(ArmTemplateParameters) + + - task: GoTool@0 + inputs: + version: '$(GoVersion)' + displayName: "Select Go Version" + + - template: ../steps/create-go-workspace.yml + + - template: ../steps/set-scope.yml + parameters: + ServiceDirectory: ${{ parameters.ServiceDirectory }} + GoWorkspace: $(GO_WORKSPACE_PATH) + + - template: ../steps/build-test.yml + parameters: + ServiceDirectory: ${{ parameters.ServiceDirectory }} + GoWorkspace: $(GO_WORKSPACE_PATH) + Scope: $(SCOPE) + Image: $(OSVmImage) + GoVersion: $(GoVersion) + RunTests: true + + - ${{ parameters.PostSteps }} + + - template: /eng/common/TestResources/remove-test-resources.yml + parameters: + ServiceDirectory: ${{ parameters.ServiceDirectory }} + SubscriptionConfiguration: $(SubscriptionConfiguration) diff --git a/eng/pipelines/templates/stages/archetype-sdk-tests.yml b/eng/pipelines/templates/stages/archetype-sdk-tests.yml new file mode 100644 index 000000000000..9e151940cb9d --- /dev/null +++ b/eng/pipelines/templates/stages/archetype-sdk-tests.yml @@ -0,0 +1,96 @@ +parameters: + - name: ServiceDirectory + type: string + default: '' + - name: Clouds + type: string + default: 'Public' + - name: SupportedClouds + type: string + default: 'Public,UsGov,China' + - name: UnsupportedClouds + type: string + default: '' + - name: PreSteps + type: object + default: [] + - name: PostSteps + type: object + default: [] + - name: TimeoutInMinutes + type: number + default: 60 + - name: Location + type: string + default: '' + - name: CloudConfig + type: object + default: + Public: + SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources) + Preview: + SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources-preview) + Canary: + SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources) + Location: 'centraluseuap' + UsGov: + SubscriptionConfiguration: $(sub-config-gov-test-resources) + China: + SubscriptionConfiguration: $(sub-config-cn-test-resources) + - name: MatrixConfigs + type: object + default: + - Name: Go_live_test_base + Path: eng/pipelines/templates/stages/platform-matrix.json + Selection: all + GenerateVMJobs: true + - name: AdditionalMatrixConfigs + type: object + default: [] + - name: MatrixFilters + type: object + default: [] + - name: MatrixReplace + type: object + default: [] + +stages: +- ${{ each cloud in parameters.CloudConfig }}: + # Run all clouds by default for weekly test pipeline, except for clouds specifically unsupported by the calling pipeline + # - ${{ if or(contains(parameters.Clouds, cloud.key), contains(variables['Build.DefinitionName'], 'tests-weekly')) }}: + - ${{ if or(contains(parameters.Clouds, cloud.key), and(contains(variables['Build.DefinitionName'], 'tests-weekly'), contains(parameters.SupportedClouds, cloud.key))) }}: + - ${{ if not(contains(parameters.UnsupportedClouds, cloud.key)) }}: + - stage: ${{ cloud.key }} + dependsOn: [] + jobs: + - template: /eng/common/pipelines/templates/jobs/archetype-sdk-tests-generate.yml + parameters: + JobTemplatePath: /eng/pipelines/templates/jobs/live.tests.yml + AdditionalParameters: + ServiceDirectory: ${{ parameters.ServiceDirectory }} + EnvVars: ${{ parameters.EnvVars }} + TimeoutInMinutes: ${{ parameters.TimeoutInMinutes }} + Location: ${{ parameters.Location }} + PreSteps: + - ${{ parameters.PreSteps }} + PostSteps: + - ${{ parameters.PostSteps }} + MatrixConfigs: + # Enumerate platforms and additional platforms based on supported clouds (sparse platform<-->cloud matrix). + - ${{ each config in parameters.MatrixConfigs }}: + - ${{ config }} + - ${{ each config in parameters.AdditionalMatrixConfigs }}: + - ${{ config }} + MatrixFilters: + - ${{ each cloudFilter in cloud.value.MatrixFilters }}: + - ${{ cloudFilter }} + - ${{ parameters.MatrixFilters }} + MatrixReplace: + - ${{ each cloudReplace in cloud.value.MatrixReplace }}: + - ${{ cloudReplace }} + - ${{ parameters.MatrixReplace }} + CloudConfig: + SubscriptionConfiguration: ${{ cloud.value.SubscriptionConfiguration }} + SubscriptionConfigurations: ${{ cloud.value.SubscriptionConfigurations }} + Location: ${{ coalesce(parameters.Location, cloud.value.Location) }} + Cloud: ${{ cloud.key }} diff --git a/eng/pipelines/templates/stages/platform-matrix.json b/eng/pipelines/templates/stages/platform-matrix.json new file mode 100644 index 000000000000..a2b589ed2349 --- /dev/null +++ b/eng/pipelines/templates/stages/platform-matrix.json @@ -0,0 +1,18 @@ +{ + "matrix": { + "Agent": { + "ubuntu-20.04": { + "OSVmImage": "MMSUbuntu20.04", + "Pool": "azsdk-pool-mms-ubuntu-2004-general" + }, + "windows-2019": { + "OSVmImage": "MMS2019", + "Pool": "azsdk-pool-mms-win-2019-general" + } + }, + "GoVersion": [ + "1.16.7", + "1.17" + ] + } +} diff --git a/eng/pipelines/templates/steps/build-test.yml b/eng/pipelines/templates/steps/build-test.yml index 3fb124547094..8356e4d0ddc5 100644 --- a/eng/pipelines/templates/steps/build-test.yml +++ b/eng/pipelines/templates/steps/build-test.yml @@ -1,13 +1,27 @@ parameters: - ServiceDirectory: '' - GoWorkspace: '' - Scope: 'sdk/...' - Image: '' - GoVersion: '' - RunTests: false + - name: ServiceDirectory + type: string + default: '' + - name: GoWorkspace + type: string + default: '' + - name: Scope + type: string + default: 'sdk/...' + - name: Image + type: string + default: '' + - name: GoVersion + type: string + default: '' + - name: RunTests + type: boolean + default: false + - name: EnvVars + type: object + default: {} steps: - - pwsh: ./eng/scripts/build.ps1 displayName: 'Build' workingDirectory: '${{parameters.GoWorkspace}}' @@ -48,6 +62,7 @@ steps: workingDirectory: '${{parameters.GoWorkspace}}' env: GO111MODULE: 'on' + ${{ insert }}: ${{ parameters.EnvVars }} - pwsh: ../eng/scripts/create_coverage.ps1 ${{parameters.ServiceDirectory}} displayName: 'Generate Coverage XML'