Skip to content

Commit 2f3a980

Browse files
authored
Update avocado with a compliant release stage (#135)
* update avocado with the 1es template stuff
1 parent 00f44b5 commit 2f3a980

6 files changed

Lines changed: 289 additions & 86 deletions

File tree

azure-pipelines.yml

Lines changed: 122 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,127 @@
11
trigger:
22
- main
3-
4-
variables:
5-
Codeql.Enabled: true
6-
7-
jobs:
8-
- job: Test
9-
strategy:
10-
matrix:
11-
Linux.Node10:
12-
node.version: 10.x
13-
vm.image: 'ubuntu-20.04'
14-
Linux.Node12:
15-
node.version: 12.x
16-
vm.image: 'ubuntu-20.04'
17-
Win.Node10:
18-
node.version: 10.x
19-
vm.image: 'windows-2019'
20-
Win.Node12:
21-
node.version: 12.x
22-
vm.image: 'windows-2019'
23-
pool:
24-
vmImage: $(vm.image)
25-
steps:
26-
- task: NodeTool@0
27-
displayName: 'Install Node'
28-
inputs:
29-
versionSpec: $(node.version)
30-
- script: npm install
31-
- task: Npm@1
32-
displayName: 'npm test'
33-
inputs:
34-
command: custom
35-
verbose: false
36-
customCommand: test
37-
- task: PublishTestResults@2
38-
condition: succeededOrFailed()
39-
inputs:
40-
testResultsFiles: '**/test-results.xml'
41-
testRunTitle: 'Test results for JavaScript'
42-
- task: PublishCodeCoverageResults@1
43-
condition: succeededOrFailed()
44-
inputs:
45-
codeCoverageTool: Cobertura
46-
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
47-
reportDirectory: '$(System.DefaultWorkingDirectory)/**/coverage'
48-
- job: Build
49-
pool:
50-
vmImage: 'ubuntu-22.04'
51-
steps:
52-
- task: Npm@1
53-
displayName: 'npm pack'
54-
inputs:
55-
command: custom
56-
verbose: false
57-
customCommand: pack
58-
- task: CopyFiles@2
59-
displayName: 'Copy Files to: drop'
60-
inputs:
61-
Contents: '*.tgz'
62-
TargetFolder: drop
63-
- task: PublishBuildArtifacts@1
64-
inputs:
65-
pathtoPublish: $(Build.SourcesDirectory)/drop
663

67-
- job: Windows
68-
pool:
69-
vmImage: 'windows-2019'
4+
extends:
5+
template: /eng/1es-redirect.yml
6+
parameters:
7+
stages:
8+
- stage: Build_And_Test
9+
displayName: 'Build and Test'
7010

71-
steps:
72-
- task: ea576cd4-c61f-48f8-97e7-a3cb07b90a6f@2 # CredScan@2
73-
inputs:
74-
toolMajorVersion: 'V2'
11+
variables:
12+
- template: /eng/image.yml
7513

76-
- task: f5679091-e6da-4974-a8dc-0eec03a8ea63@1 # PostAnalysis@1
77-
inputs:
78-
AllTools: false
79-
APIScan: false
80-
BinSkim: false
81-
CodesignValidation: false
82-
CredScan: true
83-
FortifySCA: false
84-
FxCop: false
85-
ModernCop: false
86-
PoliCheck: false
87-
RoslynAnalyzers: false
88-
SDLNativeRules: false
89-
Semmle: false
90-
TSLint: false
91-
ToolLogsNotFoundAction: 'Standard'
14+
jobs:
15+
- job: Build
16+
pool:
17+
image: $(LINUXVMIMAGE)
18+
name: $(LINUXPOOL)
19+
os: linux
20+
steps:
21+
- task: Npm@1
22+
displayName: 'npm pack'
23+
inputs:
24+
command: custom
25+
verbose: false
26+
customCommand: pack
27+
28+
- task: CopyFiles@2
29+
displayName: 'Copy Files to: drop'
30+
inputs:
31+
Contents: '*.tgz'
32+
TargetFolder: $(Build.ArtifactStagingDirectory)
33+
34+
- template: /eng/publish-1es-artifact.yml
35+
parameters:
36+
artifactName: 'drop'
37+
artifactPath: '$(Build.ArtifactStagingDirectory)'
38+
39+
- job: Test_Windows
40+
strategy:
41+
matrix:
42+
Win.Node10:
43+
node.version: 10.x
44+
Win.Node12:
45+
node.version: 12.x
46+
pool:
47+
image: $(WINDOWSVMIMAGE)
48+
name: $(WINDOWSPOOL)
49+
os: windows
50+
steps:
51+
- template: /eng/test-steps.yml
52+
parameters:
53+
version: $(node.version)
54+
55+
- job: Test_Linux
56+
strategy:
57+
matrix:
58+
Linux.Node10:
59+
node.version: 10.x
60+
Linux.Node12:
61+
node.version: 12.x
62+
pool:
63+
image: $(LINUXVMIMAGE)
64+
name: $(LINUXPOOL)
65+
os: linux
66+
steps:
67+
- template: /eng/test-steps.yml
68+
parameters:
69+
version: $(node.version)
70+
71+
# only include if running on `internal` build with manual queue, otherwise never include
72+
- ${{ if and(in(variables['Build.Reason'], 'Manual', ''), eq(variables['System.TeamProject'], 'internal'))}}:
73+
- stage: Publish
74+
displayName: Publish
75+
dependsOn: Build_And_Test
76+
77+
jobs:
78+
- deployment: Publish
79+
environment: 'package-publish'
80+
pool:
81+
name: azsdk-pool-mms-ubuntu-2004-general
82+
image: azsdk-pool-mms-ubuntu-2004-1espt
83+
os: linux
84+
85+
strategy:
86+
runOnce:
87+
deploy:
88+
steps:
89+
- checkout: self
90+
submodules: false
91+
92+
- download: current
93+
artifact: drop
94+
timeoutInMinutes: 5
95+
96+
- task: PowerShell@2
97+
inputs:
98+
filePath: '$(Build.SourcesDirectory)/eng/scripts/determine-release-tag.ps1'
99+
failOnStderr: true
100+
pwsh: true
101+
102+
- pwsh: |
103+
Write-Host "Will deploy with tag of $(Tag)"
104+
Get-ChildItem "$(Pipeline.Workspace)/drop" -Recurse -Force `
105+
| Where-Object { $_.Name -like "*.tgz" } `
106+
| Copy-Item -Destination "$(Build.ArtifactStagingDirectory)"
107+
108+
Get-ChildItem "$(Build.ArtifactStagingDirectory)" -Recurse -Force | % { Write-Host $_.FullName }
109+
displayName: Move artifact to $(Build.ArtifactStagingDirectory)
110+
111+
- task: EsrpRelease@7
112+
inputs:
113+
displayName: 'Publish oav to ESRP'
114+
ConnectedServiceName: 'Azure SDK Engineering System'
115+
ClientId: '5f81938c-2544-4f1f-9251-dd9de5b8a81b'
116+
KeyVaultName: 'AzureSDKEngKeyVault'
117+
AuthCertName: 'azure-sdk-esrp-release-auth-certificate'
118+
SignCertName: 'azure-sdk-esrp-release-sign-certificate'
119+
Intent: 'PackageDistribution'
120+
ContentType: 'npm'
121+
FolderLocation: $(Build.ArtifactStagingDirectory)
122+
Owners: ${{ coalesce(variables['Build.RequestedForEmail'], 'azuresdk@microsoft.com') }}
123+
Approvers: 'azuresdk@microsoft.com'
124+
ServiceEndpointUrl: 'https://api.esrp.microsoft.com'
125+
MainPublisher: 'ESRPRELPACMANTEST'
126+
DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47'
127+
productstate: $(Tag)

eng/1es-redirect.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
git:
41+
longpaths: true
42+
submodules: false
43+
sourceRepositoriesToScan:
44+
include:
45+
- repository: self
46+
submodule: false
47+
runInSingleJob: true
48+
sourceAnalysisPool:
49+
name: azsdk-pool-mms-win-2022-general
50+
image: azsdk-pool-mms-win-2022-1espt
51+
os: windows
52+
eslint:
53+
enabled: false
54+
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/azur 19 e-sdk/internal/_build/results?buildId=3556850"
55+
codeql:
56+
compiled:
57+
enabled: false
58+
justificationForDisabling: "CodeQL times our pipelines out by running for 2+ hours before being force canceled."
59+
psscriptanalyzer:
60+
compiled: true
61+
break: true
62+
policy: M365
63+
64+
stages: ${{ parameters.stages }}

eng/image.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Default pool image selection. Set as variable so we can override at pipeline level
2+
3+
variables:
4+
- name: LINUXPOOL
5+
value: azsdk-pool-mms-ubuntu-2004-general
6+
- name: WINDOWSPOOL
7+
value: azsdk-pool-mms-win-2022-general
8+
- name: MACPOOL
9+
value: Azure Pipelines
10+
11+
- name: LINUXVMIMAGE
12+
value: azsdk-pool-mms-ubuntu-2004-1espt
13+
- name: LINUXNEXTVMIMAGE
14+
value: ubuntu-22.04
15+
- name: WINDOWSVMIMAGE
16+
value: azsdk-pool-mms-win-2022-1espt
17+
- name: MACVMIMAGE
18+
value: macos-11
19+
20+
# Values required for pool.os field in 1es pipeline templates
21+
- name: LINUXOS
22+
value: linux
23+
- name: WINDOWSOS
24+
value: windows
25+
- name: MACOS
26+
value: macOS

eng/publish-1es-artifact.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This step is used to prevent duplication of artifact publishes when there is an issue that would prevent the overall success of the job.
2+
# Ensuring that we only publish when successful (and two a differently named artifact otherwise) will allow easy retry on a build pipeline
3+
# without running into the "cannot override artifact" failure when we finally do get a passing run.
4+
5+
# ArtifactName - The name of the artifact in the "successful" case.
6+
# ArtifactPath - The path we will be publishing.
7+
# CustomCondition - Used if there is additional logic necessary to prevent attempt of publish.
8+
# SbomEnabled - Set whether to auto-inject 1es pipeline template sbom tasks
9+
10+
parameters:
11+
ArtifactName: ''
12+
ArtifactPath: ''
13+
CustomCondition: true
14+
SbomEnabled: true
15+
16+
steps:
17+
- pwsh: |
18+
if ($env:AGENT_JOBSTATUS -eq "Failed") {
19+
Write-Host "##vso[task.setvariable variable=PublishArtifactName;]${{ parameters.ArtifactName }}-FailedAttempt$(System.JobAttempt)"
20+
} else {
21+
Write-Host "##vso[task.setvariable variable=PublishArtifactName;]${{ parameters.ArtifactName }}"
22+
}
23+
condition: and(succeededOrFailed(), ${{ parameters.CustomCondition }})
24+
displayName: Set Artifact Name $(Agent.JobStatus)
25+
26+
- task: 1ES.PublishPipelineArtifact@1
27+
condition: and(succeededOrFailed(), ${{ parameters.CustomCondition }})
28+
displayName: 'Publish ${{ parameters.ArtifactName }} Artifacts'
29+
inputs:
30+
artifactName: '$(PublishArtifactName)'
31+
targetPath: '${{ parameters.ArtifactPath }}'
32+
sbomEnabled: ${{ parameters.SbomEnabled }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Read the package.json file
2+
$packageJsonPath = "$PSScriptRoot/../../package.json"
3+
$packageJson = Get-Content $packageJsonPath -Raw | ConvertFrom-Json
4+
5+
# Function to check if a version is non-GA
6+
function Is-NonGA($version) {
7+
return $version -match "-(alpha|beta|rc|pre)"
8+
}
9+
10+
$pkgVersion = $packageJson.version
11+
12+
if (Is-NonGA($pkgVersion)) {
13+
Write-Host "##vso[task.setvariable variable=Tag;]beta"
14+
}
15+
else {
16+
Write-Host "##vso[task.setvariable variable=Tag;]latest"
17+
}
18+

eng/test-steps.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
parameters:
2+
- name: version
3+
type: string
4+
5+
steps:
6+
- task: NodeTool@0
7+
displayName: 'Install Node'
8+
inputs:
9+
versionSpec: ${{ parameters.version }}
10+
- script: npm install
11+
- task: Npm@1
12+
displayName: 'npm test'
13+
inputs:
14+
command: custom
15+
verbose: false
16+
customCommand: test
17+
- task: PublishTestResults@2
18+
condition: succeededOrFailed()
19+
inputs:
20+
testResultsFiles: '**/test-results.xml'
21+
testRunTitle: 'Test results for JavaScript'
22+
- task: PublishCodeCoverageResults@1
23+
condition: succeededOrFailed()
24+
inputs:
25+
codeCoverageTool: Cobertura
26+
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
27+
reportDirectory: '$(System.DefaultWorkingDirectory)/**/coverage'

0 commit comments

Comments
 (0)