Skip to content

Commit 4d7c56e

Browse files
authored
Engineering - Add GitHub action for pull requests (microsoft#254056)
* Test - handle running tests as part of a GitHub action * Add GitHub action files
1 parent e93d384 commit 4d7c56e

File tree

26 files changed

+1072
-37
lines changed

26 files changed

+1072
-37
lines changed

.github/workflows/pr-darwin-test.yml

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
job_name:
5+
type: string
6+
required: true
7+
electron_tests:
8+
type: boolean
9+
default: false
10+
browser_tests:
11+
type: boolean
12+
default: false
13+
remote_tests:
14+
type: boolean
15+
default: false
16+
17+
jobs:
18+
macOS-test:
19+
name: ${{ inputs.job_name }}
20+
runs-on: macos-14-xlarge
21+
env:
22+
ARTIFACT_NAME: ${{ (inputs.electron_tests && 'electron') || (inputs.browser_tests && 'browser') || (inputs.remote_tests && 'remote') || 'unknown' }}
23+
NPM_ARCH: arm64
24+
VSCODE_ARCH: arm64
25+
steps:
26+
- name: Checkout microsoft/vscode
27+
uses: actions/checkout@v4
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version-file: .nvmrc
33+
env:
34+
NODEJS_ORG_MIRROR: https://github.com/joaomoreno/node-mirror/releases/download
35+
36+
- name: Prepare node_modules cache key
37+
run: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.js darwin $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash
38+
39+
- name: Restore node_modules cache
40+
id: cache-node-modules
41+
uses: actions/cache@v4
42+
with:
43+
path: .build/node_modules_cache
44+
key: "node_modules-${{ hashFiles('.build/packagelockhash') }}"
45+
46+
- name: Extract node_modules cache
47+
if: steps.cache-node-modules.outputs.cache-hit == 'true'
48+
run: tar -xzf .build/node_modules_cache/cache.tgz
49+
50+
- name: Install dependencies
51+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
52+
run: |
53+
set -e
54+
c++ --version
55+
xcode-select -print-path
56+
python3 -m pip install --break-system-packages setuptools
57+
58+
for i in {1..5}; do # try 5 times
59+
npm ci && break
60+
if [ $i -eq 5 ]; then
61+
echo "Npm install failed too many times" >&2
62+
exit 1
63+
fi
64+
echo "Npm install failed $i, trying again..."
65+
done
66+
env:
67+
npm_config_arch: ${{ env.NPM_ARCH }}
68+
VSCODE_ARCH: ${{ env.VSCODE_ARCH }}
69+
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
70+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
# Avoid using dlopen to load Kerberos on macOS which can cause missing libraries
73+
# https://github.com/mongodb-js/kerberos/commit/04044d2814ad1d01e77f1ce87f26b03d86692cf2
74+
# flipped the default to support legacy linux distros which shouldn't happen
75+
# on macOS.
76+
GYP_DEFINES: "kerberos_use_rtld=false"
77+
78+
- name: Create node_modules archive
79+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
80+
run: |
81+
set -e
82+
node build/azure-pipelines/common/listNodeModules.js .build/node_modules_list.txt
83+
mkdir -p .build/node_modules_cache
84+
tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt
85+
86+
- name: Create .build folder
87+
run: mkdir -p .build
88+
89+
- name: Prepare built-in extensions cache key
90+
run: node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash
91+
92+
- name: Restore built-in extensions cache
93+
id: cache-builtin-extensions
94+
uses: actions/cache@v4
95+
with:
96+
path: .build/builtInExtensions
97+
key: "builtin-extensions-${{ hashFiles('.build/builtindepshash') }}"
98+
99+
- name: Download built-in extensions
100+
if: steps.cache-builtin-extensions.outputs.cache-hit != 'true'
101+
run: node build/lib/builtInExtensions.js
102+
env:
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
105+
- name: Transpile client and extensions
106+
run: npm run gulp transpile-client-esbuild transpile-extensions
107+
108+
- name: Download Electron and Playwright
109+
run: |
110+
set -e
111+
112+
for i in {1..3}; do # try 3 times (matching retryCountOnTaskFailure: 3)
113+
if npm exec -- npm-run-all -lp "electron ${{ env.VSCODE_ARCH }}" "playwright-install"; then
114+
echo "Download successful on attempt $i"
115+
break
116+
fi
117+
118+
if [ $i -eq 3 ]; then
119+
echo "Download failed after 3 attempts" >&2
120+
exit 1
121+
fi
122+
123+
echo "Download failed on attempt $i, retrying..."
124+
sleep 5 # optional: add a small delay between retries
125+
done
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
129+
- name: 🧪 Run unit tests (Electron)
130+
if: ${{ inputs.electron_tests }}
131+
timeout-minutes: 15
132+
run: ./scripts/test.sh --tfs "Unit Tests"
133+
134+
- name: 🧪 Run unit tests (node.js)
135+
if: ${{ inputs.electron_tests }}
136+
timeout-minutes: 15
137+
run: npm run test-node
138+
139+
- name: 🧪 Run unit tests (Browser, Webkit)
140+
if: ${{ inputs.browser_tests }}
141+
timeout-minutes: 30
142+
run: npm run test-browser-no-install -- --browser webkit --tfs "Browser Unit Tests"
143+
env:
144+
DEBUG: "*browser*"
145+
146+
- name: Build integration tests
147+
run: |
148+
set -e
149+
npm run gulp \
150+
compile-extension:configuration-editing \
151+
compile-extension:css-language-features-server \
152+
compile-extension:emmet \
153+
compile-extension:git \
154+
compile-extension:github-authentication \
155+
compile-extension:html-language-features-server \
156+
compile-extension:ipynb \
157+
compile-extension:notebook-renderers \
158+
compile-extension:json-language-features-server \
159+
compile-extension:markdown-language-features \
160+
compile-extension-media \
161+
compile-extension:microsoft-authentication \
162+
compile-extension:typescript-language-features \
163+
compile-extension:vscode-api-tests \
164+
compile-extension:vscode-colorize-tests \
165+
compile-extension:vscode-colorize-perf-tests \
166+
compile-extension:vscode-test-resolver
167+
168+
- name: 🧪 Run integration tests (Electron)
169+
if: ${{ inputs.electron_tests }}
170+
timeout-minutes: 20
171+
run: ./scripts/test-integration.sh --tfs "Integration Tests"
172+
173+
- name: 🧪 Run integration tests (Browser, Webkit)
174+
if: ${{ inputs.browser_tests }}
175+
timeout-minutes: 20
176+
run: ./scripts/test-web-integration.sh --browser webkit
177+
178+
- name: 🧪 Run integration tests (Remote)
179+
if: ${{ inputs.remote_tests }}
180+
timeout-minutes: 20
181+
run: ./scripts/test-remote-integration.sh
182+
183+
- name: Compile smoke tests
184+
working-directory: test/smoke
185+
run: npm run compile
186+
187+
- name: Compile extensions for smoke tests
188+
run: npm run gulp compile-extension-media
189+
190+
- name: Diagnostics before smoke test run
191+
run: ps -ef
192+
continue-on-error: true
193+
if: always()
194+
195+
- name: 🧪 Run smoke tests (Electron)
196+
if: ${{ inputs.electron_tests }}
197+
timeout-minutes: 20
198+
run: npm run smoketest-no-compile -- --tracing
199+
200+
- name: 🧪 Run smoke tests (Browser, Chromium)
201+
if: ${{ inputs.browser_tests }}
202+
timeout-minutes: 20
203+
run: npm run smoketest-no-compile -- --web --tracing --headless
204+
205+
- name: 🧪 Run smoke tests (Remote)
206+
if: ${{ inputs.remote_tests }}
207+
timeout-minutes: 20
208+
run: npm run smoketest-no-compile -- --remote --tracing
209+
210+
- name: Diagnostics after smoke test run
211+
run: ps -ef
212+
continue-on-error: true
213+
if: always()
214+
215+
- name: Publish Crash Reports
216+
uses: actions/upload-artifact@v4
217+
if: failure()
218+
continue-on-error: true
219+
with:
220+
name: ${{ format('crash-dump-macos-{0}-{1}-{2}', env.VSCODE_ARCH, env.ARTIFACT_NAME, github.run_attempt) }}
221+
path: .build/crashes
222+
if-no-files-found: ignore
223+
224+
# In order to properly symbolify above crash reports
225+
# (if any), we need the compiled native modules too
226+
- name: Publish Node Modules
227+
uses: actions/upload-artifact@v4
228+
if: failure()
229+
continue-on-error: true
230+
with:
231+
name: ${{ format('node-modules-macos-{0}-{1}-{2}', env.VSCODE_ARCH, env.ARTIFACT_NAME, github.run_attempt) }}
232+
path: node_modules
233+
if-no-files-found: ignore
234+
235+
- name: Publish Log Files
236+
uses: actions/upload-artifact@v4
237+
if: always()
238+
continue-on-error: true
239+
with:
240+
name: ${{ format('logs-macos-{0}-{1}-{2}', env.VSCODE_ARCH, env.ARTIFACT_NAME, github.run_attempt) }}
241+
path: .build/logs
242+
if-no-files-found: ignore
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
job_name:
5+
type: string
6+
required: true
7+
rustup_toolchain:
8+
type: string
9+
required: true
10+
11+
jobs:
12+
linux-cli-test:
13+
name: ${{ inputs.job_name }}
14+
runs-on: [ self-hosted, 1ES.Pool=1es-vscode-oss-ubuntu-22.04-x64 ]
15+
env:
16+
RUSTUP_TOOLCHAIN: ${{ inputs.rustup_toolchain }}
17+
steps:
18+
- name: Checkout microsoft/vscode
19+
uses: actions/checkout@v4
20+
21+
- name: Install Rust
22+
run: |
23+
set -e
24+
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain $RUSTUP_TOOLCHAIN
25+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
26+
27+
- name: Set Rust version
28+
run: |
29+
set -e
30+
rustup default $RUSTUP_TOOLCHAIN
31+
rustup update $RUSTUP_TOOLCHAIN
32+
rustup component add clippy
33+
34+
- name: Check Rust versions
35+
run: |
36+
set -e
37+
rustc --version
38+
cargo --version
39+
40+
- name: Clippy lint
41+
run: cargo clippy -- -D warnings
42+
working-directory: cli
43+
44+
- name: 🧪 Run unit tests
45+
run: cargo test
46+
working-directory: cli

0 commit comments

Comments
 (0)