Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync eng/common directory with azure-sdk-tools for PR 1452 #14179

Merged
merged 2 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,40 @@ parameters:
default: []
- name: JobTemplatePath
type: string
# Set this to false to do a full checkout for private repositories with the azure pipelines service connection
- name: SparseCheckout
type: boolean
default: true
- name: SparseCheckoutPaths
type: object
default: []
- name: Pool
type: string
default: azsdk-pool-mms-ubuntu-1804-general
- name: OsVmImage
type: string
default: MMSUbuntu18.04

jobs:
- job: generate_matrix
variables:
displayNameFilter: $[ coalesce(variables.jobMatrixFilter, '.*') ]
pool:
name: Azure Pipelines
vmImage: ubuntu-18.04
name: ${{ parameters.Pool }}
vmImage: ${{ parameters.OsVmImage }}
displayName: Generate Job Matrix
steps:
# Skip sparse checkout for the `azure-sdk-for-<lang>-pr` private mirrored repositories
# as we require the github service connection to be loaded.
- ${{ if and(parameters.SparseCheckout, not(contains(variables['Build.DefinitionName'], '-pr - '))) }}:
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
parameters:
${{ if ne(length(parameters.SparseCheckoutPaths), 0) }}:
Paths: ${{ parameters.SparseCheckoutPaths }}
${{ if and(eq(length(parameters.SparseCheckoutPaths), 0), ne(parameters.AdditionalParameters.ServiceDirectory, '')) }}:
Paths:
- ${{ parameters.AdditionalParameters.ServiceDirectory }}

- ${{ each config in parameters.MatrixConfigs }}:
- ${{ if eq(config.GenerateVMJobs, 'true') }}:
- task: Powershell@2
Expand Down
34 changes: 34 additions & 0 deletions eng/common/pipelines/templates/steps/sparse-checkout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
parameters:
- name: Paths
type: object
default: []
- name: Repositories
type: object
default:
- Name: $(Build.Repository.Name)
Commitish: $(Build.SourceVersion)
WorkingDirectory: $(System.DefaultWorkingDirectory)

steps:
- checkout: none

- ${{ each repo in parameters.Repositories }}:
- pwsh: |
$dir = "${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }}"
New-Item $dir -ItemType Directory -Force

- pwsh: |
git clone --no-checkout --filter=tree:0 git://github.com/${{ repo.Name }} .
git sparse-checkout init
git sparse-checkout set eng
displayName: Init sparse checkout ${{ repo.Name }}
workingDirectory: ${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }}

- ${{ each path in parameters.Paths }}:
- pwsh: git sparse-checkout add ${{ path }}
displayName: Add sparse checkout path ${{ path }}
workingDirectory: ${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }}

- pwsh: git checkout ${{ repo.Commitish }}
displayName: Sparse checkout at ${{ repo.Commitish }}
workingDirectory: ${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }}
4 changes: 3 additions & 1 deletion eng/common/scripts/job-matrix/samples/matrix-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ jobs:
- template: /eng/common/pipelines/templates/jobs/archetype-sdk-tests-generate.yml
parameters:
JobTemplatePath: /eng/common/scripts/job-matrix/samples/matrix-job-sample.yml
AdditionalParameters: []
AdditionalParameters: {}
Pool: Azure Pipelines
OsVmImage: ubuntu-18.04
CloudConfig:
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
Location: eastus2
Expand Down