Skip to content

Commit a35179e

Browse files
authored
lts: Fix stress tests runs (#26096)
## Description For a while, the runs of the stress tests pipeline in the LTS branch have been broken for different reasons. This PR addresses them all so we can continue running that pipeline for the LTS branch. Main changes: - Bring in the template file that configures our centralized ADO feed to download dependencies. - Replace the Npm tasks with Bash tasks that use pnpm. Npm tasks don't respect the configuration done by the previous bullet point. - Fix path for package in the artifact (we replaced `scoped/unscoped` with `tarballs` in build-tools a while back). - Pin the dependency on an internal package (oteljs) to a version that doesn't cause issues in our LTS branch, where ESM vs CJS is not cleaned up like in main. - Update Node from 20.15.1 to 20.19.0 to match main (and we know it fixes a couple of issues with module resolution). Fixes [AB#54754](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/54754) and [AB#54755](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/54755), plus some other issues hiding behind those.
1 parent f9d49d5 commit a35179e

File tree

2 files changed

+121
-42
lines changed

2 files changed

+121
-42
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright (c) Microsoft Corporation and contributors. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
# Creates an .npmrc file which uses the appropriate feeds from our ADO
5+
# org to download packages from the right locations, adds the necessary authentication to it, and sets configuration so
6+
# for the rest of the job execution all invocations of npm (EXCEPT installs through Npm@ tasks) use it.
7+
# The file is created in a "global" location that should not interfere with anything else.
8+
#
9+
# Npm@ tasks always override the user-level .npmrc file with one of their own, so they do not work with this
10+
# configuration. For that reason, using them to install dependencies should be avoided. Using them for other kinds
11+
# of npm invocations should be fine.
12+
13+
parameters:
14+
# Location for the .npmrc file.
15+
- name: userNpmrcDirectory
16+
type: string
17+
default: $(Agent.TempDirectory)/global-download-npmrc
18+
19+
steps:
20+
# Force a parsing error so the pipeline run cannot even start if the conditions are incorrect for the use of this template.
21+
# Note this will always show up as a syntax error/warning (squiggly line) in IDEs that validate the structure of the
22+
# pipeline YAML file.
23+
- ${{ if ne(variables['System.TeamProject'], 'internal')}}:
24+
- "Something tried to use the 'include-setup-npmrc-for-download.yml' template outside the 'internal' ADO project. This is not supported."
25+
26+
- task: Bash@3
27+
displayName: Ensure necessary values exist
28+
inputs:
29+
targetType: 'inline'
30+
script: |
31+
set -eu -o pipefail
32+
33+
if [ -z "$(ado-feeds-ff-download-only)" ]; then
34+
echo "##vso[task.logissue type=error]Runtime variable 'ado-feeds-ff-download-only' must have a value. Make sure the 'ado-feeds' variable group is in scope."
35+
exit 1
36+
fi
37+
38+
- task: Bash@3
39+
displayName: Initialize .npmrc
40+
inputs:
41+
targetType: 'inline'
42+
script: |
43+
set -eu -o pipefail
44+
45+
mkdir -p ${{ parameters.userNpmrcDirectory }}
46+
cd ${{ parameters.userNpmrcDirectory }}
47+
48+
echo "Generating .npmrc"
49+
50+
# Default feed that contains all our internal builds and mirrors external sources like npm.
51+
echo "registry=$(ado-feeds-ff-download-only)" >> ./.npmrc
52+
echo "always-auth=true" >> ./.npmrc
53+
cat .npmrc
54+
55+
- task: npmAuthenticate@0
56+
displayName: 'Authenticate to internal ADO feeds'
57+
retryCountOnTaskFailure: 1
58+
inputs:
59+
workingFile: ${{ parameters.userNpmrcDirectory }}/.npmrc
60+
61+
- task: Bash@3
62+
displayName: Use the authenticated .npmrc file globally
63+
inputs:
64+
targetType: 'inline'
65+
script: |
66+
TARGET_FILE=${{ parameters.userNpmrcDirectory }}/.npmrc
67+
68+
# Configure the copied file to be the default user-level .npmrc file, so all invocations of npm use it.
69+
# Particularly relevant for the ones that occur when we install older version for compat tests.
70+
echo "Setting NPM_CONFIG_USERCONFIG to '$TARGET_FILE'"
71+
echo "##vso[task.setvariable variable=NPM_CONFIG_USERCONFIG]$TARGET_FILE"

tools/pipelines/templates/include-test-real-service.yml

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
pool: ${{ parameters.poolBuild }}
5858
timeoutInMinutes: ${{ parameters.timeoutInMinutes }}
5959
variables:
60+
- group: ado-feeds
6061
# We use 'chalk' to colorize output, which auto-detects color support in the
6162
# running terminal. The log output shown in Azure DevOps job runs only has
6263
# basic ANSI color support though, so force that in the pipeline
@@ -67,7 +68,7 @@ jobs:
6768
- name: testPackageFilePattern
6869
value: ${{ replace(replace(parameters.testPackage, '@', '' ), '/', '-') }}-*.tgz
6970
- name: testPackagePathPattern
70-
value: $(Pipeline.Workspace)/client/pack/scoped/${{ variables.testPackageFilePattern }}
71+
value: $(Pipeline.Workspace)/client/pack/tarballs/${{ variables.testPackageFilePattern }}
7172
- name: skipComponentGovernanceDetection
7273
value: true
7374
- ${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/test/') }}:
@@ -129,16 +130,15 @@ jobs:
129130
130131
# Install
131132
- task: UseNode@1
132-
displayName: Use Node 20.15.1
133+
displayName: Use Node 20.19.0
133134
inputs:
134-
version: 20.15.1
135-
- task: Npm@1
136-
displayName: Install npm 10
137-
retryCountOnTaskFailure: 4
138-
inputs:
139-
command: 'custom'
140-
customCommand: 'install --global npm@^10'
141-
customRegistry: 'useNpmrc'
135+
version: 20.19.0
136+
137+
- template: /tools/pipelines/templates/include-install-pnpm.yml@self
138+
parameters:
139+
buildDirectory: $(Pipeline.Workspace)
140+
141+
- template: /tools/pipelines/templates/include-setup-npmrc-for-download.yml@self
142142

143143
# Download artifact
144144
- task: DownloadPipelineArtifact@2
@@ -169,43 +169,51 @@ jobs:
169169
targetType: 'inline'
170170
workingDirectory: ${{ parameters.testWorkspace }}
171171
script: |
172-
echo Initialize package
173-
npm init --yes
174-
175-
echo Generating .npmrc
176-
echo "registry=https://registry.npmjs.org" >> ./.npmrc
177-
echo "always-auth=false" >> ./.npmrc
178-
179-
echo "@fluidframework:registry=${{ variables.feed }}" >> ./.npmrc
180-
echo "@fluid-experimental:registry=${{ variables.feed }}" >> ./.npmrc
181-
echo "@fluid-internal:registry=${{ variables.feed }}" >> ./.npmrc
182-
echo "@ff-internal:registry=https://pkgs.dev.azure.com/fluidframework/internal/_packaging/build/npm/registry/" >> ./.npmrc
183-
echo "@microsoft:registry=https://pkgs.dev.azure.com/fluidframework/internal/_packaging/office/npm/registry/" >> ./.npmrc
184-
echo "always-auth=true" >> ./.npmrc
185-
cat .npmrc
186-
172+
set -eu -o pipefail
187173
if [[ `ls -1 ${{ variables.testPackagePathPattern }} | wc -l` -eq 1 ]]; then
188174
echo "##vso[task.setvariable variable=testPackageTgz;isOutput=true]`ls ${{ variables.testPackagePathPattern }}`"
189175
else
190176
ls -1 ${{ variables.testPackagePathPattern }}
191177
echo "##vso[task.logissue type=error]Test package '${{ parameters.testPackage }}' not found, or there are more then one found"
192178
fi
193179
194-
# Auth to internal feed
195-
- task: npmAuthenticate@0
196-
displayName: 'npm authenticate (internal feed)'
180+
181+
# Pin oteljs to a version that doesn't depend on packages that cause issues in our LTS branch
182+
# because they expect everything to be ESM, which we're not using yet in LTS (we probably can't make such a big
183+
# change to how the packages work in LTS, it would almost certainly result in some breaking changes).
184+
# Note that it needs to be done before running `pnpm install` so that the override is respected during installation.
185+
- task: Bash@3
186+
displayName: 'Add pnpm override for @microsoft/[email protected]'
197187
inputs:
198-
workingFile: ${{ parameters.testWorkspace }}/.npmrc
188+
targetType: 'inline'
189+
workingDirectory: ${{ parameters.testWorkspace }}
190+
script: |
191+
# Init first so package.json exists.
192+
pnpm init
193+
# Apply override
194+
node -e "
195+
const fs = require('fs');
196+
const pkgPath = './package.json';
197+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
198+
pkg.pnpm = pkg.pnpm || {};
199+
pkg.pnpm.overrides = pkg.pnpm.overrides || {};
200+
pkg.pnpm.overrides['@microsoft/oteljs'] = '4.20.30';
201+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
202+
"
199203
200204
# Install test and logger package
201-
- task: Npm@1
202-
displayName: 'npm install'
203-
retryCountOnTaskFailure: 4
205+
# Use a Bash@3 task instead of Npm@1 so we can use pnpm, which will respect the .npmrc file configured globally earlier
206+
- task: Bash@3
207+
displayName: 'pnpm install'
208+
# ADO feeds have latency on the order of minutes before packages are available downstream. See:
209+
# https://learn.microsoft.com/en-us/azure/devops/artifacts/concepts/upstream-sources?view=azure-devops#upstream-sources-health-status
210+
# This pipeline installs packages which were published very recently relative to its runtime, hence the rather high retry count here.
211+
retryCountOnTaskFailure: 10
204212
inputs:
205-
command: 'custom'
206-
workingDir: ${{ parameters.testWorkspace }}
207-
customCommand: 'install $(Initialize.testPackageTgz) @ff-internal/aria-logger'
208-
customRegistry: 'useNpmrc'
213+
targetType: 'inline'
214+
workingDirectory: ${{ parameters.testWorkspace }}
215+
script: |
216+
pnpm install $(Initialize.testPackageTgz) @ff-internal/aria-logger
209217
210218
# Download Test Files & Install Extra Dependencies
211219
# These steps are intended to include extra dependencies that are not available as
@@ -238,14 +246,14 @@ jobs:
238246
239247
- ${{ if ne(parameters.extraDependencies, 'null') }}:
240248
# Install extra dependencies for test files
241-
- task: Npm@1
242-
displayName: 'npm install - extra dependencies for test files'
249+
# Use a Bash@3 task instead of Npm@1 so we can use pnpm, which will respect the .npmrc file configured globally earlier
250+
- task: Bash@3
251+
displayName: 'pnpm install - extra dependencies for test files'
243252
retryCountOnTaskFailure: 4
244253
inputs:
245-
command: 'custom'
246-
workingDir: ${{ parameters.testWorkspace }}
247-
customCommand: 'install ${{ parameters.extraDependencies }}'
248-
customRegistry: 'useNpmrc'
254+
targetType: 'inline'
255+
workingDirectory: ${{ parameters.testWorkspace }}
256+
script: 'pnpm install ${{ parameters.extraDependencies }}'
249257

250258
# run the test
251259
- task: Npm@1

0 commit comments

Comments
 (0)