From 7cfe1837f20f82564a98154846b416b9b631d8d4 Mon Sep 17 00:00:00 2001 From: Scott Beddall <45376673+scbedd@users.noreply.github.com> Date: Fri, 29 Oct 2021 18:00:37 -0700 Subject: [PATCH] Handling Proper Defaulting of `BuildTargetingString` within nested templates (#21426) * adding targeting-string-resolve.yml and calling at the root of each "job" in our pipeline. The BuildTargetingString should apply appropriately in all cases now. --- eng/pipelines/templates/jobs/ci.tests.yml | 6 +++-- eng/pipelines/templates/jobs/ci.yml | 15 ++++++++--- eng/pipelines/templates/jobs/live.tests.yml | 7 ++--- .../templates/stages/archetype-sdk-client.yml | 5 +--- eng/pipelines/templates/steps/analyze.yml | 27 ++++++------------- .../templates/steps/build-artifacts.yml | 19 ++++++++----- eng/pipelines/templates/steps/build-test.yml | 12 ++++++--- eng/pipelines/templates/steps/run_apistub.yml | 9 +++++-- eng/pipelines/templates/steps/run_bandit.yml | 9 +++++-- eng/pipelines/templates/steps/run_black.yml | 1 - .../templates/steps/run_breaking_changes.yml | 9 +++++-- eng/pipelines/templates/steps/run_mypy.yml | 8 +++++- eng/pipelines/templates/steps/run_pylint.yml | 9 +++++-- .../templates/steps/set-dev-build.yml | 9 +++++-- .../steps/targeting-string-resolve.yml | 18 +++++++++++++ .../templates/steps/test_regression.yml | 14 ++++++---- 16 files changed, 119 insertions(+), 58 deletions(-) create mode 100644 eng/pipelines/templates/steps/targeting-string-resolve.yml diff --git a/eng/pipelines/templates/jobs/ci.tests.yml b/eng/pipelines/templates/jobs/ci.tests.yml index 0a268202a88f..2ddc3881ac96 100644 --- a/eng/pipelines/templates/jobs/ci.tests.yml +++ b/eng/pipelines/templates/jobs/ci.tests.yml @@ -72,6 +72,10 @@ jobs: value: ${{ parameters.InjectedPackages }} steps: + - template: /eng/pipelines/templates/steps/targeting-string-resolve.yml + parameters: + BuildTargetingString: ${{ parameters.BuildTargetingString }} + - template: /eng/common/pipelines/templates/steps/verify-agent-os.yml parameters: AgentImage: $(OSVmImage) @@ -99,7 +103,6 @@ jobs: OSVmImage: $(OSVmImage) CoverageArg: $(CoverageArg) PythonVersion: $(PythonVersion) - BuildTargetingString: ${{ parameters.BuildTargetingString }} ToxTestEnv: $(toxenv) ToxEnvParallel: ${{ parameters.ToxEnvParallel }} InjectedPackages: $(InjectedPackages) @@ -112,7 +115,6 @@ jobs: - template: ../steps/set-dev-build.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} - ${{ each step in parameters.BeforeTestSteps }}: - ${{ step }} diff --git a/eng/pipelines/templates/jobs/ci.yml b/eng/pipelines/templates/jobs/ci.yml index 7c5a7d5e326a..085b3de41017 100644 --- a/eng/pipelines/templates/jobs/ci.yml +++ b/eng/pipelines/templates/jobs/ci.yml @@ -70,10 +70,13 @@ jobs: vmImage: MMSUbuntu20.04 steps: + - template: /eng/pipelines/templates/steps/targeting-string-resolve.yml + parameters: + BuildTargetingString: ${{ parameters.BuildTargetingString }} + - template: ../steps/build-artifacts.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} BeforePublishSteps: ${{ parameters.BeforePublishSteps }} BuildDocs: ${{ parameters.BuildDocs }} TestPipeline: ${{ parameters.TestPipeline }} @@ -98,6 +101,10 @@ jobs: vmImage: MMSUbuntu20.04 steps: + - template: /eng/pipelines/templates/steps/targeting-string-resolve.yml + parameters: + BuildTargetingString: ${{ parameters.BuildTargetingString }} + - template: /eng/common/pipelines/templates/steps/check-spelling.yml - template: /eng/common/pipelines/templates/steps/verify-links.yml @@ -112,7 +119,6 @@ jobs: - template: ../steps/analyze.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} TestMarkArgument: ${{ parameters.TestMarkArgument }} AdditionalTestArgs: '--wheel_dir="$(Build.ArtifactStagingDirectory)"' TestPipeline: ${{ parameters.TestPipeline }} @@ -180,7 +186,10 @@ jobs: vmImage: MMSUbuntu20.04 steps: + - template: /eng/pipelines/templates/steps/targeting-string-resolve.yml + parameters: + BuildTargetingString: ${{ parameters.BuildTargetingString }} + - template: ../steps/test_regression.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} diff --git a/eng/pipelines/templates/jobs/live.tests.yml b/eng/pipelines/templates/jobs/live.tests.yml index 09bd7d44b67c..793c519010f1 100644 --- a/eng/pipelines/templates/jobs/live.tests.yml +++ b/eng/pipelines/templates/jobs/live.tests.yml @@ -68,8 +68,6 @@ jobs: value: true - name: ArmTemplateParameters value: '@{}' - - name: BuildTargetingStringValue - value: $[ coalesce(variables['BuildTargetingString'], '${{ parameters.BuildTargetingString }}') ] timeoutInMinutes: ${{ parameters.TestTimeoutInMinutes }} continueOnError: false @@ -87,6 +85,10 @@ jobs: parameters: AgentImage: $(OSVmImage) + - template: /eng/pipelines/templates/steps/targeting-string-resolve.yml + parameters: + BuildTargetingString: ${{ parameters.BuildTargetingString }} + - template: /eng/common/TestResources/build-test-resource-config.yml parameters: SubscriptionConfiguration: ${{ parameters.CloudConfig.SubscriptionConfiguration }} @@ -101,7 +103,6 @@ jobs: - template: ../steps/build-test.yml parameters: - BuildTargetingString: $(BuildTargetingStringValue) ServiceDirectory: ${{ parameters.ServiceDirectory }} CloudName: ${{ parameters.CloudConfig.Cloud }} CoverageArg: $(CoverageArg) diff --git a/eng/pipelines/templates/stages/archetype-sdk-client.yml b/eng/pipelines/templates/stages/archetype-sdk-client.yml index 99c4178ce1ee..f562ccee86b5 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-client.yml +++ b/eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -72,9 +72,6 @@ parameters: stages: - stage: Build - variables: - - name: BuildTargetingStringValue - value: $[ coalesce(variables['BuildTargetingString'], '${{ parameters.BuildTargetingString }}') ] jobs: - template: /eng/pipelines/templates/jobs/ci.yml parameters: @@ -87,7 +84,7 @@ stages: AfterTestSteps: ${{ parameters.AfterTestSteps }} BeforePublishSteps: ${{ parameters.BeforePublishSteps }} TestMarkArgument: ${{ parameters.TestMarkArgument }} - BuildTargetingString: $(BuildTargetingStringValue) + BuildTargetingString: '${{ parameters.BuildTargetingString }}' TestTimeoutInMinutes: ${{ parameters.TestTimeoutInMinutes }} ToxEnvParallel: ${{ parameters.ToxEnvParallel }} InjectedPackages: ${{ parameters.InjectedPackages }} diff --git a/eng/pipelines/templates/steps/analyze.yml b/eng/pipelines/templates/steps/analyze.yml index 278651a0d947..c2199a443cb9 100644 --- a/eng/pipelines/templates/steps/analyze.yml +++ b/eng/pipelines/templates/steps/analyze.yml @@ -1,5 +1,4 @@ parameters: - BuildTargetingString: 'azure-*' ServiceDirectory: '' TestMarkArgument: '' AdditionalTestArgs: '' @@ -8,6 +7,12 @@ parameters: VerifyAutorest: false ValidateFormatting: false +# The variable TargetingString is set by template `eng/pipelines/templates/steps/targeting-string-resolve.yml`. This template is invoked from yml files: +# eng/pipelines/templates/jobs/ci.tests.yml +# eng/pipelines/templates/jobs/ci.yml +# eng/pipelines/templates/jobs/live.test.yml + +# Please use `$(TargetingString)` to refer to the python packages glob string. This was previously `${{ parameters.BuildTargetingString }}`. steps: - template: /eng/pipelines/templates/steps/analyze_dependency.yml @@ -25,16 +30,6 @@ steps: ServiceName: ${{parameters.ServiceDirectory}} ForRelease: false -# - template: /eng/common/pipelines/templates/steps/verify-samples.yml -# parameters: -# ServiceDirectory: ${{parameters.ServiceDirectory}} - - # Using --always-succeed so as not to block the build. Once package - # target is based on data available per-package the --always-succeed should - # be removed so this script can help enforce correct practices - # (https://github.com/Azure/azure-sdk-for-python/issues/8697) - - - pwsh: | pip install -r eng/ci_tools.txt $(if($IsWindows) {"--user" }) displayName: 'Install Necessary Dependencies' @@ -83,31 +78,28 @@ steps: condition: and(succeededOrFailed(), ne(variables['Skip.VerifySdist'],'true')) inputs: scriptPath: 'scripts/devops_tasks/setup_execute_tests.py' - arguments: '"${{ parameters.BuildTargetingString }}" --service=${{parameters.ServiceDirectory}} --toxenv=verifysdist' + arguments: '"$(TargetingString)" --service=${{parameters.ServiceDirectory}} --toxenv=verifysdist' - task: PythonScript@0 displayName: 'Verify whl' condition: and(succeededOrFailed(), ne(variables['Skip.VerifyWhl'],'true')) inputs: scriptPath: 'scripts/devops_tasks/setup_execute_tests.py' - arguments: '"${{ parameters.BuildTargetingString }}" --service=${{parameters.ServiceDirectory}} --toxenv=verifywhl' + arguments: '"$(TargetingString)" --service=${{parameters.ServiceDirectory}} --toxenv=verifywhl' - template: run_mypy.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} TestMarkArgument: ${{ parameters.TestMarkArgument }} - template: run_pylint.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} - ${{ if parameters.ValidateFormatting }}: - template: run_black.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} ValidateFormatting: ${{ parameters.ValidateFormatting }} - task: DownloadPipelineArtifact@2 @@ -119,21 +111,18 @@ steps: - template: ../steps/run_apistub.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} TestMarkArgument: ${{ parameters.TestMarkArgument }} AdditionalTestArgs: ${{parameters.AdditionalTestArgs}} - template: ../steps/run_bandit.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} TestMarkArgument: ${{ parameters.TestMarkArgument }} AdditionalTestArgs: ${{parameters.AdditionalTestArgs}} - template: ../steps/run_breaking_changes.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} TestMarkArgument: ${{ parameters.TestMarkArgument }} AdditionalTestArgs: ${{parameters.AdditionalTestArgs}} diff --git a/eng/pipelines/templates/steps/build-artifacts.yml b/eng/pipelines/templates/steps/build-artifacts.yml index b8f2370d1581..df62b07b91a5 100644 --- a/eng/pipelines/templates/steps/build-artifacts.yml +++ b/eng/pipelines/templates/steps/build-artifacts.yml @@ -5,9 +5,6 @@ parameters: - name: TestPipeline type: boolean default: false - - name: BuildTargetingString - type: string - default: 'azure-*' - name: ServiceDirectory type: string default: '' @@ -18,13 +15,21 @@ parameters: type: object default: [] +# The variable TargetingString is set by template `eng/pipelines/templates/steps/targeting-string-resolve.yml`. This template is invoked from yml files: +# eng/pipelines/templates/jobs/ci.tests.yml +# eng/pipelines/templates/jobs/ci.yml +# eng/pipelines/templates/jobs/live.test.yml + +# Please use `$(TargetingString)` to refer to the python packages glob string. This was previously `${{ parameters.BuildTargetingString }}`. steps: - template: /eng/common/pipelines/templates/steps/set-test-pipeline-version.yml parameters: PackageName: "azure-template" ServiceDirectory: "template" TestPipeline: ${{ parameters.TestPipeline }} + - template: /eng/common/pipelines/templates/steps/set-default-branch.yml + - script: | echo "##vso[build.addbuildtag]Scheduled" displayName: 'Tag scheduled builds' @@ -43,7 +48,7 @@ steps: displayName: 'Generate Python2 Applicable Namespace Packages' inputs: scriptPath: 'scripts/devops_tasks/build_packages.py' - arguments: '-d "$(Build.ArtifactStagingDirectory)" "${{ parameters.BuildTargetingString }}" --pkgfilter="nspkg" --service=${{parameters.ServiceDirectory}}' + arguments: '-d "$(Build.ArtifactStagingDirectory)" "$(TargetingString)" --pkgfilter="nspkg" --service=${{parameters.ServiceDirectory}}' - task: UsePythonVersion@0 displayName: 'Use Python $(PythonVersion)' @@ -57,7 +62,7 @@ steps: - template: ../steps/set-dev-build.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} + - task: Powershell@2 inputs: filePath: $(Build.SourcesDirectory)/eng/common/scripts/Save-Package-Properties.ps1 @@ -73,7 +78,7 @@ steps: displayName: 'Generate Packages' inputs: scriptPath: 'scripts/devops_tasks/build_packages.py' - arguments: '-d "$(Build.ArtifactStagingDirectory)" "${{ parameters.BuildTargetingString }}" --service=${{parameters.ServiceDirectory}} --devbuild="$(SetDevVersion)"' + arguments: '-d "$(Build.ArtifactStagingDirectory)" "$(TargetingString)" --service=${{parameters.ServiceDirectory}} --devbuild="$(SetDevVersion)"' - script: | twine check $(Build.ArtifactStagingDirectory)/**/*.whl @@ -86,7 +91,7 @@ steps: inputs: scriptPath: 'scripts/devops_tasks/setup_execute_tests.py' arguments: >- - "${{ parameters.BuildTargetingString }}" + "$(TargetingString)" --service="${{ parameters.ServiceDirectory }}" --toxenv=sphinx diff --git a/eng/pipelines/templates/steps/build-test.yml b/eng/pipelines/templates/steps/build-test.yml index 1a18f5a6adc6..e2dbe73d609d 100644 --- a/eng/pipelines/templates/steps/build-test.yml +++ b/eng/pipelines/templates/steps/build-test.yml @@ -9,16 +9,22 @@ parameters: BeforeTestSteps: [] AfterTestSteps: [] CoverageArg: '' - BuildTargetingString: 'azure-*' ToxTestEnv: "" RunCoverage: ne(variables['CoverageArg'], '--disablecov') ToxEnvParallel: '' InjectedPackages: '' DevFeedName: 'public/azure-sdk-for-python' +# The variable TargetingString is set by template `eng/pipelines/templates/steps/targeting-string-resolve.yml`. This template is invoked from yml files: +# eng/pipelines/templates/jobs/ci.tests.yml +# eng/pipelines/templates/jobs/ci.yml +# eng/pipelines/templates/jobs/live.test.yml + +# Please use `$(TargetingString)` to refer to the python packages glob string. This was previously `${{ parameters.BuildTargetingString }}`. steps: - pwsh: | gci -r $(Build.ArtifactStagingDirectory) + displayName: Dump Artifact Directory - template: /eng/pipelines/templates/steps/use-python-version.yml parameters: @@ -43,7 +49,7 @@ steps: inputs: scriptPath: 'scripts/devops_tasks/setup_execute_tests.py' arguments: >- - "${{ parameters.BuildTargetingString }}" + "$(TargetingString)" ${{ parameters.AdditionalTestArgs }} ${{ parameters.CoverageArg }} --mark_arg="${{ parameters.TestMarkArgument }}" @@ -94,7 +100,7 @@ steps: inputs: scriptPath: 'scripts/devops_tasks/setup_execute_tests.py' arguments: >- - "${{ parameters.BuildTargetingString }}" + "$(TargetingString)" --service="${{ parameters.ServiceDirectory }}" --toxenv="samples" env: ${{ parameters.EnvVars }} diff --git a/eng/pipelines/templates/steps/run_apistub.yml b/eng/pipelines/templates/steps/run_apistub.yml index 5ad5273b64bc..ccd103e7f45c 100644 --- a/eng/pipelines/templates/steps/run_apistub.yml +++ b/eng/pipelines/templates/steps/run_apistub.yml @@ -1,9 +1,14 @@ parameters: - BuildTargetingString: 'azure-*' ServiceDirectory: '' TestMarkArgument: '' AdditionalTestArgs: '' +# The variable TargetingString is set by template `eng/pipelines/templates/steps/targeting-string-resolve.yml`. This template is invoked from yml files: +# eng/pipelines/templates/jobs/ci.tests.yml +# eng/pipelines/templates/jobs/ci.yml +# eng/pipelines/templates/jobs/live.test.yml + +# Please use `$(TargetingString)` to refer to the python packages glob string. This was previously `${{ parameters.BuildTargetingString }}`. steps: - task: PythonScript@0 displayName: 'Run Api Stub Generation' @@ -11,7 +16,7 @@ steps: inputs: scriptPath: 'scripts/devops_tasks/setup_execute_tests.py' arguments: >- - "${{ parameters.BuildTargetingString }}" + "$(TargetingString)" ${{ parameters.AdditionalTestArgs }} --mark_arg="${{ parameters.TestMarkArgument }}" --service="${{ parameters.ServiceDirectory }}" diff --git a/eng/pipelines/templates/steps/run_bandit.yml b/eng/pipelines/templates/steps/run_bandit.yml index 02e6c5e8cb1d..a6fd7c61ce01 100644 --- a/eng/pipelines/templates/steps/run_bandit.yml +++ b/eng/pipelines/templates/steps/run_bandit.yml @@ -1,16 +1,21 @@ parameters: - BuildTargetingString: 'azure-*' ServiceDirectory: '' TestMarkArgument: '' EnvVars: {} +# The variable TargetingString is set by template `eng/pipelines/templates/steps/targeting-string-resolve.yml`. This template is invoked from yml files: +# eng/pipelines/templates/jobs/ci.tests.yml +# eng/pipelines/templates/jobs/ci.yml +# eng/pipelines/templates/jobs/live.test.yml + +# Please use `$(TargetingString)` to refer to the python packages glob string. This was previously `${{ parameters.BuildTargetingString }}`. steps: - task: PythonScript@0 displayName: 'Run Bandit' inputs: scriptPath: 'scripts/devops_tasks/setup_execute_tests.py' arguments: >- - "${{ parameters.BuildTargetingString }}" + "$(TargetingString)" --mark_arg="${{ parameters.TestMarkArgument }}" --service="${{ parameters.ServiceDirectory }}" --toxenv="bandit" diff --git a/eng/pipelines/templates/steps/run_black.yml b/eng/pipelines/templates/steps/run_black.yml index f3af5bba1298..ace65b037e0c 100644 --- a/eng/pipelines/templates/steps/run_black.yml +++ b/eng/pipelines/templates/steps/run_black.yml @@ -1,5 +1,4 @@ parameters: - BuildTargetingString: 'azure-*' ServiceDirectory: '' ValidateFormatting: false EnvVars: {} diff --git a/eng/pipelines/templates/steps/run_breaking_changes.yml b/eng/pipelines/templates/steps/run_breaking_changes.yml index 82a43d582eff..e5341b1a7577 100644 --- a/eng/pipelines/templates/steps/run_breaking_changes.yml +++ b/eng/pipelines/templates/steps/run_breaking_changes.yml @@ -1,16 +1,21 @@ parameters: - BuildTargetingString: 'azure-*' ServiceDirectory: '' TestMarkArgument: '' EnvVars: {} +# The variable TargetingString is set by template `eng/pipelines/templates/steps/targeting-string-resolve.yml`. This template is invoked from yml files: +# eng/pipelines/templates/jobs/ci.tests.yml +# eng/pipelines/templates/jobs/ci.yml +# eng/pipelines/templates/jobs/live.test.yml + +# Please use `$(TargetingString)` to refer to the python packages glob string. This was previously `${{ parameters.BuildTargetingString }}`. steps: - task: PythonScript@0 displayName: 'Run Breaking Changes' inputs: scriptPath: 'scripts/devops_tasks/setup_execute_tests.py' arguments: >- - "${{ parameters.BuildTargetingString }}" + "$(TargetingString)" --mark_arg="${{ parameters.TestMarkArgument }}" --service="${{ parameters.ServiceDirectory }}" --toxenv="breaking" diff --git a/eng/pipelines/templates/steps/run_mypy.yml b/eng/pipelines/templates/steps/run_mypy.yml index 4fa05f07cd29..6a6b77ad0252 100644 --- a/eng/pipelines/templates/steps/run_mypy.yml +++ b/eng/pipelines/templates/steps/run_mypy.yml @@ -4,6 +4,12 @@ parameters: TestMarkArgument: '' EnvVars: {} +# The variable TargetingString is set by template `eng/pipelines/templates/steps/targeting-string-resolve.yml`. This template is invoked from yml files: +# eng/pipelines/templates/jobs/ci.tests.yml +# eng/pipelines/templates/jobs/ci.yml +# eng/pipelines/templates/jobs/live.test.yml + +# Please use `$(TargetingString)` to refer to the python packages glob string. This was previously `${{ parameters.BuildTargetingString }}`. steps: - task: UsePythonVersion@0 displayName: 'Use Python 3.7' @@ -21,7 +27,7 @@ steps: inputs: scriptPath: 'scripts/devops_tasks/setup_execute_tests.py' arguments: >- - "${{ parameters.BuildTargetingString }}" + "$(TargetingString)" --mark_arg="${{ parameters.TestMarkArgument }}" --service="${{ parameters.ServiceDirectory }}" --toxenv="mypy" diff --git a/eng/pipelines/templates/steps/run_pylint.yml b/eng/pipelines/templates/steps/run_pylint.yml index 1386c14c00a4..ea626731845e 100644 --- a/eng/pipelines/templates/steps/run_pylint.yml +++ b/eng/pipelines/templates/steps/run_pylint.yml @@ -1,9 +1,14 @@ parameters: - BuildTargetingString: 'azure-*' ServiceDirectory: '' TestMarkArgument: '' EnvVars: {} +# The variable TargetingString is set by template `eng/pipelines/templates/steps/targeting-string-resolve.yml`. This template is invoked from yml files: +# eng/pipelines/templates/jobs/ci.tests.yml +# eng/pipelines/templates/jobs/ci.yml +# eng/pipelines/templates/jobs/live.test.yml + +# Please use `$(TargetingString)` to refer to the python packages glob string. This was previously `${{ parameters.BuildTargetingString }}`. steps: - task: UsePythonVersion@0 displayName: 'Use Python 3.7' @@ -21,7 +26,7 @@ steps: inputs: scriptPath: 'scripts/devops_tasks/setup_execute_tests.py' arguments: >- - "${{ parameters.BuildTargetingString }}" + "$(TargetingString)" --mark_arg="${{ parameters.TestMarkArgument }}" --service="${{ parameters.ServiceDirectory }}" --toxenv="lint" diff --git a/eng/pipelines/templates/steps/set-dev-build.yml b/eng/pipelines/templates/steps/set-dev-build.yml index 3160548fe81b..0936a5cb2e36 100644 --- a/eng/pipelines/templates/steps/set-dev-build.yml +++ b/eng/pipelines/templates/steps/set-dev-build.yml @@ -1,7 +1,12 @@ parameters: - BuildTargetingString: 'azure-*' ServiceDirectory: '' +# The variable TargetingString is set by template `eng/pipelines/templates/steps/targeting-string-resolve.yml`. This template is invoked from yml files: +# eng/pipelines/templates/jobs/ci.tests.yml +# eng/pipelines/templates/jobs/ci.yml +# eng/pipelines/templates/jobs/live.test.yml + +# Please use `$(TargetingString)` to refer to the python packages glob string. This was previously `${{ parameters.BuildTargetingString }}`. steps: - template: /eng/common/pipelines/templates/steps/daily-dev-build-variable.yml parameters: @@ -12,4 +17,4 @@ steps: displayName: "Update package versions for dev build" inputs: scriptPath: 'eng/versioning/version_set_dev.py' - arguments: '"${{ parameters.BuildTargetingString }}" --service="${{parameters.ServiceDirectory}}" --build-id="$(Build.BuildNumber)"' + arguments: '"$(TargetingString)" --service="${{parameters.ServiceDirectory}}" --build-id="$(Build.BuildNumber)"' diff --git a/eng/pipelines/templates/steps/targeting-string-resolve.yml b/eng/pipelines/templates/steps/targeting-string-resolve.yml new file mode 100644 index 000000000000..10e95eba9350 --- /dev/null +++ b/eng/pipelines/templates/steps/targeting-string-resolve.yml @@ -0,0 +1,18 @@ +parameters: + - name: BuildTargetingString + type: string + default: 'azure-*' + +steps: + - pwsh: | + $setting = "${{ parameters.BuildTargetingString }}" + + # if the variable is not set, it'll just come back as the variable name. otherwise it's set. + if ('$(BuildTargetingString)' -ne ('$' + '(BuildTargetingString)')) { + $setting = "$(BuildTargetingString)" + } + + Write-Host "Setting TargetingString to $setting" + Write-Host "##vso[task.setvariable variable=TargetingString]$setting" + displayName: Check override of targeting string + condition: and(succeededOrFailed(), eq(variables['TargetingString'],'')) diff --git a/eng/pipelines/templates/steps/test_regression.yml b/eng/pipelines/templates/steps/test_regression.yml index 9d50fb4f2173..bdfc5cf04ebb 100644 --- a/eng/pipelines/templates/steps/test_regression.yml +++ b/eng/pipelines/templates/steps/test_regression.yml @@ -1,9 +1,14 @@ parameters: - BuildTargetingString: 'azure-*' ServiceDirectory: '' BuildStagingDirectory: $(Build.ArtifactStagingDirectory) DevFeedName: 'public/azure-sdk-for-python' - + +# The variable TargetingString is set by template `eng/pipelines/templates/steps/targeting-string-resolve.yml`. This template is invoked from yml files: +# eng/pipelines/templates/jobs/ci.tests.yml +# eng/pipelines/templates/jobs/ci.yml +# eng/pipelines/templates/jobs/live.test.yml + +# Please use `$(TargetingString)` to refer to the python packages glob string. This was previously `${{ parameters.BuildTargetingString }}`. steps: - task: UsePythonVersion@0 displayName: 'Use Python 3.7' @@ -22,7 +27,6 @@ steps: - template: ../steps/set-dev-build.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} - ${{if eq(variables['System.TeamProject'], 'internal') }}: - template: ../steps/auth-dev-feed.yml @@ -34,7 +38,7 @@ steps: inputs: scriptPath: 'scripts/devops_tasks/test_regression.py' arguments: >- - "${{ parameters.BuildTargetingString }}" + "$(TargetingString)" --service="${{ parameters.ServiceDirectory }}" --whl-dir="${{ parameters.BuildStagingDirectory }}" --mark-arg="not cosmosEmulator" @@ -44,7 +48,7 @@ steps: inputs: scriptPath: 'scripts/devops_tasks/test_regression.py' arguments: >- - "${{ parameters.BuildTargetingString }}" + "$(TargetingString)" --service="${{ parameters.ServiceDirectory }}" --whl-dir="${{ parameters.BuildStagingDirectory }}" --verify-latest=False