Skip to content

Commit 57e265c

Browse files
Abe27342Abram Sanderson
andauthored
Use secondary repository checkout in performance benchmarks pipeline (#25550)
## Description Follow-up to #25535 which applies the same kind of change to the performance benchmarks pipeline template. Test run: [here](https://dev.azure.com/fluidframework/internal/_build/results?buildId=357522&view=results) --------- Co-authored-by: Abram Sanderson <[email protected]>
1 parent 0e9a1b9 commit 57e265c

File tree

14 files changed

+153
-145
lines changed

14 files changed

+153
-145
lines changed

packages/dds/map/src/test/memory/.mocharc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
"recursive": true,
1515
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
1616
"reporterOptions": ["reportDir=.memoryTestsOutput/"],
17-
"require": ["node_modules/@fluid-internal/mocha-test-setup"],
17+
"require": ["@fluid-internal/mocha-test-setup"],
1818
"spec": ["dist/test/memory/**/*.spec.*js", "--perfMode"],
1919
"timeout": "60000",
2020
};

packages/dds/matrix/src/test/memory/.mocharc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
"recursive": true,
1515
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
1616
"reporterOptions": ["reportDir=.memoryTestsOutput/"],
17-
"require": ["node_modules/@fluid-internal/mocha-test-setup"],
17+
"require": ["@fluid-internal/mocha-test-setup"],
1818
"spec": ["dist/test/memory/**/*.spec.*js", "--perfMode"],
1919
"timeout": "90000",
2020
};

packages/dds/matrix/src/test/time/.mocharc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
"node-option": ["expose-gc", "gc-global", "unhandled-rejections=strict"], // without leading "--"
1313
"recursive": true,
1414
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
15-
"require": ["node_modules/@fluid-internal/mocha-test-setup"],
15+
"require": ["@fluid-internal/mocha-test-setup"],
1616
"spec": ["dist/test/time/**/*.spec.*js", "--perfMode"],
1717
"timeout": "15000",
1818
};

packages/dds/sequence/src/test/memory/.mocharc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
"recursive": true,
1515
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
1616
"reporterOptions": ["reportDir=.memoryTestsOutput/"],
17-
"require": ["node_modules/@fluid-internal/mocha-test-setup"],
17+
"require": ["@fluid-internal/mocha-test-setup"],
1818
"spec": ["dist/test/memory/**/*.spec.*js", "--perfMode"],
1919
"timeout": "60000",
2020
};

packages/test/test-end-to-end-tests/src/test/benchmark/.mocharc.memory.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const newConfig = {
1818
"recursive": true,
1919
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
2020
"reporterOptions": ["reportDir=.memoryTestsOutput/"],
21-
"require": [...config.require, "node_modules/@fluid-internal/mocha-test-setup"],
21+
"require": [...config.require, "@fluid-internal/mocha-test-setup"],
2222
"spec": [
2323
"lib/test/benchmark/**/*.memory.spec.*js",
2424
"lib/test/benchmark/**/*.all.spec.*js",

packages/test/test-end-to-end-tests/src/test/benchmark/.mocharc.time.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const newConfig = {
1818
"recursive": true,
1919
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
2020
"reporterOptions": ["reportDir=.timeTestsOutput/"],
21-
"require": [...config.require, "node_modules/@fluid-internal/mocha-test-setup"],
21+
"require": [...config.require, "@fluid-internal/mocha-test-setup"],
2222
"spec": [
2323
"lib/test/benchmark/**/*.time.spec.*js",
2424
"lib/test/benchmark/**/*.all.spec.*js",
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright (c) Microsoft Corporation and contributors. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
# Copy runtime devDependencies from an installed package to somewhere else (usually the root package in the workspace)
5+
# and install them.
6+
# This is useful for test workloads that don't run in the original context of the package (i.e. that need to install it)
7+
# such as the performance benchmarks and e2e test pipelines.
8+
9+
parameters:
10+
- name: sourcePackageLocation
11+
type: string
12+
13+
- name: destPackageLocation
14+
type: string
15+
16+
steps:
17+
# The test workload we are running frequently depends on devDependencies of the package being installed.
18+
# To make sure these are available, copy them to the root package.json and reinstall.
19+
- task: Bash@3
20+
displayName: Copy devDependencies
21+
inputs:
22+
targetType: 'inline'
23+
script: |
24+
set -eu -o pipefail
25+
26+
testPkgJsonPath=${{ parameters.sourcePackageLocation }}/package.json
27+
pkgJsonPath=${{ parameters.destPackageLocation }}/package.json
28+
node -e "
29+
const { devDependencies } = require('$testPkgJsonPath');
30+
const pkg = require('$pkgJsonPath');
31+
if (!pkg.devDependencies) {
32+
pkg.devDependencies = {};
33+
}
34+
// Avoid copying some common dev dependencies that should only be required at build time.
35+
// Keeping the dependency tree small helps reduce job time and likelihood of install failures, since
36+
// dependencies added as part of this step won't be reproducible via pnpm-lock.
37+
const avoidCopying = new Set([
38+
'@types/node',
39+
'typescript',
40+
'@microsoft/api-extractor',
41+
'@fluid-tools/build-cli',
42+
'@fluidframework/build-common',
43+
'@fluidframework/build-tools'
44+
]);
45+
for (const [k, v] of Object.entries(devDependencies)) {
46+
if (!pkg.devDependencies[k] && !avoidCopying.has(k)) {
47+
// Note that if you use string interpolation, bash interpreting the dollar sign takes precedence.
48+
console.log('Adding devDependency ' + k + '@' + v);
49+
pkg.devDependencies[k] = v;
50+
}
51+
}
52+
require('fs').writeFileSync('$pkgJsonPath', JSON.stringify(pkg));
53+
"
54+
55+
- task: Bash@3
56+
displayName: 'pnpm install - extra dependencies for test files'
57+
retryCountOnTaskFailure: 10
58+
inputs:
59+
targetType: 'inline'
60+
script: 'pnpm install --no-frozen-lockfile'

tools/pipelines/templates/include-install.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,21 @@ parameters:
1313
- name: packageManagerInstallCommand
1414
type: string
1515

16+
- name: primaryRegistry
17+
type: string
18+
default: $(ado-feeds-primary-registry)
19+
20+
- name: userNpmrcPath
21+
type: string
22+
default: $(Agent.TempDirectory)/.npmrc
23+
1624
steps:
1725
- ${{ if eq(parameters.packageManager, 'pnpm') }}:
1826
- template: /tools/pipelines/templates/include-install-pnpm.yml@self
1927
parameters:
2028
buildDirectory: ${{ parameters.buildDirectory }}
29+
primaryRegistry: ${{ parameters.primaryRegistry }}
30+
userNpmrcPath: ${{ parameters.userNpmrcPath }}
2131

2232
- task: Bash@3
2333
displayName: Install dependencies

tools/pipelines/templates/include-setup-npmrc-for-download.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
parameters:
1414
# Location for the .npmrc file.
15-
# NOTE: Do not override the default value. It's a parameter just for reusability.
16-
- name: npmrcLocation
15+
- name: userNpmrcDirectory
1716
type: string
1817
default: $(Agent.TempDirectory)/global-download-npmrc
1918

@@ -43,8 +42,8 @@ steps:
4342
script: |
4443
set -eu -o pipefail
4544
46-
mkdir -p ${{ parameters.npmrcLocation }}
47-
cd ${{ parameters.npmrcLocation }}
45+
mkdir -p ${{ parameters.userNpmrcDirectory }}
46+
cd ${{ parameters.userNpmrcDirectory }}
4847
4948
echo "Generating .npmrc"
5049
@@ -57,14 +56,14 @@ steps:
5756
displayName: 'Authenticate to internal ADO feeds'
5857
retryCountOnTaskFailure: 1
5958
inputs:
60-
workingFile: ${{ parameters.npmrcLocation }}/.npmrc
59+
workingFile: ${{ parameters.userNpmrcDirectory }}/.npmrc
6160

6261
- task: Bash@3
6362
displayName: Use the authenticated .npmrc file globally
6463
inputs:
6564
targetType: 'inline'
6665
script: |
67-
TARGET_FILE=${{ parameters.npmrcLocation }}/.npmrc
66+
TARGET_FILE=${{ parameters.userNpmrcDirectory }}/.npmrc
6867
6968
# Configure the copied file to be the default user-level .npmrc file, so all invocations of npm use it.
7069
# Particularly relevant for the ones that occur when we install older version for compat tests.

tools/pipelines/templates/include-test-perf-benchmarks-install-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ steps:
108108
ls -1 $TEST_PACKAGE_PATH_PATTERN
109109
110110
if [[ `ls -1 $TEST_PACKAGE_PATH_PATTERN | wc -l` -eq 1 ]]; then
111-
npm install $(ls $TEST_PACKAGE_PATH_PATTERN)
111+
pnpm install $(ls $TEST_PACKAGE_PATH_PATTERN)
112112
else
113113
echo "##vso[task.logissue type=error]Test package '${{ parameters.testPackageName }}' not found, or more than one possible match found. See messages above."
114114
exit -1

0 commit comments

Comments
 (0)