Skip to content

Allow running tests against a specific VSIX #1349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
runs-on: ubuntu-latest
container:
image: swift:6.0-jammy
outputs:
artifact-id: ${{ steps.archive.outputs.artifact-id }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -25,36 +27,53 @@ jobs:
npm run compile
npm run package
npm run preview-package
for file in *.vsix; do
name="$(basename "$file" .vsix)-${{github.run_number}}.vsix"
echo "Created bundle $name"
mv "$file" "$name"
done
- name: Archive production artifacts
id: archive
uses: actions/upload-artifact@v4
if: always()
if: ${{ env.ACT != 'true' }}
with:
if-no-files-found: error
name: vscode-swift-extension
path: |
*.vsix

tests_release:
name: Test Release
needs: package
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
needs_token: true
# Linux
linux_env_vars: |
NODE_VERSION=v20.18.2
NODE_PATH=/usr/local/nvm/versions/node/v20.18.2/bin
NVM_DIR=/usr/local/nvm
CI=1
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
GITHUB_REPOSITORY=${{github.repository}}
linux_pre_build_command: . .github/workflows/scripts/setup-linux.sh
linux_build_command: ./scripts/test.sh
# Windows
windows_env_vars: |
CI=1
windows_pre_build_command: .github\workflows\scripts\windows\install-nodejs.ps1
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
VSCODE_SWIFT_VSIX=vscode-swift.vsix
GITHUB_REPOSITORY=${{github.repository}}
windows_pre_build_command: .github\workflows\scripts\windows\setup.ps1
windows_build_command: scripts\test_windows.ps1
enable_windows_docker: false

tests_insiders:
name: Test Insiders
needs: package
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
needs_token: true
# Linux
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"}]'
linux_env_vars: |
Expand All @@ -63,13 +82,18 @@ jobs:
NVM_DIR=/usr/local/nvm
CI=1
VSCODE_VERSION=insiders
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
GITHUB_REPOSITORY=${{github.repository}}
linux_pre_build_command: . .github/workflows/scripts/setup-linux.sh
linux_build_command: ./scripts/test.sh
# Windows
windows_exclude_swift_versions: '[{"swift_version": "5.9"}, {"swift_version": "6.0"}, {"swift_version": "nightly-6.1"}, {"swift_version": "nightly"}]'
windows_env_vars: |
CI=1
VSCODE_VERSION=insiders
windows_pre_build_command: .github\workflows\scripts\windows\install-nodejs.ps1
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
VSCODE_SWIFT_VSIX=vscode-swift.vsix
GITHUB_REPOSITORY=${{github.repository}}
windows_pre_build_command: .github\workflows\scripts\windows\setup.ps1
windows_build_command: scripts\test_windows.ps1
enable_windows_docker: false
13 changes: 11 additions & 2 deletions .github/workflows/scripts/setup-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,14 @@ export NVM_DIR=/usr/local/nvm
apt-get update && apt-get install -y rsync curl gpg libasound2 libgbm1 libgtk-3-0 libnss3 xvfb build-essential
mkdir -p $NVM_DIR
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
/bin/bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION"
echo "$NODE_PATH" >> "$GITHUB_PATH"
# shellcheck disable=SC1091
. $NVM_DIR/nvm.sh && nvm install $NODE_VERSION
echo "$NODE_PATH" >> "$GITHUB_PATH"

env | sort

if [ -n "$VSCODE_SWIFT_VSIX_ID" ]; then
npm ci --ignore-scripts
npx tsx scripts/download_vsix.ts
export VSCODE_SWIFT_VSIX="vscode-swift.vsix"
fi
2 changes: 1 addition & 1 deletion .github/workflows/scripts/windows/install-nodejs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ if ($Process.ExitCode -eq 0) {
Write-Host ('FAILED ({0})' -f $Process.ExitCode)
exit 1
}
Remove-Item -Force $env:TEMP\node.msi
Remove-Item -Force $env:TEMP\node.msi
12 changes: 12 additions & 0 deletions .github/workflows/scripts/windows/setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Install node.js
. .github\workflows\scripts\windows\install-nodejs.ps1

# Download the VSIX archived upstream
npm ci -ignore-script node-pty
$Process = Start-Process npx "tsx scripts/download_vsix.ts" -Wait -PassThru -NoNewWindow
if ($Process.ExitCode -eq 0) {
Write-Host 'SUCCESS'
} else {
Write-Host ('FAILED ({0})' -f $Process.ExitCode)
exit 1
}
25 changes: 24 additions & 1 deletion .vscode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

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

const isCIBuild = process.env["CI"] === "1";
const isFastTestRun = process.env["FAST_TEST_RUN"] === "1";
Expand All @@ -39,15 +40,36 @@ if (dataDir) {
if (process.platform === "darwin" && process.arch === "x64") {
launchArgs.push("--disable-gpu");
}
let vsixPath = process.env["VSCODE_SWIFT_VSIX"];
const install = [];
const installExtensions = ["vadimcn.vscode-lldb", "llvm-vs-code-extensions.lldb-dap"];
if (vsixPath) {
if (!path.isAbsolute(vsixPath)) {
vsixPath = path.join(__dirname, vsixPath);
}
console.log("Installing " + vsixPath);
install.push({
label: "installExtension",
installExtensions: installExtensions.concat(vsixPath ? [vsixPath] : []),
launchArgs,
files: [],
version: process.env["VSCODE_VERSION"] ?? "stable",
reuseMachineInstall: !isCIBuild,
});
}

module.exports = defineConfig({
tests: [
...install,
{
label: "integrationTests",
files: ["dist/test/common.js", "dist/test/integration-tests/**/*.test.js"],
version: process.env["VSCODE_VERSION"] ?? "stable",
workspaceFolder: "./assets/test",
launchArgs,
extensionDevelopmentPath: vsixPath
? [`${__dirname}/.vscode-test/extensions/${publisher}.${name}-${version}`]
: undefined,
mocha: {
ui: "tdd",
color: true,
Expand All @@ -64,7 +86,7 @@ module.exports = defineConfig({
},
},
reuseMachineInstall: !isCIBuild,
installExtensions: ["vadimcn.vscode-lldb", "llvm-vs-code-extensions.lldb-dap"],
installExtensions,
},
{
label: "unitTests",
Expand All @@ -84,6 +106,7 @@ module.exports = defineConfig({
},
},
},
skipExtensionDependencies: true,
reuseMachineInstall: !isCIBuild,
},
// you can specify additional test configurations, too
Expand Down
Loading