Skip to content

Commit 131180e

Browse files
scottn12Copilot
andauthored
security: Use governed template for LTS build pipeline (#25931)
## Description This PR updates the build pipeline on the LTS branch to use governed templates. ## Reviewer Guidance - The 1ES injected steps occur multiple times in the pipeline run. I think this may be because they are supposed to run after each published artifact, so this may be okay. ## Misc [AB#53960](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/53960) --------- Co-authored-by: Copilot <[email protected]>
1 parent ffd8c55 commit 131180e

File tree

2 files changed

+95
-97
lines changed

2 files changed

+95
-97
lines changed

tools/pipelines/build-client.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,5 @@ extends:
115115
poolBuild: Large-eastus2
116116
cgSubDirectory: packages
117117
checkoutSubmodules: true
118-
taskBundleAnalysis: true
118+
taskBundleAnalysis: true
119+
shouldShip: ${{ or(eq(variables['release'], 'release'), eq(variables['release'], 'prerelease')) }}

tools/pipelines/templates/build-npm-package.yml

Lines changed: 93 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -99,37 +99,97 @@ parameters:
9999
type: string
100100
default: "^"
101101

102-
trigger: none
103-
104-
variables:
105-
# We use 'chalk' to colorize output, which auto-detects color support in the
106-
# running terminal. The log output shown in Azure DevOps job runs only has
107-
# basic ANSI color support though, so force that in the pipeline
108-
- name: FORCE_COLOR
109-
value: 1
110-
- template: include-vars.yml
111-
parameters:
112-
publishOverride: '${{ parameters.publishOverride }}'
113-
releaseBuildOverride: '${{ parameters.releaseBuildOverride }}'
114-
115-
stages:
116-
# Install / Build / Test Stage
117-
- stage: build
118-
displayName: Build Stage
119-
jobs:
102+
# Indicates if this is a release build that should be shipped to arrow.
103+
- name: shouldShip
104+
type: boolean
105+
default: false
106+
107+
resources:
108+
repositories:
109+
- repository: 1ESPipelineTemplates
110+
type: git
111+
name: 1ESPipelineTemplates/1ESPipelineTemplates
112+
ref: refs/tags/release
113+
114+
extends:
115+
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
116+
parameters:
117+
pool:
118+
name: Small-eastus2
119+
os: linux
120+
sdl:
121+
${{ if eq(variables['System.TeamProject'], 'internal') }}:
122+
arrow:
123+
# This is the service connection for the Arrow Service Connection in FluidFramework Azure DevOps organization
124+
serviceConnection: ff-internal-arrow-sc
125+
# This will make sure that the artifacts are published to the Arrow Service Connection if they are release or pre-release
126+
isShipped: ${{ parameters.shouldShip }}
127+
sourceAnalysisPool:
128+
name: Azure-Pipelines-1ESPT-ExDShared
129+
image: windows-2022
130+
os: windows
131+
# Tentative workaround for the occasional Credscan failures
132+
credscan:
133+
batchSize: 4
134+
# Skip tagging if Github PR coming from a fork; This skips Microsoft security checks that won't work on forks.
135+
settings:
136+
skipBuildTagsForGitHubPullRequests: true
137+
customBuildTags:
138+
- ES365AIMigrationTooling
139+
stages:
140+
# Install / Build / Test Stage
141+
- stage: build
142+
displayName: Build Stage
143+
jobs:
120144
# Job - Build
121145
- job: build
122146
displayName: Build
123147
pool: ${{ parameters.poolBuild }}
124148
variables:
125-
- group: ado-feeds
126-
- group: storage-vars
127-
# Coverage has quality issues in LTS, and root-causing + fixing is not a priority given changes to LTS at this point
128-
# will be things like upgrading node or security fixes, not adding new features.
129-
- name: testCoverage
130-
value: false
131-
- name: releaseBuildVar
132-
value: $[variables.releaseBuild]
149+
# We use 'chalk' to colorize output, which auto-detects color support in the
150+
# running terminal. The log output shown in Azure DevOps job runs only has
151+
# basic ANSI color support though, so force that in the pipeline
152+
- name: FORCE_COLOR
153+
value: 1
154+
- template: /tools/pipelines/templates/include-vars.yml@self
155+
parameters:
156+
publishOverride: '${{ parameters.publishOverride }}'
157+
releaseBuildOverride: '${{ parameters.releaseBuildOverride }}'
158+
- group: ado-feeds
159+
- group: storage-vars
160+
# Coverage has quality issues in LTS, and root-causing + fixing is not a priority given changes to LTS at this point
161+
# will be things like upgrading node or security fixes, not adding new features.
162+
- name: testCoverage
163+
value: false
164+
- name: releaseBuildVar
165+
value: $[variables.releaseBuild]
166+
templateContext:
167+
outputs:
168+
- ${{ if ne(parameters.taskPack, false) }}:
169+
- output: pipelineArtifact
170+
displayName: 'Publish Artifact - pack'
171+
targetPath: '$(Build.ArtifactStagingDirectory)/pack'
172+
artifactName: 'pack'
173+
publishLocation: 'Container'
174+
- ${{ if ne(parameters.taskPack, false) }}:
175+
- output: pipelineArtifact
176+
displayName: 'Publish Artifact - Test Files'
177+
targetPath: '$(Build.ArtifactStagingDirectory)/test-files'
178+
artifactName: 'test-files'
179+
publishLocation: 'Container'
180+
- ${{ if eq(parameters.taskBundleAnalysis, true) }}:
181+
- output: pipelineArtifact
182+
displayName: 'Publish Artifacts - bundle-analysis'
183+
condition: and( succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(${{ parameters.taskPublishBundleSizeArtifacts }}, true) )
184+
targetPath: '${{ parameters.buildDirectory }}/artifacts/bundleAnalysis'
185+
artifactName: 'bundleAnalysis'
186+
publishLocation: 'Container'
187+
- ${{ if ne(parameters.taskBuildDocs, false) }}:
188+
- output: pipelineArtifact
189+
displayName: 'Publish Artifact - _api-extractor-temp'
190+
targetPath: '${{ parameters.buildDirectory }}/_api-extractor-temp'
191+
artifactName: '_api-extractor-temp'
192+
publishLocation: 'Container'
133193
steps:
134194
# Setup
135195
- checkout: self
@@ -227,7 +287,7 @@ stages:
227287
packageManagerInstallCommand: '${{ parameters.packageManagerInstallCommand }}'
228288

229289
# Set version
230-
- template: include-set-package-version.yml@self
290+
- template: /tools/pipelines/templates/include-set-package-version.yml@self
231291
parameters:
232292
buildDirectory: ${{ parameters.buildDirectory }}
233293
buildNumberInPatch: ${{ parameters.buildNumberInPatch }}
@@ -252,7 +312,6 @@ stages:
252312
command: 'custom'
253313
workingDir: ${{ parameters.buildDirectory }}
254314
customCommand: 'run lint'
255-
256315
# Test
257316
- ${{ if ne(parameters.taskTest, 'false') }}:
258317
# Run any additional tests first so their results can be copied to the ~/nyc dir and published below
@@ -328,20 +387,6 @@ stages:
328387
workingDirectory: '${{ parameters.buildDirectory }}'
329388
filePath: $(Build.SourcesDirectory)/scripts/pack-packages.sh
330389

331-
- task: PublishBuildArtifacts@1
332-
displayName: Publish Artifact - pack
333-
inputs:
334-
PathtoPublish: '$(Build.ArtifactStagingDirectory)/pack'
335-
ArtifactName: 'pack'
336-
publishLocation: 'Container'
337-
338-
- task: PublishBuildArtifacts@1
339-
displayName: Publish Artifact - Test Files
340-
inputs:
341-
PathtoPublish: '$(Build.ArtifactStagingDirectory)/test-files'
342-
ArtifactName: 'test-files'
343-
publishLocation: 'Container'
344-
345390
# Collect/publish/run bundle analysis
346391
- ${{ if eq(parameters.taskBundleAnalysis, true) }}:
347392
- task: Npm@1
@@ -350,28 +395,9 @@ stages:
350395
command: 'custom'
351396
workingDir: ${{ parameters.buildDirectory }}
352397
customCommand: 'run bundle-analysis:collect'
353-
354-
- task: PublishBuildArtifacts@1
355-
displayName: Publish Artifacts - bundle-analysis
356-
condition:
357-
and(
358-
succeeded(),
359-
ne(variables['Build.Reason'], 'PullRequest'),
360-
eq(${{ parameters.taskPublishBundleSizeArtifacts }}, true)
361-
)
362-
inputs:
363-
PathtoPublish: '${{ parameters.buildDirectory }}/artifacts/bundleAnalysis'
364-
Artifactname: 'bundleAnalysis'
365-
publishLocation: 'Container'
366-
367398
- task: Npm@1
368399
displayName: run bundle size comparison
369-
condition:
370-
and(
371-
succeeded(),
372-
eq(variables['Build.Reason'], 'PullRequest'),
373-
ne(variables['System.PullRequest.IsFork'], 'true')
374-
)
400+
condition: and( succeeded(), eq(variables['Build.Reason'], 'PullRequest'), ne(variables['System.PullRequest.IsFork'], 'true') )
375401
continueOnError: true
376402
env:
377403
ADO_API_TOKEN: $(System.AccessToken)
@@ -390,14 +416,6 @@ stages:
390416
command: 'custom'
391417
workingDir: ${{ parameters.buildDirectory }}
392418
customCommand: 'run ci:build:docs'
393-
394-
- task: PublishBuildArtifacts@1
395-
displayName: Publish Artifact - _api-extractor-temp
396-
inputs:
397-
PathtoPublish: '${{ parameters.buildDirectory }}/_api-extractor-temp'
398-
ArtifactName: '_api-extractor-temp'
399-
publishLocation: 'Container'
400-
401419
- task: Bash@3
402420
displayName: Check for extraneous modified files
403421
inputs:
@@ -410,29 +428,8 @@ stages:
410428
exit -1;
411429
fi
412430
413-
# Job - Component detection
414-
- ${{ if eq(variables.componentDetection, true) }}:
415-
- job: CG
416-
displayName: Component Detection
417-
pool: ${{ parameters.poolCG }}
418-
steps:
419-
- checkout: self
420-
clean: true
421-
lfs: false
422-
submodules: false
423-
424-
- ${{ parameters.preCG }}
425-
426-
- task: ComponentGovernanceComponentDetection@0
427-
displayName: Component Detection
428-
inputs:
429-
sourceScanPath: ${{ parameters.buildDirectory }}/${{ parameters.cgSubDirectory }}
430-
verbosity: Verbose
431-
scanType: Register
432-
alertWarningLevel: High
433-
434-
# Publish stage
435-
- ${{ if eq(variables.publish, true) }}:
436-
- template: include-publish-npm-package.yml
437-
parameters:
438-
tagName: ${{ parameters.tagName }}
431+
# Publish stage
432+
- ${{ if eq(variables.publish, true) }}:
433+
- template: /tools/pipelines/templates/include-publish-npm-package.yml@self
434+
parameters:
435+
tagName: ${{ parameters.tagName }}

0 commit comments

Comments
 (0)