Skip to content

Commit 6d309f2

Browse files
Abe27342Abram Sanderson
andauthored
Restore compat install caching to include-test-real-service.yaml (#25563)
## Description Follow-up to #25535 which restores the caching of compat dependencies we previously had. Couldn't help myself from making a tweak so the cache key is invalidated on minor version change, which should give us better long-term behavior: the set of versions to install is dynamically computed based on roughly the current package version, so using major+minor here should be a net win as only roughly one build per release should need to install compat dependencies, after that they will be cached. --------- Co-authored-by: Abram Sanderson <absander@microsoft.com>
1 parent 57e265c commit 6d309f2

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,40 @@ stages:
315315
destPackageLocation: $(Build.SourcesDirectory)
316316

317317
- ${{ if eq(parameters.cacheCompatVersionsInstalls, true) }}:
318+
- task: Bash@3
319+
displayName: Compute compat versions install location and version
320+
inputs:
321+
targetType: 'inline'
322+
workingDirectory: $(Build.SourcesDirectory)/node_modules/@fluid-private/test-end-to-end-tests
323+
# Using import.meta.resolve to compute this is more resilient to different install tree types.
324+
# Also note that test-version-utils is esm-only, so cannot be loaded with require.
325+
script: |
326+
set -eu -o pipefail
327+
node --input-type=module -e "
328+
import { createRequire } from 'module';
329+
const require = createRequire(import.meta.url);
330+
const path = require('path');
331+
const versionUtilsIndexUrl = await import.meta.resolve('@fluid-private/test-version-utils');
332+
const basePath = new URL(versionUtilsIndexUrl.replace('/lib/index.js', '')).pathname;
333+
const legacyModulesPath = path.join(basePath, 'node_modules', '.legacy');
334+
console.log('Resolved @fluid-private/test-version-utils legacy modules to ' + legacyModulesPath);
335+
console.log('##vso[task.setvariable variable=compatVersionInstallsPath]' + legacyModulesPath);
336+
const packageJsonPath = path.join(basePath, 'package.json');
337+
const packageJson = require(packageJsonPath);
338+
const packageVersion = packageJson.version;
339+
const [major, minor] = packageVersion.split('.');
340+
const cacheKey = 'major:' + major + ',minor:' + minor;
341+
console.log('Computed compat version cache key: ' + cacheKey);
342+
console.log('##vso[task.setvariable variable=compatVersionCacheKey;]'+ cacheKey);
343+
"
344+
318345
- task: Cache@2
319346
displayName: Cache compat versions install location
320347
timeoutInMinutes: 3
321348
continueOnError: true
322349
inputs:
323-
key: '"compat-version-installs" | "$(Agent.OS)" | "${{ parameters.testCommand }}" | "${{ variant.name }}"'
324-
path: $(Build.SourcesDirectory)/node_modules/@fluid-private/test-version-utils/node_modules/.legacy/
350+
key: '"compat-version-installs" | "$(Agent.OS)" | "${{ parameters.testCommand }}" | "${{ variant.name }}" | $(compatVersionCacheKey)'
351+
path: $(compatVersionInstallsPath)
325352

326353
# Only check out tenants from the tenant pool if we are running tests against ODSP
327354
- ${{ if or(eq(parameters.stageId, 'e2e_odsp'), eq(parameters.stageId, 'stress_tests_odsp')) }}:

0 commit comments

Comments
 (0)