Skip to content

Commit eadb3fa

Browse files
mrleemurrayCopilot
andcommitted
Merge main into chat compact icons
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2 parents 602781a + 0234402 commit eadb3fa

162 files changed

Lines changed: 9049 additions & 2591 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/azure-pipelines/alpine/product-build-alpine-node-modules.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ jobs:
9090
mkdir -p .build/nodejs-musl
9191
NODE_VERSION=$(grep '^target=' remote/.npmrc | cut -d '"' -f 2)
9292
BUILD_ID=$(grep '^ms_build_id=' remote/.npmrc | cut -d '"' -f 2)
93-
az extension add --name azure-devops --upgrade --only-show-errors
9493
az artifacts universal download \
9594
--organization "https://dev.azure.com/monacotools" \
9695
--project "Monaco" \

build/azure-pipelines/alpine/product-build-alpine.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ jobs:
106106
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
107107
displayName: Setup NPM Authentication
108108

109+
- template: ../common/foundry-local.yml@self
110+
parameters:
111+
phase: prepare
112+
109113
- task: Docker@1
110114
inputs:
111115
azureSubscriptionEndpoint: vscode
@@ -135,7 +139,6 @@ jobs:
135139
mkdir -p .build/nodejs-musl
136140
NODE_VERSION=$(grep '^target=' remote/.npmrc | cut -d '"' -f 2)
137141
BUILD_ID=$(grep '^ms_build_id=' remote/.npmrc | cut -d '"' -f 2)
138-
az extension add --name azure-devops --upgrade --only-show-errors
139142
az artifacts universal download \
140143
--organization "https://dev.azure.com/monacotools" \
141144
--project "Monaco" \
@@ -174,6 +177,10 @@ jobs:
174177
displayName: Install dependencies
175178
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
176179
180+
- template: ../common/foundry-local.yml@self
181+
parameters:
182+
phase: install
183+
177184
- script: node build/azure-pipelines/common/checkNativeOptionalDeps.ts
178185
displayName: Verify native optional dependency binaries
179186

build/azure-pipelines/common/disableFoundryLocalInstall.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as fs from 'fs';
7-
import * as path from 'path';
6+
import { disableFoundryLocalInstall } from './foundryLocalInstall.ts';
87

9-
const packageJsonPath = path.resolve(import.meta.dirname, '../../..', 'package.json');
10-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) as {
11-
dependencies?: Record<string, string>;
12-
allowScripts?: Record<string, boolean>;
13-
};
14-
const allowScripts = packageJson.allowScripts;
15-
const foundryLocalVersion = packageJson.dependencies?.['foundry-local-sdk'];
16-
const foundryLocalKey = foundryLocalVersion ? `foundry-local-sdk@${foundryLocalVersion}` : undefined;
17-
18-
if (!allowScripts || !foundryLocalKey || allowScripts[foundryLocalKey] !== true) {
19-
throw new Error('Expected an approved, pinned foundry-local-sdk install script in package.json');
20-
}
21-
22-
allowScripts[foundryLocalKey] = false;
23-
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, undefined, 2)}\n`);
24-
console.log(`Disabled ${foundryLocalKey} install script for this CI job`);
8+
disableFoundryLocalInstall();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
parameters:
2+
- name: phase
3+
type: string
4+
values:
5+
- prepare
6+
- install
7+
8+
steps:
9+
- ${{ if eq(parameters.phase, 'prepare') }}:
10+
- task: NuGetAuthenticate@1
11+
displayName: Setup NuGet Authentication
12+
13+
- script: node build/azure-pipelines/common/disableFoundryLocalInstall.ts
14+
displayName: Disable Foundry Local Native Install
15+
16+
- ${{ if eq(parameters.phase, 'install') }}:
17+
- script: node build/azure-pipelines/common/foundryLocalInstall.ts
18+
displayName: Install Foundry Local Native Dependencies
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { execFileSync } from 'child_process';
7+
import { createHash } from 'crypto';
8+
import * as fs from 'fs';
9+
import * as path from 'path';
10+
import { fetchCoreLibraries, getStandardArtifacts, type IFoundryDependencyVersions, requiredCoreLibraryNames, supportsCoreLibraryTarget, VSCODE_NUGET_FEED } from '../../dictation-runtime/nuget.ts';
11+
12+
const repositoryRoot = path.resolve(import.meta.dirname, '../../..');
13+
const packageName = 'foundry-local-sdk';
14+
const credentialTokenEnvironmentVariable = 'VSS_NUGET_ACCESSTOKEN';
15+
const expectedInstallerUtilsHash = '0831c932b10389283e805f88a204b0f6a5a8053f2ee520e56a0f0adf1352aa8b';
16+
17+
type RootPackageJson = {
18+
dependencies?: Record<string, string>;
19+
allowScripts?: Record<string, boolean>;
20+
};
21+
22+
type FoundryPackageJson = {
23+
version?: string;
24+
scripts?: Record<string, string>;
25+
};
26+
27+
function readJson<T>(filePath: string): T {
28+
return JSON.parse(fs.readFileSync(filePath, 'utf8')) as T;
29+
}
30+
31+
function getPinnedPackage(root: string): { packageJsonPath: string; packageJson: RootPackageJson; allowScripts: Record<string, boolean>; allowScriptsKey: string } {
32+
const packageJsonPath = path.join(root, 'package.json');
33+
const packageJson = readJson<RootPackageJson>(packageJsonPath);
34+
const allowScripts = packageJson.allowScripts;
35+
const version = packageJson.dependencies?.[packageName];
36+
const allowScriptsKey = version ? `${packageName}@${version}` : undefined;
37+
38+
if (!allowScripts || !version || !allowScriptsKey || allowScripts[allowScriptsKey] !== true) {
39+
throw new Error(`Expected an approved, pinned ${packageName} install script in package.json`);
40+
}
41+
42+
return { packageJsonPath, packageJson, allowScripts, allowScriptsKey };
43+
}
44+
45+
export function disableFoundryLocalInstall(root = repositoryRoot): void {
46+
const { packageJsonPath, packageJson, allowScripts, allowScriptsKey } = getPinnedPackage(root);
47+
allowScripts[allowScriptsKey] = false;
48+
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, undefined, 2)}\n`);
49+
console.log(`Disabled ${allowScriptsKey} install script for this CI job`);
50+
}
51+
52+
function validateInstallerUtils(installerUtilsPath: string): void {
53+
const contents = fs.readFileSync(installerUtilsPath);
54+
const actualHash = createHash('sha256').update(contents).digest('hex');
55+
56+
if (actualHash !== expectedInstallerUtilsHash) {
57+
throw new Error(`Unexpected ${packageName} installer utility hash ${actualHash}`);
58+
}
59+
}
60+
61+
function runLifecycleScript(packageRoot: string, relativeScriptPath: string): void {
62+
execFileSync(process.execPath, [path.join(packageRoot, relativeScriptPath)], {
63+
cwd: packageRoot,
64+
stdio: 'inherit'
65+
});
66+
}
67+
68+
export async function installFoundryLocal(root = repositoryRoot): Promise<void> {
69+
if (!process.env[credentialTokenEnvironmentVariable]) {
70+
throw new Error(`${credentialTokenEnvironmentVariable} was not set by NuGetAuthenticate`);
71+
}
72+
73+
const rootPackageJson = readJson<RootPackageJson>(path.join(root, 'package.json'));
74+
const version = rootPackageJson.dependencies?.[packageName];
75+
const allowScriptsKey = version ? `${packageName}@${version}` : undefined;
76+
if (!version || !allowScriptsKey || rootPackageJson.allowScripts?.[allowScriptsKey] !== false) {
77+
throw new Error(`Expected the pinned ${packageName} install script to be disabled before installation`);
78+
}
79+
80+
const packageRoot = path.join(root, 'node_modules', packageName);
81+
const packageJson = readJson<FoundryPackageJson>(path.join(packageRoot, 'package.json'));
82+
if (packageJson.version !== version) {
83+
throw new Error(`Expected ${packageName}@${version}, found ${packageJson.version ?? 'an unknown version'}`);
84+
}
85+
if (packageJson.scripts?.preinstall !== 'node script/preinstall.cjs' || packageJson.scripts.install !== 'node script/install-standard.cjs') {
86+
throw new Error(`Unexpected ${packageName}@${version} lifecycle scripts`);
87+
}
88+
89+
validateInstallerUtils(path.join(packageRoot, 'script', 'install-utils.cjs'));
90+
runLifecycleScript(packageRoot, 'script/preinstall.cjs');
91+
92+
const target = `${process.platform}-${process.arch}`;
93+
if (!supportsCoreLibraryTarget(target)) {
94+
console.warn(`[foundry-local] Unsupported platform: ${target}. Skipping.`);
95+
return;
96+
}
97+
98+
const dependencies = readJson<IFoundryDependencyVersions>(path.join(packageRoot, 'deps_versions.json'));
99+
const artifacts = getStandardArtifacts(target, dependencies);
100+
const binDir = path.join(packageRoot, 'foundry-local-core', target);
101+
await fetchCoreLibraries(target, artifacts, binDir, { feeds: [VSCODE_NUGET_FEED], skipIfPresent: true });
102+
103+
const missingFiles = requiredCoreLibraryNames(target).filter(file => !fs.existsSync(path.join(binDir, file)));
104+
if (missingFiles.length > 0) {
105+
throw new Error(`[foundry-local] Missing required native libraries for ${target}: ${missingFiles.join(', ')}`);
106+
}
107+
108+
const coreVersion = dependencies['foundry-local-core'].nuget;
109+
const platformPackageJson = {
110+
name: `@foundry-local-core/${target}`,
111+
version: coreVersion,
112+
description: `Native binaries for Foundry Local SDK (${target})`,
113+
private: true,
114+
};
115+
fs.writeFileSync(path.join(binDir, 'package.json'), JSON.stringify(platformPackageJson, undefined, 2));
116+
console.log('[foundry-local] Installation complete.');
117+
}
118+
119+
if (import.meta.filename === process.argv[1]) {
120+
await installFoundryLocal();
121+
}

build/azure-pipelines/common/sanity-tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ jobs:
102102
displayName: Create Crash Dumps Directory
103103

104104
- ${{ if and(eq(parameters.os, 'windows'), eq(parameters.arch, 'arm64')) }}:
105+
- task: NuGetAuthenticate@1
106+
displayName: Setup NuGet Authentication
107+
105108
- script: |
106109
@echo off
107110
setlocal enabledelayedexpansion
@@ -117,7 +120,7 @@ jobs:
117120
if exist "!SDK_ROOT!" rmdir /s /q "!SDK_ROOT!"
118121
119122
set "SDK_PACKAGE=$(Agent.TempDirectory)\windows-sdk-build-tools.nupkg"
120-
curl.exe -fsSL --retry 5 --retry-delay 2 --retry-all-errors "https://api.nuget.org/v3-flatcontainer/microsoft.windows.sdk.buildtools/!PACKAGE_VERSION!/microsoft.windows.sdk.buildtools.!PACKAGE_VERSION!.nupkg" -o "!SDK_PACKAGE!"
123+
curl.exe -fsSL --retry 5 --retry-delay 2 --retry-all-errors -u "vscode:%VSS_NUGET_ACCESSTOKEN%" "https://pkgs.dev.azure.com/monacotools/Monaco/_packaging/vscode/nuget/v3/flat2/microsoft.windows.sdk.buildtools/!PACKAGE_VERSION!/microsoft.windows.sdk.buildtools.!PACKAGE_VERSION!.nupkg" -o "!SDK_PACKAGE!"
121124
122125
set "ACTUAL_HASH="
123126
for /f "skip=1" %%A in ('certutil -hashfile "!SDK_PACKAGE!" SHA256') do if not defined ACTUAL_HASH set "ACTUAL_HASH=%%A"

build/azure-pipelines/darwin/steps/product-build-darwin-compile.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ steps:
2424
versionSource: fromFile
2525
versionFilePath: .nvmrc
2626

27-
- ${{ if eq(parameters.VSCODE_SKIP_FOUNDRY_LOCAL_INSTALL, true) }}:
27+
- ${{ if or(eq(parameters.VSCODE_CIBUILD, true), eq(parameters.VSCODE_SKIP_FOUNDRY_LOCAL_INSTALL, true)) }}:
2828
- script: node build/azure-pipelines/common/disableFoundryLocalInstall.ts
2929
displayName: Disable Foundry Local Native Install
3030

@@ -80,6 +80,11 @@ steps:
8080
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
8181
displayName: Setup NPM Authentication
8282

83+
- ${{ if and(eq(parameters.VSCODE_CIBUILD, false), eq(parameters.VSCODE_SKIP_FOUNDRY_LOCAL_INSTALL, false)) }}:
84+
- template: ../../common/foundry-local.yml@self
85+
parameters:
86+
phase: prepare
87+
8388
- task: PipAuthenticate@1
8489
inputs:
8590
artifactFeeds: Monaco/vscode
@@ -112,6 +117,11 @@ steps:
112117
displayName: Install dependencies
113118
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
114119
120+
- ${{ if and(eq(parameters.VSCODE_CIBUILD, false), eq(parameters.VSCODE_SKIP_FOUNDRY_LOCAL_INSTALL, false)) }}:
121+
- template: ../../common/foundry-local.yml@self
122+
parameters:
123+
phase: install
124+
115125
- script: node build/azure-pipelines/common/checkNativeOptionalDeps.ts
116126
displayName: Verify native optional dependency binaries
117127

build/azure-pipelines/linux/steps/product-build-linux-compile.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ steps:
3232
versionSource: fromFile
3333
versionFilePath: .nvmrc
3434

35-
- ${{ if eq(parameters.VSCODE_SKIP_FOUNDRY_LOCAL_INSTALL, true) }}:
35+
- ${{ if or(eq(parameters.VSCODE_CIBUILD, true), eq(parameters.VSCODE_SKIP_FOUNDRY_LOCAL_INSTALL, true)) }}:
3636
- script: node build/azure-pipelines/common/disableFoundryLocalInstall.ts
3737
displayName: Disable Foundry Local Native Install
3838

@@ -100,6 +100,11 @@ steps:
100100
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
101101
displayName: Setup NPM Authentication
102102

103+
- ${{ if and(eq(parameters.VSCODE_CIBUILD, false), eq(parameters.VSCODE_SKIP_FOUNDRY_LOCAL_INSTALL, false)) }}:
104+
- template: ../../common/foundry-local.yml@self
105+
parameters:
106+
phase: prepare
107+
103108
- script: |
104109
set -e
105110
@@ -159,6 +164,11 @@ steps:
159164
displayName: Install dependencies
160165
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
161166
167+
- ${{ if and(eq(parameters.VSCODE_CIBUILD, false), eq(parameters.VSCODE_SKIP_FOUNDRY_LOCAL_INSTALL, false)) }}:
168+
- template: ../../common/foundry-local.yml@self
169+
parameters:
170+
phase: install
171+
162172
- script: node build/azure-pipelines/common/checkNativeOptionalDeps.ts
163173
displayName: Verify native optional dependency binaries
164174

build/azure-pipelines/product-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ extends:
290290
ubuntu-2004-arm64:
291291
image: onebranch.azurecr.io/linux/ubuntu-2004-arm64:latest
292292
settings:
293-
networkIsolationPolicy: Permissive,CFSClean2,CFSClean3
293+
networkIsolationPolicy: Permissive,CFSClean,CFSClean2,CFSClean3
294294
stages:
295295

296296
- stage: Quality

build/azure-pipelines/product-quality-checks.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ jobs:
5656
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
5757
displayName: Setup NPM Authentication
5858

59+
- template: ./common/foundry-local.yml@self
60+
parameters:
61+
phase: prepare
62+
5963
- script: |
6064
set -e
6165
@@ -105,6 +109,10 @@ jobs:
105109
displayName: Install dependencies
106110
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
107111
112+
- template: ./common/foundry-local.yml@self
113+
parameters:
114+
phase: install
115+
108116
- script: node build/azure-pipelines/common/checkNativeOptionalDeps.ts
109117
displayName: Verify native optional dependency binaries
110118

0 commit comments

Comments
 (0)