Skip to content

Commit ecce9ed

Browse files
azure-sdkbenbp
andauthored
Sync eng/common directory with azure-sdk-tools for PR 1452 (Azure#14179)
* Use sparse checkout for generate matrix job * Add repository parameter Co-authored-by: Ben Broderick Phillips <[email protected]>
1 parent 0f9117c commit ecce9ed

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

eng/common/pipelines/templates/jobs/archetype-sdk-tests-generate.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,40 @@ parameters:
1212
default: []
1313
- name: JobTemplatePath
1414
type: string
15+
# Set this to false to do a full checkout for private repositories with the azure pipelines service connection
16+
- name: SparseCheckout
17+
type: boolean
18+
default: true
19+
- name: SparseCheckoutPaths
20+
type: object
21+
default: []
22+
- name: Pool
23+
type: string
24+
default: azsdk-pool-mms-ubuntu-1804-general
25+
- name: OsVmImage
26+
type: string
27+
default: MMSUbuntu18.04
1528

1629
jobs:
1730
- job: generate_matrix
1831
variables:
1932
displayNameFilter: $[ coalesce(variables.jobMatrixFilter, '.*') ]
2033
pool:
21-
name: Azure Pipelines
22-
vmImage: ubuntu-18.04
34+
name: ${{ parameters.Pool }}
35+
vmImage: ${{ parameters.OsVmImage }}
2336
displayName: Generate Job Matrix
2437
steps:
38+
# Skip sparse checkout for the `azure-sdk-for-<lang>-pr` private mirrored repositories
39+
# as we require the github service connection to be loaded.
40+
- ${{ if and(parameters.SparseCheckout, not(contains(variables['Build.DefinitionName'], '-pr - '))) }}:
41+
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
42+
parameters:
43+
${{ if ne(length(parameters.SparseCheckoutPaths), 0) }}:
44+
Paths: ${{ parameters.SparseCheckoutPaths }}
45+
${{ if and(eq(length(parameters.SparseCheckoutPaths), 0), ne(parameters.AdditionalParameters.ServiceDirectory, '')) }}:
46+
Paths:
47+
- ${{ parameters.AdditionalParameters.ServiceDirectory }}
48+
2549
- ${{ each config in parameters.MatrixConfigs }}:
2650
- ${{ if eq(config.GenerateVMJobs, 'true') }}:
2751
- task: Powershell@2
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
parameters:
2+
- name: Paths
3+
type: object
4+
default: []
5+
- name: Repositories
6+
type: object
7+
default:
8+
- Name: $(Build.Repository.Name)
9+
Commitish: $(Build.SourceVersion)
10+
WorkingDirectory: $(System.DefaultWorkingDirectory)
11+
12+
steps:
13+
- checkout: none
14+
15+
- ${{ each repo in parameters.Repositories }}:
16+
- pwsh: |
17+
$dir = "${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }}"
18+
New-Item $dir -ItemType Directory -Force
19+
20+
- pwsh: |
21+
git clone --no-checkout --filter=tree:0 git://github.com/${{ repo.Name }} .
22+
git sparse-checkout init
23+
git sparse-checkout set eng
24+
displayName: Init sparse checkout ${{ repo.Name }}
25+
workingDirectory: ${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }}
26+
27+
- ${{ each path in parameters.Paths }}:
28+
- pwsh: git sparse-checkout add ${{ path }}
29+
displayName: Add sparse checkout path ${{ path }}
30+
workingDirectory: ${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }}
31+
32+
- pwsh: git checkout ${{ repo.Commitish }}
33+
displayName: Sparse checkout at ${{ repo.Commitish }}
34+
workingDirectory: ${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }}

eng/common/scripts/job-matrix/samples/matrix-test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ jobs:
77
- template: /eng/common/pipelines/templates/jobs/archetype-sdk-tests-generate.yml
88
parameters:
99
JobTemplatePath: /eng/common/scripts/job-matrix/samples/matrix-job-sample.yml
10-
AdditionalParameters: []
10+
AdditionalParameters: {}
11+
Pool: Azure Pipelines
12+
OsVmImage: ubuntu-18.04
1113
CloudConfig:
1214
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
1315
Location: eastus2

0 commit comments

Comments
 (0)