Skip to content
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

Allow running tests against a specific VSIX #1349

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
39 changes: 27 additions & 12 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,71 @@ 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
- name: Build Extension
run: |
export NODE_VERSION=v18.19.0
export NODE_PATH=/usr/local/nvm/versions/node/v18.19.0/bin
export NVM_DIR=/usr/local/nvm
. .github/workflows/scripts/setup-linux.sh
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
npm ci
npm run compile
npm run 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=v18.19.0
NODE_PATH=/usr/local/nvm/versions/node/v18.19.0/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
VSCODE_TEST=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": "nightly-6.1"}, {"swift_version": "nightly-main"}]'
linux_env_vars: |
NODE_VERSION=v18.19.0
NODE_PATH=/usr/local/nvm/versions/node/v18.19.0/bin
NVM_DIR=/usr/local/nvm
CI=1
VSCODE_TEST=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
Expand All @@ -72,6 +84,9 @@ jobs:
CI=1
VSCODE_TEST=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
14 changes: 12 additions & 2 deletions .github/workflows/scripts/setup-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ export NODE_PATH=/usr/local/nvm/versions/node/v18.19.0/bin
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
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
}
22 changes: 21 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,34 @@ if (dataDir) {
if (process.platform === "darwin" && process.arch === "x64") {
launchArgs.push("--disable-gpu");
}
let vsixPath = process.env["VSCODE_SWIFT_VSIX"];
const install = [];
if (vsixPath) {
if (!path.isAbsolute(vsixPath)) {
vsixPath = path.join(__dirname, vsixPath);
}
console.log("Installing " + vsixPath);
install.push({
label: "installExtension",
installExtensions: vsixPath ? [vsixPath] : [],
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 +84,6 @@ module.exports = defineConfig({
},
},
reuseMachineInstall: !isCIBuild,
installExtensions: ["vadimcn.vscode-lldb"],
},
{
label: "unitTests",
Expand All @@ -84,6 +103,7 @@ module.exports = defineConfig({
},
},
},
skipExtensionDependencies: true,
reuseMachineInstall: !isCIBuild,
},
// you can specify additional test configurations, too
Expand Down
Loading
Loading