Skip to content

Commit 4ff0cd2

Browse files
authored
Add ADO pipeline scaffolding (#1762)
1 parent bddff2b commit 4ff0cd2

14 files changed

Lines changed: 579 additions & 1 deletion

File tree

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ trim_trailing_whitespace = true
1010
[*.json]
1111
indent_size = 2
1212

13+
[*.ps1]
14+
indent_size = 2
15+
1316
[*.rs]
1417
end_of_line = lf
1518

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"cSpell.enabled": true,
33
"editor.formatOnSave": true,
4-
"rust-analyzer.cargo.features": "all"
4+
"rust-analyzer.cargo.features": "all",
5+
"[powershell]": {
6+
"editor.defaultFormatter": "ms-vscode.powershell",
7+
},
8+
"yaml.format.printWidth": 240
59
}

eng/CredScanSuppression.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"tool": "Credential Scanner",
3+
"suppressions": [
4+
{
5+
"placeholder": [
6+
"placeholder"
7+
],
8+
"_justification": "Secret used by test code, it is fake."
9+
},
10+
{
11+
"file": [
12+
"eng/common/testproxy/dotnet-devcert.pfx"
13+
],
14+
"_justification": "File contains private key used by test code."
15+
}
16+
]
17+
}

eng/pipelines/pr.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
trigger: none
2+
3+
pr:
4+
branches:
5+
include:
6+
- main
7+
- feature/*
8+
- hotfix/*
9+
- release/*
10+
11+
extends:
12+
template: /eng/pipelines/templates/stages/archetype-sdk-client.yml
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
parameters:
2+
- name: ServiceDirectory
3+
type: string
4+
default: auto
5+
- name: BeforeTestSteps
6+
type: object
7+
default: []
8+
- name: AfterTestSteps
9+
type: object
10+
default: []
11+
- name: TestTimeoutInMinutes
12+
type: number
13+
default: 60
14+
- name: BuildDocs
15+
type: boolean
16+
default: true
17+
- name: TestProxy
18+
type: boolean
19+
default: false
20+
- name: TestPipeline
21+
type: boolean
22+
default: false
23+
- name: GenerateApiReviewForManualOnly
24+
type: boolean
25+
default: false
26+
- name: BuildMatrix
27+
type: object
28+
default:
29+
- pool:
30+
os: linux
31+
name: $(LINUXPOOL)
32+
image: $(LINUXVMIMAGE)
33+
Toolchains:
34+
- name: stable
35+
publish: true
36+
- name: msrv
37+
- name: nightly
38+
- pool:
39+
os: windows
40+
name: $(WINDOWSPOOL)
41+
image: $(WINDOWSVMIMAGE)
42+
Toolchains:
43+
- name: stable
44+
- name: msrv
45+
- name: nightly
46+
- pool:
47+
os: macOS
48+
name: $(MACPOOL)
49+
vmImage: $(MACVMIMAGE)
50+
Toolchains:
51+
- name: stable
52+
- name: msrv
53+
- name: nightly
54+
- name: AnalyzeToolchains
55+
type: object
56+
default: [stable]
57+
58+
jobs:
59+
- ${{ each matrix in parameters.BuildMatrix }}:
60+
- ${{ each toolchain in matrix.Toolchains }}:
61+
- job: Build_${{ matrix.pool.os }}_${{ toolchain.name }}
62+
timeoutInMinutes: 90
63+
64+
pool: ${{ matrix.pool }}
65+
66+
steps:
67+
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
68+
parameters:
69+
Paths: [/*]
70+
71+
- template: /eng/pipelines/templates/steps/test-packages.yml
72+
parameters:
73+
ServiceDirectory: ${{ parameters.ServiceDirectory }}
74+
Toolchain: ${{ toolchain.name }}
75+
ArtifactSuffix: ${{ matrix.pool.os }}_${{ toolchain.name }}
76+
PublishArtifacts: ${{ eq(toolchain.publish, 'true') }}
77+
UnitTests: true
78+
FunctionalTests: ${{ ne(variables['Build.Reason'], 'PullRequest') }}
79+
80+
- ${{ each toolchain in parameters.AnalyzeToolchains }}:
81+
- job: "Analyze_${{ toolchain }}"
82+
condition: and(succeededOrFailed(), ne(variables['Skip.Analyze'], 'true'))
83+
timeoutInMinutes: ${{ parameters.TestTimeoutInMinutes }}
84+
85+
pool:
86+
os: linux
87+
name: $(LINUXPOOL)
88+
image: $(LINUXVMIMAGE)
89+
90+
steps:
91+
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
92+
parameters:
93+
Paths: [/*]
94+
95+
- template: /eng/pipelines/templates/steps/analyze.yml
96+
parameters:
97+
Toolchain: ${{ toolchain }}
98+
99+
- template: /eng/common/pipelines/templates/steps/check-spelling.yml
100+
parameters:
101+
ContinueOnError: false
102+
103+
# Disabled until we fix crates.io link checking
104+
# - template: /eng/common/pipelines/templates/steps/verify-links.yml
105+
# parameters:
106+
# ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
107+
# Directory: ""
108+
# Urls: (eng/common/scripts/get-markdown-files-from-changed-files.ps1)
109+
# ${{ elseif eq(parameters.ServiceDirectory, 'auto') }}:
110+
# Directory: ""
111+
# ${{ else }}:
112+
# Directory: sdk/${{ parameters.ServiceDirectory }}
113+
# CheckLinkGuidance: $true
114+
# Condition: succeededOrFailed()
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
resources:
2+
repositories:
3+
- repository: 1ESPipelineTemplates
4+
type: git
5+
name: 1ESPipelineTemplates/1ESPipelineTemplates
6+
ref: refs/tags/release
7+
- repository: 1ESPipelineTemplatesCanary
8+
type: git
9+
name: 1ESPipelineTemplates/1ESPipelineTemplates
10+
ref: refs/tags/canary
11+
12+
parameters:
13+
- name: stages
14+
type: stageList
15+
default: []
16+
- name: Use1ESOfficial
17+
type: boolean
18+
default: true
19+
- name: oneESTemplateTag
20+
type: string
21+
default: release
22+
23+
extends:
24+
${{ if and(parameters.Use1ESOfficial, eq(parameters.oneESTemplateTag, 'canary')) }}:
25+
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplatesCanary
26+
${{ elseif eq(parameters.oneESTemplateTag, 'canary') }}:
27+
template: v1/1ES.Unofficial.PipelineTemplate.yml@1ESPipelineTemplatesCanary
28+
${{ elseif and(parameters.Use1ESOfficial, eq(variables['System.TeamProject'], 'internal')) }}:
29+
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
30+
${{ else }}:
31+
template: v1/1ES.Unofficial.PipelineTemplate.yml@1ESPipelineTemplates
32+
parameters:
33+
${{ if eq(parameters.oneESTemplateTag, 'canary') }}:
34+
# Enable 1es template team to verify validation has been run on canary
35+
customBuildTags:
36+
- 1ES.PT.Tag-refs/tags/canary
37+
settings:
38+
skipBuildTagsForGitHubPullRequests: true
39+
sdl:
40+
sourceAnalysisPool:
41+
name: azsdk-pool-mms-win-2022-general
42+
image: azsdk-pool-mms-win-2022-1espt
43+
os: windows
44+
eslint:
45+
enabled: false
46+
justificationForDisabling: "ESLint injected task has failures because it uses an old version of mkdirp. We should not fail for tools not controlled by the repo. See: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3556850"
47+
codeql:
48+
compiled:
49+
enabled: false
50+
justificationForDisabling: "CodeQL times our pipelines out by running for 2+ hours before being force canceled."
51+
credscan:
52+
suppressionsFile: $(Build.SourcesDirectory)/eng/CredScanSuppression.json
53+
toolVersion: "2.3.12.23"
54+
baselineFiles: $(Build.SourcesDirectory)/eng/python.gdnbaselines
55+
psscriptanalyzer:
56+
compiled: true
57+
break: true
58+
policy: M365
59+
# Turn off the build warnings caused by disabling some sdl checks
60+
createAdoIssuesForJustificationsForDisablement: false
61+
stages: ${{ parameters.stages }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
parameters:
2+
- name: ServiceDirectory
3+
type: string
4+
default: auto
5+
- name: TestTimeoutInMinutes
6+
type: number
7+
default: 60
8+
- name: BuildDocs
9+
type: boolean
10+
default: true
11+
- name: TestProxy
12+
type: boolean
13+
default: true
14+
- name: GenerateApiReviewForManualOnly
15+
type: boolean
16+
default: false
17+
- name: oneESTemplateTag
18+
type: string
19+
default: release
20+
21+
extends:
22+
template: /eng/pipelines/templates/stages/1es-redirect.yml
23+
parameters:
24+
oneESTemplateTag: ${{ parameters.oneESTemplateTag }}
25+
stages:
26+
- stage: Build
27+
variables:
28+
- template: /eng/pipelines/templates/variables/image.yml
29+
jobs:
30+
- template: /eng/pipelines/templates/jobs/ci.yml
31+
parameters:
32+
ServiceDirectory: ${{ parameters.ServiceDirectory }}
33+
${{ if eq(parameters.ServiceDirectory, 'template') }}:
34+
TestPipeline: true
35+
TestTimeoutInMinutes: ${{ parameters.TestTimeoutInMinutes }}
36+
BuildDocs: ${{ parameters.BuildDocs }}
37+
TestProxy: ${{ parameters.TestProxy }}
38+
GenerateApiReviewForManualOnly: ${{ parameters.GenerateApiReviewForManualOnly }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
parameters:
2+
- name: Toolchain
3+
type: string
4+
default: stable
5+
6+
steps:
7+
- template: /eng/pipelines/templates/steps/use-rust.yml@self
8+
parameters:
9+
Toolchain: ${{ parameters.Toolchain }}
10+
11+
- pwsh: |
12+
. ./eng/common/scripts/Helpers/CommandInvocation-Helpers.ps1
13+
14+
$env:RUSTDOCFLAGS = "-D warnings"
15+
$env:RUSTFLAGS = "-Dwarnings"
16+
17+
Invoke-LoggedCommand "cargo +$(Toolchain) check -p azure_core --no-default-features"
18+
Invoke-LoggedCommand "cargo +$(Toolchain) fmt --all -- --check"
19+
Invoke-LoggedCommand "cargo +$(Toolchain) clippy --all"
20+
Invoke-LoggedCommand "cargo +$(Toolchain) doc --all --no-deps"
21+
displayName: "Run source analysis"
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
parameters:
2+
- name: ServiceDirectory
3+
type: string
4+
default: auto
5+
- name: Toolchain
6+
type: string
7+
default: stable
8+
- name: ArtifactSuffix
9+
type: string
10+
default: "linux"
11+
- name: PublishArtifacts
12+
type: boolean
13+
default: false
14+
- name: UnitTests
15+
type: boolean
16+
default: false
17+
- name: FunctionalTests
18+
type: boolean
19+
default: false
20+
- name: TestTimeoutInMinutes
21+
type: number
22+
default: 60
23+
24+
steps:
25+
- template: /eng/pipelines/templates/steps/use-rust.yml@self
26+
parameters:
27+
Toolchain: ${{ parameters.Toolchain }}
28+
29+
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml@self
30+
31+
- script: |
32+
echo "##vso[build.addbuildtag]Scheduled"
33+
displayName: "Tag scheduled builds"
34+
condition: and(eq(variables['Build.SourceBranchName'], variables['DefaultBranch']), eq(variables['Build.Reason'],'Schedule'))
35+
36+
# now we need to call Save-Package-Properties so that we can filter on it
37+
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
38+
- pwsh: |
39+
mkdir -p $(Build.ArtifactStagingDirectory)/diff
40+
displayName: Create PR Diff Folder
41+
42+
- pwsh: |
43+
$location = Join-Path "$(Build.ArtifactStagingDirectory)" "diff"
44+
45+
Write-Host "./eng/common/scripts/Generate-PR-Diff.ps1 -TargetPath `"$(Build.SourcesDirectory)`" -ArtifactPath `"$location`""
46+
./eng/common/scripts/Generate-PR-Diff.ps1 -TargetPath "$(Build.SourcesDirectory)" -ArtifactPath "$location"
47+
displayName: Generate PR Diff
48+
49+
- pwsh: |
50+
Write-Host "Freshly generated the PR diff:"
51+
Get-ChildItem -R -Force $(Build.ArtifactStagingDirectory)/diff | % { $_.FullName }
52+
cat $(Build.ArtifactStagingDirectory)/diff/diff.json
53+
displayName: Dump PR Diff
54+
55+
- task: Powershell@2
56+
displayName: Save package properties filtered for PR
57+
inputs:
58+
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Save-Package-Properties.ps1
59+
arguments: >
60+
-PrDiff $(Build.ArtifactStagingDirectory)/diff/diff.json
61+
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
62+
pwsh: true
63+
64+
- ${{ else }}:
65+
- task: Powershell@2
66+
displayName: Save package properties with dev version
67+
condition: and(succeeded(), eq(variables['SetDevVersion'],'true'))
68+
inputs:
69+
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Save-Package-Properties.ps1
70+
arguments: >
71+
-ServiceDirectory ${{parameters.ServiceDirectory}}
72+
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
73+
-AddDevVersion
74+
pwsh: true
75+
- task: Powershell@2
76+
displayName: Save package properties for service
77+
condition: and(succeeded(), ne(variables['SetDevVersion'],'true'))
78+
inputs:
79+
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Save-Package-Properties.ps1
80+
arguments: >
81+
-ServiceDirectory ${{parameters.ServiceDirectory}}
82+
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
83+
pwsh: true
84+
85+
- task: Powershell@2
86+
displayName: "Test Packages"
87+
condition: and(succeeded(), ne(variables['NoPackagesChanged'],'true'))
88+
timeoutInMinutes: ${{ parameters.TestTimeoutInMinutes }}
89+
env:
90+
CIBW_BUILD_VERBOSITY: 3
91+
inputs:
92+
pwsh: true
93+
filePath: $(Build.SourcesDirectory)/eng/scripts/Test-Packages.ps1
94+
arguments: >
95+
-PackageInfoPath '(Build.ArtifactStagingDirectory)/PackageInfo'
96+
-Toolchain '$(Toolchain)'
97+
-UnitTests $${{ parameters.UnitTests }}
98+
-FunctionalTests $${{ parameters.FunctionalTests }}
99+
100+
- ${{ if parameters.PublishArtifacts}}:
101+
- template: /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
102+
parameters:
103+
ArtifactPath: "$(Build.ArtifactStagingDirectory)"
104+
ArtifactName: "packages_${{ parameters.ArtifactSuffix }}"
105+
CustomCondition: and(succeeded(), ne(variables['NoPackagesChanged'],'true'))

0 commit comments

Comments
 (0)