Skip to content

Commit 5a621d8

Browse files
authored
Allow running tests against a specific VSIX (#1349)
* Allow running tests against a specific VSIX * Use VSIX in downstream jobs * Fix soundness * Make work for Windows * Install extension before running tests * Make work so we can run locally without publishing * Fix soundness errors * Fix formatting issue * Fix install of CodeLLDB * Add trailing new lines
1 parent 828d4ed commit 5a621d8

File tree

8 files changed

+1809
-66
lines changed

8 files changed

+1809
-66
lines changed

.github/workflows/nightly.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
runs-on: ubuntu-latest
1212
container:
1313
image: swift:6.0-jammy
14+
outputs:
15+
artifact-id: ${{ steps.archive.outputs.artifact-id }}
1416
steps:
1517
- name: Checkout repository
1618
uses: actions/checkout@v4
@@ -25,36 +27,53 @@ jobs:
2527
npm run compile
2628
npm run package
2729
npm run preview-package
30+
for file in *.vsix; do
31+
name="$(basename "$file" .vsix)-${{github.run_number}}.vsix"
32+
echo "Created bundle $name"
33+
mv "$file" "$name"
34+
done
2835
- name: Archive production artifacts
36+
id: archive
2937
uses: actions/upload-artifact@v4
30-
if: always()
38+
if: ${{ env.ACT != 'true' }}
3139
with:
40+
if-no-files-found: error
3241
name: vscode-swift-extension
3342
path: |
3443
*.vsix
44+
3545
tests_release:
3646
name: Test Release
47+
needs: package
3748
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
3849
with:
50+
needs_token: true
3951
# Linux
4052
linux_env_vars: |
4153
NODE_VERSION=v20.18.2
4254
NODE_PATH=/usr/local/nvm/versions/node/v20.18.2/bin
4355
NVM_DIR=/usr/local/nvm
4456
CI=1
57+
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
58+
GITHUB_REPOSITORY=${{github.repository}}
4559
linux_pre_build_command: . .github/workflows/scripts/setup-linux.sh
4660
linux_build_command: ./scripts/test.sh
4761
# Windows
4862
windows_env_vars: |
4963
CI=1
50-
windows_pre_build_command: .github\workflows\scripts\windows\install-nodejs.ps1
64+
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
65+
VSCODE_SWIFT_VSIX=vscode-swift.vsix
66+
GITHUB_REPOSITORY=${{github.repository}}
67+
windows_pre_build_command: .github\workflows\scripts\windows\setup.ps1
5168
windows_build_command: scripts\test_windows.ps1
5269
enable_windows_docker: false
5370

5471
tests_insiders:
5572
name: Test Insiders
73+
needs: package
5674
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
5775
with:
76+
needs_token: true
5877
# Linux
5978
linux_exclude_swift_versions: '[{"swift_version": "5.8"}, {"swift_version": "5.9"}, {"swift_version": "5.10"}, {"swift_version": "6.0"}, {"swift_version": "nightly-6.1"}, {"swift_version": "nightly-main"}]'
6079
linux_env_vars: |
@@ -63,13 +82,18 @@ jobs:
6382
NVM_DIR=/usr/local/nvm
6483
CI=1
6584
VSCODE_VERSION=insiders
85+
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
86+
GITHUB_REPOSITORY=${{github.repository}}
6687
linux_pre_build_command: . .github/workflows/scripts/setup-linux.sh
6788
linux_build_command: ./scripts/test.sh
6889
# Windows
6990
windows_exclude_swift_versions: '[{"swift_version": "5.9"}, {"swift_version": "6.0"}, {"swift_version": "nightly-6.1"}, {"swift_version": "nightly"}]'
7091
windows_env_vars: |
7192
CI=1
7293
VSCODE_VERSION=insiders
73-
windows_pre_build_command: .github\workflows\scripts\windows\install-nodejs.ps1
94+
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
95+
VSCODE_SWIFT_VSIX=vscode-swift.vsix
96+
GITHUB_REPOSITORY=${{github.repository}}
97+
windows_pre_build_command: .github\workflows\scripts\windows\setup.ps1
7498
windows_build_command: scripts\test_windows.ps1
7599
enable_windows_docker: false

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,14 @@ export NVM_DIR=/usr/local/nvm
2020
apt-get update && apt-get install -y rsync curl gpg libasound2 libgbm1 libgtk-3-0 libnss3 xvfb build-essential
2121
mkdir -p $NVM_DIR
2222
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
23-
/bin/bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION"
24-
echo "$NODE_PATH" >> "$GITHUB_PATH"
23+
# shellcheck disable=SC1091
24+
. $NVM_DIR/nvm.sh && nvm install $NODE_VERSION
25+
echo "$NODE_PATH" >> "$GITHUB_PATH"
26+
27+
env | sort
28+
29+
if [ -n "$VSCODE_SWIFT_VSIX_ID" ]; then
30+
npm ci --ignore-scripts
31+
npx tsx scripts/download_vsix.ts
32+
export VSCODE_SWIFT_VSIX="vscode-swift.vsix"
33+
fi

.github/workflows/scripts/windows/install-nodejs.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ if ($Process.ExitCode -eq 0) {
2121
Write-Host ('FAILED ({0})' -f $Process.ExitCode)
2222
exit 1
2323
}
24-
Remove-Item -Force $env:TEMP\node.msi
24+
Remove-Item -Force $env:TEMP\node.msi
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Install node.js
2+
. .github\workflows\scripts\windows\install-nodejs.ps1
3+
4+
# Download the VSIX archived upstream
5+
npm ci -ignore-script node-pty
6+
$Process = Start-Process npx "tsx scripts/download_vsix.ts" -Wait -PassThru -NoNewWindow
7+
if ($Process.ExitCode -eq 0) {
8+
Write-Host 'SUCCESS'
9+
} else {
10+
Write-Host ('FAILED ({0})' -f $Process.ExitCode)
11+
exit 1
12+
}

.vscode-test.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
const { defineConfig } = require("@vscode/test-cli");
1616
const path = require("path");
17+
const { version, publisher, name } = require("./package.json");
1718

1819
const isCIBuild = process.env["CI"] === "1";
1920
const isFastTestRun = process.env["FAST_TEST_RUN"] === "1";
@@ -39,15 +40,36 @@ if (dataDir) {
3940
if (process.platform === "darwin" && process.arch === "x64") {
4041
launchArgs.push("--disable-gpu");
4142
}
43+
let vsixPath = process.env["VSCODE_SWIFT_VSIX"];
44+
const install = [];
45+
const installExtensions = ["vadimcn.vscode-lldb", "llvm-vs-code-extensions.lldb-dap"];
46+
if (vsixPath) {
47+
if (!path.isAbsolute(vsixPath)) {
48+
vsixPath = path.join(__dirname, vsixPath);
49+
}
50+
console.log("Installing " + vsixPath);
51+
install.push({
52+
label: "installExtension",
53+
installExtensions: installExtensions.concat(vsixPath ? [vsixPath] : []),
54+
launchArgs,
55+
files: [],
56+
version: process.env["VSCODE_VERSION"] ?? "stable",
57+
reuseMachineInstall: !isCIBuild,
58+
});
59+
}
4260

4361
module.exports = defineConfig({
4462
tests: [
63+
...install,
4564
{
4665
label: "integrationTests",
4766
files: ["dist/test/common.js", "dist/test/integration-tests/**/*.test.js"],
4867
version: process.env["VSCODE_VERSION"] ?? "stable",
4968
workspaceFolder: "./assets/test",
5069
launchArgs,
70+
extensionDevelopmentPath: vsixPath
71+
? [`${__dirname}/.vscode-test/extensions/${publisher}.${name}-${version}`]
72+
: undefined,
5173
mocha: {
5274
ui: "tdd",
5375
color: true,
@@ -64,7 +86,7 @@ module.exports = defineConfig({
6486
},
6587
},
6688
reuseMachineInstall: !isCIBuild,
67-
installExtensions: ["vadimcn.vscode-lldb", "llvm-vs-code-extensions.lldb-dap"],
89+
installExtensions,
6890
},
6991
{
7092
label: "unitTests",
@@ -84,6 +106,7 @@ module.exports = defineConfig({
84106
},
85107
},
86108
},
109+
skipExtensionDependencies: true,
87110
reuseMachineInstall: !isCIBuild,
88111
},
89112
// you can specify additional test configurations, too

0 commit comments

Comments
 (0)