Skip to content

Commit 1a094dd

Browse files
alan-agius4kirjs
authored andcommitted
ci: try to resolve vscode extension e2e flakes
Update e2e test runner to VS Code 1.102.0, streamline test activation, and manage temporary directories via `TEST_TMPDIR`.
1 parent 2ecdb22 commit 1a094dd

File tree

6 files changed

+10
-45
lines changed

6 files changed

+10
-45
lines changed

.github/workflows/pr.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ jobs:
134134
uses: angular/dev-infra/github-actions/bazel/configure-remote@f47684669736e28fd77eab64e65b2952c8a948ee
135135
- name: Install node modules
136136
run: pnpm install --frozen-lockfile
137-
- name: Cache downloaded vscode binary
138-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
139-
with:
140-
path: '~/.cache/vscode-test'
141-
key: vscode-cache-${{ runner.os }}-${{ hashFiles('vscode-ng-language-service/integration/e2e/index.ts') }} # The version is specified in this file.
142137
- name: Run tests
143138
run: pnpm bazel test //vscode-ng-language-service/...
144139

vscode-ng-language-service/integration/e2e/completion_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {activate, COMPLETION_COMMAND, FOO_TEMPLATE_URI} from './helper';
55
describe('Angular LS completions', () => {
66
beforeAll(async () => {
77
await activate(FOO_TEMPLATE_URI);
8-
}, 20_000);
8+
});
99

1010
it(`does not duplicate HTML completions in external templates`, async () => {
1111
const position = new vscode.Position(0, 0);

vscode-ng-language-service/integration/e2e/definition_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const APP_COMPONENT_URI = vscode.Uri.file(APP_COMPONENT);
1010
describe('Angular LS', () => {
1111
beforeAll(async () => {
1212
await activate(APP_COMPONENT_URI);
13-
}, 20_000);
13+
});
1414

1515
it(`returns definition for variable in template`, async () => {
1616
// vscode Position is zero-based

vscode-ng-language-service/integration/e2e/helper.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,7 @@ export const FOO_TEMPLATE_URI = vscode.Uri.file(FOO_TEMPLATE);
1111

1212
export async function activate(uri: vscode.Uri): Promise<void> {
1313
await vscode.window.showTextDocument(uri);
14-
1514
// This is needed for stabilization and to reduce flakes.
1615
// The timeout gives the language server time to warm up.
1716
await setTimeout(3_000);
18-
19-
await waitForDefinitionsToBeAvailable(20);
20-
}
21-
22-
async function waitForDefinitionsToBeAvailable(maxTries: number) {
23-
await vscode.workspace.openTextDocument(APP_COMPONENT_URI);
24-
25-
let tries = 0;
26-
while (tries < maxTries) {
27-
const position = new vscode.Position(4, 25);
28-
// For a complete list of standard commands, see
29-
// https://code.visualstudio.com/api/references/commands
30-
const definitions = await vscode.commands.executeCommand<vscode.LocationLink[]>(
31-
DEFINITION_COMMAND,
32-
APP_COMPONENT_URI,
33-
position,
34-
);
35-
36-
if (definitions?.length > 0) {
37-
return;
38-
}
39-
40-
tries++;
41-
await setTimeout(500);
42-
}
4317
}

vscode-ng-language-service/integration/e2e/hover_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {activate, FOO_TEMPLATE_URI, HOVER_COMMAND} from './helper';
55
describe('Angular LS quick info', () => {
66
beforeAll(async () => {
77
await activate(FOO_TEMPLATE_URI);
8-
}, 20_000);
8+
});
99

1010
it(`returns quick info from built in extension for class in template`, async () => {
1111
const position = new vscode.Position(1, 8);

vscode-ng-language-service/integration/e2e/index.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import {join} from 'node:path';
2-
import {homedir, tmpdir} from 'node:os';
32
import {promisify} from 'node:util';
43
import {runTests} from '@vscode/test-electron';
54

65
import {PACKAGE_ROOT, PROJECT_PATH} from '../test_constants';
7-
import {mkdtemp} from 'node:fs/promises';
86

97
// @ts-expect-error no types.
108
import Xvfb from 'xvfb';
@@ -13,20 +11,18 @@ async function main() {
1311
const EXT_DEVELOPMENT_PATH = join(PACKAGE_ROOT, 'development_package');
1412
const EXT_TESTS_PATH = join(PACKAGE_ROOT, 'integration', 'e2e', 'jasmine');
1513
const xvfb = new Xvfb();
16-
17-
// We cannot use `TEST_TMPDIR` as it's longer than 170 characters
18-
const vsCodeDataDir = await mkdtemp(join(tmpdir(), 'vscode-e2e-'));
14+
const tmpDir = process.env['TEST_TMPDIR']!;
1915

2016
try {
2117
await promisify(xvfb.start).call(xvfb);
2218

2319
const exitCode = await runTests({
24-
// Keep version in sync with vscode engine version in package.json
25-
version: '1.74.3',
20+
// The current version should align with the VS Code engine version in package.json, but it's several years old.
21+
// TODO: We should update the package.json version eventually.
22+
version: '1.102.0',
2623
extensionDevelopmentPath: EXT_DEVELOPMENT_PATH,
2724
extensionTestsPath: EXT_TESTS_PATH,
28-
// Avoid redownloading vscode if the test if flaky.
29-
cachePath: join(homedir(), '.cache/vscode-test'),
25+
cachePath: join(tmpDir, '.cache'),
3026
launchArgs: [
3127
PROJECT_PATH,
3228
// This disables all extensions except the one being tested
@@ -35,8 +31,8 @@ async function main() {
3531
'--no-sandbox',
3632
'--disable-dev-shm-usage',
3733
'--disable-software-rasterizer',
38-
`--extensions-dir=${vsCodeDataDir}/extensions`,
39-
`--user-data-dir=${vsCodeDataDir}/user-data`,
34+
`--extensions-dir=${join(tmpDir, 'extensions')}`,
35+
`--user-data-dir=${join(tmpDir, 'user-data')}`,
4036
],
4137
});
4238

0 commit comments

Comments
 (0)