Skip to content

Commit bc52ec9

Browse files
authored
Install extensions one at a time (#1752)
1 parent 175d0cc commit bc52ec9

File tree

7 files changed

+83
-24
lines changed

7 files changed

+83
-24
lines changed

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
CI=1
9797
VSCODE_VERSION=insiders
9898
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
99-
VSCODE_SWIFT_VSIX=vscode-swift.vsix
99+
VSCODE_SWIFT_PRERELEASE_VSIX=vscode-swift-prerelease.vsix
100100
GITHUB_REPOSITORY=${{github.repository}}
101101
windows_pre_build_command: .github\workflows\scripts\windows\setup.ps1
102102
windows_build_command: scripts\test_windows.ps1

.github/workflows/scripts/setup-linux.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ if [ -n "$VSCODE_SWIFT_VSIX_ID" ]; then
3030
npm ci --ignore-scripts
3131
npx tsx scripts/download_vsix.ts
3232
export VSCODE_SWIFT_VSIX="vscode-swift.vsix"
33+
export VSCODE_SWIFT_PRERELEASE_VSIX="vscode-swift-prerelease.vsix"
3334
fi

.vscode-test.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
const { defineConfig } = require("@vscode/test-cli");
1616
const path = require("path");
1717
const { version, publisher, name } = require("./package.json");
18+
const { preview } = require("./scripts/versions");
1819

1920
const isCIBuild = process.env["CI"] === "1";
2021
const isFastTestRun = process.env["FAST_TEST_RUN"] === "1";
@@ -40,19 +41,31 @@ if (dataDir) {
4041
if (process.platform === "darwin" && process.arch === "x64") {
4142
launchArgs.push("--disable-gpu");
4243
}
43-
let vsixPath = process.env["VSCODE_SWIFT_VSIX"];
44+
const isStableRun = process.env["VSCODE_VERSION"] !== "insiders";
45+
let versionStr = version;
46+
if (!isStableRun) {
47+
const segments = version.split(".").map(v => parseInt(v, 10));
48+
versionStr = preview({ major: segments[0], minor: segments[1], patch: segments[2] });
49+
}
50+
let vsixPath = isStableRun
51+
? process.env["VSCODE_SWIFT_VSIX"]
52+
: process.env["VSCODE_SWIFT_PRERELEASE_VSIX"];
4453
const install = [];
4554
const installExtensions = ["vadimcn.vscode-lldb", "llvm-vs-code-extensions.lldb-dap"];
4655
if (vsixPath) {
4756
if (!path.isAbsolute(vsixPath)) {
4857
vsixPath = path.join(__dirname, vsixPath);
4958
}
5059
console.log("Installing " + vsixPath);
60+
installExtensions.push(vsixPath);
61+
}
62+
63+
for (const ext of installExtensions) {
5164
install.push({
52-
label: "installExtension",
53-
installExtensions: installExtensions.concat(vsixPath ? [vsixPath] : []),
65+
label: `installExtension-${ext}`,
66+
installExtensions: [ext],
5467
launchArgs,
55-
files: [],
68+
files: ["dist/test/sleep.test.js"],
5669
version: process.env["VSCODE_VERSION"] ?? "stable",
5770
reuseMachineInstall: !isCIBuild,
5871
});
@@ -68,7 +81,7 @@ module.exports = defineConfig({
6881
workspaceFolder: "./assets/test",
6982
launchArgs,
7083
extensionDevelopmentPath: vsixPath
71-
? [`${__dirname}/.vscode-test/extensions/${publisher}.${name}-${version}`]
84+
? [`${__dirname}/.vscode-test/extensions/${publisher}.${name}-${versionStr}`]
7285
: undefined,
7386
env: {
7487
VSCODE_TEST: "1",
@@ -107,7 +120,7 @@ module.exports = defineConfig({
107120
workspaceFolder: "./assets/test.code-workspace",
108121
launchArgs,
109122
extensionDevelopmentPath: vsixPath
110-
? [`${__dirname}/.vscode-test/extensions/${publisher}.${name}-${version}`]
123+
? [`${__dirname}/.vscode-test/extensions/${publisher}.${name}-${versionStr}`]
111124
: undefined,
112125
env: {
113126
VSCODE_TEST: "1",

scripts/dev_package.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import {
2020
main,
2121
updateChangelog,
2222
} from "./lib/utilities";
23+
// eslint-disable-next-line @typescript-eslint/no-require-imports
24+
const { dev } = require("./versions");
2325

2426
// eslint-disable-next-line @typescript-eslint/no-floating-promises
2527
main(async () => {
2628
const rootDirectory = getRootDirectory();
2729
const version = await getExtensionVersion();
2830
// Increment the patch version from the package.json
29-
const patch = version.patch + 1;
30-
const devVersion = `${version.major}.${version.minor}.${patch}-dev`;
31+
const devVersion = dev(version);
3132
// Update version in CHANGELOG
3233
await updateChangelog(devVersion);
3334
// Use VSCE to package the extension

scripts/preview_package.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,16 @@ import {
1919
main,
2020
updateChangelog,
2121
} from "./lib/utilities";
22-
23-
/**
24-
* Formats the given date as a string in the form "YYYYMMdd".
25-
*
26-
* @param date The date to format as a string.
27-
* @returns The formatted date.
28-
*/
29-
function formatDate(date: Date): string {
30-
const year = date.getUTCFullYear().toString().padStart(4, "0");
31-
const month = (date.getUTCMonth() + 1).toString().padStart(2, "0");
32-
const day = date.getUTCDate().toString().padStart(2, "0");
33-
return year + month + day;
34-
}
22+
// eslint-disable-next-line @typescript-eslint/no-require-imports
23+
const { preview } = require("./versions");
3524

3625
// eslint-disable-next-line @typescript-eslint/no-floating-promises
3726
main(async () => {
3827
const rootDirectory = getRootDirectory();
3928
const version = await getExtensionVersion();
4029
// Increment the minor version and set the patch version to today's date
4130
const minor = version.minor + 1;
42-
const patch = formatDate(new Date());
43-
const previewVersion = `${version.major}.${minor}.${patch}`;
31+
const previewVersion = preview(version);
4432
// Make sure that the new minor version is odd
4533
if (minor % 2 !== 1) {
4634
throw new Error(

scripts/versions.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the VS Code Swift open source project
4+
//
5+
// Copyright (c) 2025 the VS Code Swift project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of VS Code Swift project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
/**
15+
* Formats the given date as a string in the form "YYYYMMdd".
16+
*
17+
* @param date The date to format as a string.
18+
* @returns The formatted date.
19+
*/
20+
function formatDate(date) {
21+
const year = date.getUTCFullYear().toString().padStart(4, "0");
22+
const month = (date.getUTCMonth() + 1).toString().padStart(2, "0");
23+
const day = date.getUTCDate().toString().padStart(2, "0");
24+
return year + month + day;
25+
}
26+
27+
module.exports = {
28+
preview: function (version) {
29+
const minor = version.minor + 1;
30+
const patch = formatDate(new Date());
31+
return `${version.major}.${minor}.${patch}`;
32+
},
33+
dev: function (version) {
34+
const patch = version.patch + 1;
35+
return `${version.major}.${version.minor}.${patch}-dev`;
36+
},
37+
};

test/sleep.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the VS Code Swift open source project
4+
//
5+
// Copyright (c) 2025 the VS Code Swift project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of VS Code Swift project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
suite("Sleep", () => {
16+
test("Wait 5 seconds...", async () => {
17+
await new Promise(r => setTimeout(r, 5000));
18+
}).timeout(10000);
19+
});

0 commit comments

Comments
 (0)