-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use sparse checkout for generate matrix job (#1452)
From a functional standpoint, the generate matrix job only takes a few seconds to run. Depending on the repository, the job can take a total time of 4 minutes before the test jobs are able to start, because azure pipelines does a clone of the entire repository (among other things). This PR makes a change to skip the azure pipelines checkout step, and add a lightweight git clone along with a sparse checkout of just the `eng` and service directory locations (which contain the matrix scripts and/or matrix configs). This change reduces the total job runtime to around 20 seconds from 4 minutes (repo checkouts + auto-injected policy steps).
- Loading branch information
Showing
3 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters