Skip to content

Commit 22ec32b

Browse files
Copilotjoaomoreno
andcommitted
Update workflow to use npm instead of yarn
Replace yarn-based caching and installation with npm-based approach following the pattern in latest PR workflows (pr.yml): - Use npm ci instead of yarn install - Use .build/node_modules_cache pattern instead of yarn cache - Update cache keys to match npm-based approach - Use node_modules archive creation with listNodeModules.ts - Windows uses 7z.exe for node_modules archive Updated all three platform jobs (Linux, macOS, Windows) to use npm. Co-authored-by: joaomoreno <22350+joaomoreno@users.noreply.github.com>
1 parent 8d41acc commit 22ec32b

File tree

1 file changed

+165
-105
lines changed

1 file changed

+165
-105
lines changed

.github/workflows/oss-build-fast.yml

Lines changed: 165 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
branches:
77
- copilot/add-github-actions-workflow
88

9+
permissions: {}
10+
11+
env:
12+
VSCODE_QUALITY: 'oss'
13+
914
jobs:
1015
linux:
1116
name: Linux x64
@@ -14,55 +19,71 @@ jobs:
1419
env:
1520
VSCODE_ARCH: x64
1621
steps:
17-
- uses: actions/checkout@v4
22+
- name: Checkout microsoft/vscode
23+
uses: actions/checkout@v6
1824

19-
- uses: actions/setup-node@v4
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v6
2027
with:
2128
node-version-file: .nvmrc
2229

23-
- name: Compute node modules cache key
24-
id: nodeModulesCacheKey
25-
run: echo "value=$(node build/azure-pipelines/common/computeNodeModulesCacheKey.js)" >> $GITHUB_OUTPUT
30+
- name: Prepare node_modules cache key
31+
run: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.ts linux x64 $(node -p process.arch) > .build/packagelockhash
2632

27-
- name: Cache node modules
28-
id: cacheNodeModules
29-
uses: actions/cache@v4
30-
with:
31-
path: '**/node_modules'
32-
key: ${{ runner.os }}-cacheNodeModulesLinux-${{ steps.nodeModulesCacheKey.outputs.value }}
33-
restore-keys: ${{ runner.os }}-cacheNodeModulesLinux-
34-
35-
- name: Get yarn cache directory path
36-
id: yarnCacheDirPath
37-
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
38-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
39-
40-
- name: Cache yarn directory
41-
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
42-
uses: actions/cache@v4
33+
- name: Restore node_modules cache
34+
id: cache-node-modules
35+
uses: actions/cache/restore@v5
4336
with:
44-
path: ${{ steps.yarnCacheDirPath.outputs.dir }}
45-
key: ${{ runner.os }}-yarnCacheDir-${{ steps.nodeModulesCacheKey.outputs.value }}
46-
restore-keys: ${{ runner.os }}-yarnCacheDir-
37+
path: .build/node_modules_cache
38+
key: "node_modules-linux-${{ hashFiles('.build/packagelockhash') }}"
39+
40+
- name: Extract node_modules cache
41+
if: steps.cache-node-modules.outputs.cache-hit == 'true'
42+
run: tar -xzf .build/node_modules_cache/cache.tgz
43+
44+
- name: Install build tools
45+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
46+
run: sudo apt update -y && sudo apt install -y build-essential pkg-config libx11-dev libx11-xcb-dev libxkbfile-dev libnotify-bin libkrb5-dev
4747

48-
- name: Execute yarn
49-
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
48+
- name: Install dependencies
49+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
50+
run: |
51+
set -e
52+
53+
for i in {1..5}; do # try 5 times
54+
npm ci && break
55+
if [ $i -eq 5 ]; then
56+
echo "Npm install failed too many times" >&2
57+
exit 1
58+
fi
59+
echo "Npm install failed $i, trying again..."
60+
done
5061
env:
51-
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
5262
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
53-
run: yarn --frozen-lockfile --network-timeout 180000
63+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5465

55-
- name: Compute builtin extensions cache key
56-
id: builtInExtensionsCacheKey
57-
run: echo "value=$(node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js)" >> $GITHUB_OUTPUT
66+
- name: Create node_modules archive
67+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
68+
run: |
69+
set -e
70+
node build/azure-pipelines/common/listNodeModules.ts .build/node_modules_list.txt
71+
mkdir -p .build/node_modules_cache
72+
tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt
73+
74+
- name: Prepare built-in extensions cache key
75+
run: |
76+
set -e
77+
mkdir -p .build
78+
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.ts > .build/builtindepshash
5879
59-
- name: Cache builtin extensions
80+
- name: Restore built-in extensions cache
6081
id: cache-builtin-extensions
61-
uses: actions/cache@v4
82+
uses: actions/cache/restore@v5
6283
with:
84+
enableCrossOsArchive: true
6385
path: .build/builtInExtensions
64-
key: builtInExtensions-${{ steps.builtInExtensionsCacheKey.outputs.value }}
65-
restore-keys: builtInExtensions-
86+
key: "builtin-extensions-${{ hashFiles('.build/builtindepshash') }}"
6687

6788
- name: Download built-in extensions
6889
if: steps.cache-builtin-extensions.outputs.cache-hit != 'true'
@@ -100,55 +121,67 @@ jobs:
100121
env:
101122
VSCODE_ARCH: arm64
102123
steps:
103-
- uses: actions/checkout@v4
124+
- name: Checkout microsoft/vscode
125+
uses: actions/checkout@v6
104126

105-
- uses: actions/setup-node@v4
127+
- name: Setup Node.js
128+
uses: actions/setup-node@v6
106129
with:
107130
node-version-file: .nvmrc
108131

109-
- name: Compute node modules cache key
110-
id: nodeModulesCacheKey
111-
run: echo "value=$(node build/azure-pipelines/common/computeNodeModulesCacheKey.js)" >> $GITHUB_OUTPUT
132+
- name: Prepare node_modules cache key
133+
run: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.ts darwin arm64 $(node -p process.arch) > .build/packagelockhash
112134

113-
- name: Cache node modules
114-
id: cacheNodeModules
115-
uses: actions/cache@v4
135+
- name: Restore node_modules cache
136+
id: cache-node-modules
137+
uses: actions/cache/restore@v5
116138
with:
117-
path: '**/node_modules'
118-
key: ${{ runner.os }}-cacheNodeModulesLinux-${{ steps.nodeModulesCacheKey.outputs.value }}
119-
restore-keys: ${{ runner.os }}-cacheNodeModulesLinux-
120-
121-
- name: Get yarn cache directory path
122-
id: yarnCacheDirPath
123-
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
124-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
125-
126-
- name: Cache yarn directory
127-
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
128-
uses: actions/cache@v4
129-
with:
130-
path: ${{ steps.yarnCacheDirPath.outputs.dir }}
131-
key: ${{ runner.os }}-yarnCacheDir-${{ steps.nodeModulesCacheKey.outputs.value }}
132-
restore-keys: ${{ runner.os }}-yarnCacheDir-
139+
path: .build/node_modules_cache
140+
key: "node_modules-darwin-${{ hashFiles('.build/packagelockhash') }}"
141+
142+
- name: Extract node_modules cache
143+
if: steps.cache-node-modules.outputs.cache-hit == 'true'
144+
run: tar -xzf .build/node_modules_cache/cache.tgz
133145

134-
- name: Execute yarn
135-
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
146+
- name: Install dependencies
147+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
148+
run: |
149+
set -e
150+
151+
for i in {1..5}; do # try 5 times
152+
npm ci && break
153+
if [ $i -eq 5 ]; then
154+
echo "Npm install failed too many times" >&2
155+
exit 1
156+
fi
157+
echo "Npm install failed $i, trying again..."
158+
done
136159
env:
137-
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
138160
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
139-
run: yarn --frozen-lockfile --network-timeout 180000
161+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
162+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140163

141-
- name: Compute builtin extensions cache key
142-
id: builtInExtensionsCacheKey
143-
run: echo "value=$(node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js)" >> $GITHUB_OUTPUT
164+
- name: Create node_modules archive
165+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
166+
run: |
167+
set -e
168+
node build/azure-pipelines/common/listNodeModules.ts .build/node_modules_list.txt
169+
mkdir -p .build/node_modules_cache
170+
tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt
171+
172+
- name: Prepare built-in extensions cache key
173+
run: |
174+
set -e
175+
mkdir -p .build
176+
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.ts > .build/builtindepshash
144177
145-
- name: Cache builtin extensions
178+
- name: Restore built-in extensions cache
146179
id: cache-builtin-extensions
147-
uses: actions/cache@v4
180+
uses: actions/cache/restore@v5
148181
with:
182+
enableCrossOsArchive: true
149183
path: .build/builtInExtensions
150-
key: builtInExtensions-${{ steps.builtInExtensionsCacheKey.outputs.value }}
151-
restore-keys: builtInExtensions-
184+
key: "builtin-extensions-${{ hashFiles('.build/builtindepshash') }}"
152185

153186
- name: Download built-in extensions
154187
if: steps.cache-builtin-extensions.outputs.cache-hit != 'true'
@@ -186,55 +219,82 @@ jobs:
186219
env:
187220
VSCODE_ARCH: x64
188221
steps:
189-
- uses: actions/checkout@v4
222+
- name: Checkout microsoft/vscode
223+
uses: actions/checkout@v6
190224

191-
- uses: actions/setup-node@v4
225+
- name: Setup Node.js
226+
uses: actions/setup-node@v6
192227
with:
193228
node-version-file: .nvmrc
194229

195-
- name: Compute node modules cache key
196-
id: nodeModulesCacheKey
197-
run: echo "value=$(node build/azure-pipelines/common/computeNodeModulesCacheKey.js)" >> $env:GITHUB_OUTPUT
230+
- name: Prepare node_modules cache key
231+
shell: pwsh
232+
run: |
233+
mkdir .build -ea 0
234+
node build/azure-pipelines/common/computeNodeModulesCacheKey.ts win32 x64 $(node -p process.arch) > .build/packagelockhash
198235
199-
- name: Cache node modules
200-
id: cacheNodeModules
201-
uses: actions/cache@v4
236+
- name: Restore node_modules cache
237+
id: cache-node-modules
238+
uses: actions/cache/restore@v5
202239
with:
203-
path: '**/node_modules'
204-
key: ${{ runner.os }}-cacheNodeModulesLinux-${{ steps.nodeModulesCacheKey.outputs.value }}
205-
restore-keys: ${{ runner.os }}-cacheNodeModulesLinux-
206-
207-
- name: Get yarn cache directory path
208-
id: yarnCacheDirPath
209-
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
210-
run: echo "dir=$(yarn cache dir)" >> $env:GITHUB_OUTPUT
211-
212-
- name: Cache yarn directory
213-
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
214-
uses: actions/cache@v4
215-
with:
216-
path: ${{ steps.yarnCacheDirPath.outputs.dir }}
217-
key: ${{ runner.os }}-yarnCacheDir-${{ steps.nodeModulesCacheKey.outputs.value }}
218-
restore-keys: ${{ runner.os }}-yarnCacheDir-
240+
path: .build/node_modules_cache
241+
key: "node_modules-windows-${{ hashFiles('.build/packagelockhash') }}"
242+
243+
- name: Extract node_modules cache
244+
if: steps.cache-node-modules.outputs.cache-hit == 'true'
245+
shell: pwsh
246+
run: 7z.exe x .build/node_modules_cache/cache.7z -aoa
219247

220-
- name: Execute yarn
221-
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
248+
- name: Install dependencies
249+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
250+
shell: pwsh
251+
run: |
252+
. build/azure-pipelines/win32/exec.ps1
253+
$ErrorActionPreference = "Stop"
254+
255+
for ($i = 1; $i -le 5; $i++) {
256+
try {
257+
exec { npm ci }
258+
break
259+
}
260+
catch {
261+
if ($i -eq 5) {
262+
Write-Error "npm ci failed after 5 attempts"
263+
throw
264+
}
265+
Write-Host "npm ci failed attempt $i, retrying..."
266+
Start-Sleep -Seconds 2
267+
}
268+
}
222269
env:
223-
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
270+
npm_config_arch: x64
271+
npm_config_foreground_scripts: "true"
272+
VSCODE_ARCH: x64
224273
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
225-
run: yarn --frozen-lockfile --network-timeout 180000
274+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
275+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
226276

227-
- name: Compute builtin extensions cache key
228-
id: builtInExtensionsCacheKey
229-
run: echo "value=$(node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js)" >> $env:GITHUB_OUTPUT
277+
- name: Create node_modules archive
278+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
279+
shell: pwsh
280+
run: |
281+
node build/azure-pipelines/common/listNodeModules.ts .build/node_modules_list.txt
282+
mkdir -Force .build/node_modules_cache
283+
7z.exe a .build/node_modules_cache/cache.7z -tzip `@.build/node_modules_list.txt -aoa
284+
285+
- name: Prepare built-in extensions cache key
286+
shell: pwsh
287+
run: |
288+
mkdir .build -ea 0
289+
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.ts > .build/builtindepshash
230290
231-
- name: Cache builtin extensions
291+
- name: Restore built-in extensions cache
232292
id: cache-builtin-extensions
233-
uses: actions/cache@v4
293+
uses: actions/cache/restore@v5
234294
with:
295+
enableCrossOsArchive: true
235296
path: .build/builtInExtensions
236-
key: builtInExtensions-${{ steps.builtInExtensionsCacheKey.outputs.value }}
237-
restore-keys: builtInExtensions-
297+
key: "builtin-extensions-${{ hashFiles('.build/builtindepshash') }}"
238298

239299
- name: Download built-in extensions
240300
if: steps.cache-builtin-extensions.outputs.cache-hit != 'true'

0 commit comments

Comments
 (0)