Make static CI a matrix (#16397)

* move markdown lint tests

* move markdown link tests

* refactor static link analysis into a matrix

* cache yarn packages

* fix paramater name
This commit is contained in:
Travis Plunk
2021-11-09 09:23:26 -08:00
committed by GitHub
parent f8d6b2f9fe
commit d176853672
10 changed files with 209 additions and 75 deletions
+32 -74
View File
@@ -27,83 +27,41 @@ variables:
- name: repoFolder
value: PowerShell
jobs:
- job: CI_Compliance
displayName: CI Compliance
stages:
- stage: Compliance
jobs:
- job: CI_Compliance
displayName: CI Compliance
pool:
vmImage: windows-latest
pool:
vmImage: windows-latest
variables:
- name: repoPath
value: $(Agent.BuildDirectory)\$(repoFolder)
variables:
- name: repoPath
value: $(Agent.BuildDirectory)\$(repoFolder)
steps:
- checkout: self
clean: true
path: $(repoFolder)
steps:
- checkout: self
clean: true
path: $(repoFolder)
- checkout: ComplianceRepo
- checkout: ComplianceRepo
- template: ci-compliance.yml@ComplianceRepo
- job: Linux_CI
displayName: Markdown and Common Tests
pool:
vmImage: ubuntu-20.04
variables:
- name: repoPath
value: $(Agent.BuildDirectory)/$(repoFolder)
steps:
- checkout: self
clean: true
path: $(repoFolder)
- checkout: ComplianceRepo
- powershell: |
Get-ChildItem -Path env:
displayName: Capture Environment
condition: succeededOrFailed()
- powershell: |
Install-module Pester -Scope CurrentUser -Force -MaximumVersion 4.99
displayName: Install Pester
condition: succeededOrFailed()
- bash: |
curl -o- --progress-bar -L https://yarnpkg.com/install.sh | bash
displayName: Bootstrap Yarn
condition: succeededOrFailed()
- bash: |
sudo yarn global add markdown-spellcheck@0.11.0
displayName: Install mdspell
condition: succeededOrFailed()
- bash: |
mdspell '**/*.md' '!**/Pester/**/*.md' '!**/dotnet-tools/**/*.md' --ignore-numbers --ignore-acronyms --report --en-us;
displayName: Test Spelling in Markdown
condition: succeededOrFailed()
workingDirectory: '$(repoPath)'
- ${{ if not(contains(variables['SYSTEM.COLLECTIONURI'],'mscodehub')) }}:
- pwsh: |
Import-module ./build.psm1
$path = Join-Path -Path $pwd -ChildPath './commonTestResults.xml'
$results = invoke-pester -Script ./test/common -OutputFile $path -OutputFormat NUnitXml -PassThru
Write-Host "##vso[results.publish type=NUnit;mergeResults=true;runTitle=Common Tests;publishRunAttachments=true;resultFiles=$path;]"
if($results.TotalCount -eq 0 -or $results.FailedCount -gt 0)
{
throw "Markdown tests failed"
}
displayName: Run Common Tests
condition: succeededOrFailed()
workingDirectory: '$(repoPath)'
- template: dailyBuildCompliance.yml@ComplianceRepo
- template: ci-compliance.yml@ComplianceRepo
- stage: markdown_spelling_lint
displayName: Markdown Spelling and Lint
dependsOn: []
jobs:
- template: ./misc-analysis/mdSpell.yml
- stage: markdown_link
displayName: Markdown Link
dependsOn: []
jobs:
- template: ./misc-analysis/generateMarkdownMatrix.yml
parameters:
sourceScanPath: '$(repoPath)'
jobName: generateMatrix
taskName: matrixTask
- template: ./misc-analysis/markdown.yml
parameters:
matrix: $[ dependencies.generateMatrix.outputs['matrixTask.matrix'] ]
dependsOn: generateMatrix
@@ -0,0 +1,46 @@
parameters:
- name: jobName
- name: taskName
jobs:
- job: ${{ parameters.jobName }}
displayName: Generate Markdown Matrix
pool:
vmImage: ubuntu-20.04
variables:
- name: repoPath
value: $(Agent.BuildDirectory)/$(repoFolder)
steps:
- checkout: self
clean: true
path: $(repoFolder)
- powershell: |
$matrix = @{}
$matrix += @{
'root' = @{
markdown_folder = "$(repoPath)"
markdown_recurse = $false
}
}
Get-ChildItem -path '$(repoPath)' -Directory | Foreach-Object {
$folder = $_
$matrix += @{
$_.Name = @{
markdown_folder = $_.fullName
markdown_recurse = $true
}
}
}
$matrixJson = $matrix | ConvertTo-Json -Compress
$variableName = "matrix"
$command = "vso[task.setvariable variable=$variableName;isoutput=true]$($matrixJson)"
Write-Verbose "sending command: '$command'"
Write-Host "##$command"
displayName: Create Matrix
condition: succeededOrFailed()
name: ${{ parameters.taskName }}
+63
View File
@@ -0,0 +1,63 @@
parameters:
- name: matrix
- name: dependsOn
jobs:
- job: markdown
strategy:
matrix: ${{ parameters.matrix }}
maxParallel: 5
displayName: Markdown Link Verification
dependsOn: ${{ parameters.dependsOn }}
pool:
vmImage: ubuntu-20.04
variables:
- name: repoPath
value: $(Agent.BuildDirectory)/$(repoFolder)
- name: YARN_CACHE_FOLDER
value: $(Pipeline.Workspace)/.yarn
- name: YARN_GLOBAL_CACHE_FOLDER
value: $(Pipeline.Workspace)/.yarn-global
steps:
- checkout: self
clean: true
path: $(repoFolder)
- checkout: ComplianceRepo
- task: Cache@2
inputs:
key: '"markdown-link-check" | "$(Agent.OS)" | $(repoPath)/test/common/markdown-link/markdown-link.tests.ps1'
path: $(YARN_GLOBAL_CACHE_FOLDER)
displayName: Cache Yarn packages
- powershell: |
Install-module Pester -Scope CurrentUser -Force -MaximumVersion 4.99
displayName: Install Pester
- bash: |
curl -o- --progress-bar -L https://yarnpkg.com/install.sh | bash
displayName: Bootstrap Yarn
- bash: |
yarn config set global-folder "$(YARN_GLOBAL_CACHE_FOLDER)"
displayName: Set Yarn global cache folder
- ${{ if not(contains(variables['SYSTEM.COLLECTIONURI'],'mscodehub')) }}:
- pwsh: |
Import-module ./build.psm1
$path = Join-Path -Path $pwd -ChildPath './commonTestResults.xml'
$results = invoke-pester -Script ./test/common/markdown-link -OutputFile $path -OutputFormat NUnitXml -PassThru
Write-Host "##vso[results.publish type=NUnit;mergeResults=true;runTitle=Markdown Link;publishRunAttachments=true;resultFiles=$path;]"
if($results.TotalCount -eq 0 -or $results.FailedCount -gt 0)
{
throw "Markdown tests failed"
}
displayName: Run Markdown Link Tests
condition: succeededOrFailed()
workingDirectory: '$(repoPath)'
+56
View File
@@ -0,0 +1,56 @@
jobs:
- job: markdown
displayName: Markdown Spelling
pool:
vmImage: ubuntu-20.04
variables:
- name: repoPath
value: $(Agent.BuildDirectory)/$(repoFolder)
steps:
- checkout: self
clean: true
path: $(repoFolder)
- checkout: ComplianceRepo
- powershell: |
Get-ChildItem -Path env:
displayName: Capture Environment
condition: succeededOrFailed()
- bash: |
curl -o- --progress-bar -L https://yarnpkg.com/install.sh | bash
displayName: Bootstrap Yarn
condition: succeededOrFailed()
- bash: |
sudo yarn global add markdown-spellcheck@0.11.0
displayName: Install mdspell
condition: succeededOrFailed()
- bash: |
mdspell '**/*.md' '!**/Pester/**/*.md' '!**/dotnet-tools/**/*.md' --ignore-numbers --ignore-acronyms --report --en-us;
displayName: Test Spelling in Markdown
condition: succeededOrFailed()
workingDirectory: '$(repoPath)'
- ${{ if not(contains(variables['SYSTEM.COLLECTIONURI'],'mscodehub')) }}:
- pwsh: |
Import-module ./build.psm1
$path = Join-Path -Path $pwd -ChildPath './commonTestResults.xml'
$results = invoke-pester -Script ./test/common/markdown-lint -OutputFile $path -OutputFormat NUnitXml -PassThru
Write-Host "##vso[results.publish type=NUnit;mergeResults=true;runTitle=Markdown Lint;publishRunAttachments=true;resultFiles=$path;]"
if($results.TotalCount -eq 0 -or $results.FailedCount -gt 0)
{
throw "Markdown tests failed"
}
displayName: Run Markdown Lint Tests
condition: succeededOrFailed()
workingDirectory: '$(repoPath)'
- template: dailyBuildCompliance.yml@ComplianceRepo
parameters:
sourceScanPath: '$(repoPath)'
@@ -25,7 +25,18 @@ Describe "Verify Markdown Links" {
Get-Job | Remove-Job -Force
}
$groups = Get-ChildItem -Path "$PSScriptRoot\..\..\..\*.md" -Recurse | Where-Object {$_.DirectoryName -notlike '*node_modules*'} | Group-Object -Property directory
$gciParams = @{}
if ($env:MARKDOWN_FOLDER) {
$gciParams["Path"] = (Join-Path -Path $env:MARKDOWN_FOLDER -ChildPath '*.md')
} else {
$gciParams["Path"] = "$PSScriptRoot\..\..\..\*.md"
}
if ($env:MARKDOWN_RECURSE -ne 'False') {
$gciParams["Recurse"] = $true
}
$groups = Get-ChildItem @gciParams | Where-Object {$_.DirectoryName -notlike '*node_modules*'} | Group-Object -Property directory
$jobs = @{}
# start all link verification in parallel