Skip to content
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
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ updates:
# These versions must match the versions specified in coder/coder exactly.
- dependency-name: "@types/ua-parser-js"
- dependency-name: "ua-parser-js"
# @types/node major version must match our minimum Node.js version.
- dependency-name: "@types/node"
update-types: ["version-update:semver-major"]
69 changes: 53 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,88 @@ jobs:
steps:
- uses: actions/checkout@v6

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v6
with:
node-version: "22"
cache: "yarn"
cache: "pnpm"

- run: yarn
- run: pnpm install

- run: yarn prettier --check .
- run: pnpm prettier --check .

- run: yarn lint
- run: pnpm lint

- run: yarn build
- run: pnpm build

test:
name: Test
test-unit:
name: Unit Test (Electron ${{ matrix.electron-version }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# Minimum supported version: VS Code 1.95 (Oct 2024) -> Electron 32 -> Node 20
electron-version: ["32", "latest"]

steps:
- uses: actions/checkout@v6

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v6
with:
node-version: "22"
cache: "yarn"
cache: "pnpm"

- run: yarn
- run: pnpm install

- run: yarn test:ci
- name: Run tests with Electron ${{ matrix.electron-version }}
run: ./scripts/test-electron.sh ${{ matrix.electron-version }}
env:
CI: true

test-integration:
name: Integration Test (VS Code ${{ matrix.vscode-version }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
vscode-version: ["1.95.0", "stable"]

steps:
- uses: actions/checkout@v6

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v6
with:
node-version: "22"
cache: "pnpm"

- run: pnpm install

- run: pnpm build

- name: Run integration tests on VS Code ${{ matrix.vscode-version }}
run: xvfb-run -a pnpm test:integration --label "VS Code ${{ matrix.vscode-version }}"

package:
name: Package
runs-on: ubuntu-22.04
needs: [lint, test]
needs: [lint, test-unit, test-integration]
steps:
- uses: actions/checkout@v6

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v6
with:
node-version: "22"
cache: "yarn"
cache: "pnpm"

- name: Install dependencies
run: |
yarn
npm install -g @vscode/vsce
run: pnpm install

- name: Get version from package.json
id: version
Expand All @@ -80,7 +117,7 @@ jobs:
echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT

- name: Package extension
run: vsce package --out "${{ steps.setup.outputs.packageName }}"
run: pnpm vsce package --no-dependencies --out "${{ steps.setup.outputs.packageName }}"

- name: Upload artifact (PR)
if: github.event_name == 'pull_request'
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ jobs:
steps:
- uses: actions/checkout@v6

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v6
with:
node-version: "22"
cache: "pnpm"

- name: Extract version from tag
id: version
Expand All @@ -45,9 +48,7 @@ jobs:
echo "Version validation successful: $TAG_VERSION"

- name: Install dependencies
run: |
yarn
npm install -g @vscode/vsce
run: pnpm install

- name: Setup package path
id: setup
Expand All @@ -57,7 +58,7 @@ jobs:
echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT

- name: Package extension
run: vsce package --pre-release --out "${{ steps.setup.outputs.packageName }}"
run: pnpm vsce package --no-dependencies --pre-release --out "${{ steps.setup.outputs.packageName }}"

- name: Upload artifact
uses: actions/upload-artifact@v6
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ jobs:
steps:
- uses: actions/checkout@v6

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v6
with:
node-version: "22"
cache: "pnpm"

- name: Extract version from tag
id: version
Expand All @@ -45,9 +48,7 @@ jobs:
echo "Version validation successful: $TAG_VERSION"

- name: Install dependencies
run: |
yarn
npm install -g @vscode/vsce
run: pnpm install

- name: Setup package path
id: setup
Expand All @@ -57,7 +58,7 @@ jobs:
echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT

- name: Package extension
run: vsce package --out "${{ steps.setup.outputs.packageName }}"
run: pnpm vsce package --no-dependencies --out "${{ steps.setup.outputs.packageName }}"

- name: Upload artifact
uses: actions/upload-artifact@v6
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/.nyc_output/
/coverage/
*.vsix
yarn-error.log
pnpm-debug.log
.eslintcache
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
/coverage/
*.vsix
flake.lock
yarn-error.log
pnpm-debug.log
pnpm-lock.yaml
17 changes: 15 additions & 2 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { defineConfig } from "@vscode/test-cli";

export default defineConfig({
// VS Code to Electron/Node version mapping:
// VS Code 1.95 (Oct 2024) -> Node 20 - Minimum supported
// VS Code stable -> Latest
const versions = ["1.95.0", "stable"];

const baseConfig = {
files: "out/test/integration/**/*.test.js",
extensionDevelopmentPath: ".",
extensionTestsPath: "./out/test",
Expand All @@ -9,4 +14,12 @@ export default defineConfig({
ui: "tdd",
timeout: 20000,
},
});
};

export default defineConfig(
versions.map((version) => ({
...baseConfig,
version,
label: `VS Code ${version}`,
})),
);
9 changes: 6 additions & 3 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ coverage/**
# Development files
src/**
test/**
scripts/**
**/*.ts
**/*.map

Expand All @@ -14,15 +15,17 @@ test/**
.vscode-test/**
.vscode-test.mjs
tsconfig.json
.eslintrc.json
eslint.config.mjs
.eslintcache
esbuild.mjs
.editorconfig
.prettierignore
.eslintignore
**/.gitignore
**/.git-blame-ignore-revs

# Package manager files
yarn.lock
pnpm-lock.yaml
pnpm-workspace.yaml

# Nix/flake files
flake.nix
Expand Down
22 changes: 12 additions & 10 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ Comments explain what code does or why it exists:

## Build and Test Commands

- Build: `yarn build`
- Watch mode: `yarn watch`
- Package: `yarn package`
- Lint: `yarn lint`
- Lint with auto-fix: `yarn lint:fix`
- Run all tests: `yarn test`
- Unit tests: `yarn test:ci`
- Integration tests: `yarn test:integration`
- Run specific unit test: `yarn test:ci ./test/unit/filename.test.ts`
- Run specific integration test: `yarn test:integration ./test/integration/filename.test.ts`
- Build: `pnpm build`
- Watch mode: `pnpm watch`
- Package: `pnpm package`
- Format: `pnpm fmt`
- Format check: `pnpm fmt:check`
- Lint: `pnpm lint`
- Lint with auto-fix: `pnpm lint:fix`
- Run all tests: `pnpm test`
- Unit tests: `pnpm test:ci`
- Integration tests: `pnpm test:integration`
- Run specific unit test: `pnpm test:ci ./test/unit/filename.test.ts`
- Run specific integration test: `pnpm test:integration ./test/integration/filename.test.ts`

## Code Style

Expand Down
33 changes: 25 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,17 @@ The link format is `vscode://coder.coder-remote/open?${query}`. For example:
code --open-url 'vscode://coder.coder-remote/open?url=dev.coder.com&owner=my-username&workspace=my-ws&agent=my-agent'
```

There are some unit tests as well:
There are unit tests using `vitest` with mocked VS Code APIs:

```bash
yarn test
pnpm test:ci
```

Note that we have an unusual testing setup with `vitest`; this needs to be
changed back to how using the standard testing framework for VS Code extensions
was but for now it means some things are difficult to test as you cannot import
`vscode` in tests or write any UI tests.
There are also integration tests that run inside a real VS Code instance:

```bash
pnpm test:integration
```

## Development

Expand All @@ -98,7 +99,7 @@ was but for now it means some things are difficult to test as you cannot import
> this extension from a coder workspace. We currently recommend cloning the
> repo locally

1. Run `yarn watch` in the background.
1. Run `pnpm watch` in the background.
2. OPTIONAL: Compile the `coder` binary and place it in the equivalent of
`os.tmpdir() + "/coder"`. If this is missing, it will download the binary
from the Coder deployment, as it normally would. Reading from `/tmp/coder` is
Expand All @@ -116,14 +117,30 @@ was but for now it means some things are difficult to test as you cannot import
4. If your change is something users ought to be aware of, add an entry in the
changelog.

## Node.js Version

This extension targets the Node.js version bundled with VS Code's Electron:

| VS Code | Electron | Node.js | Status |
| ------- | -------- | ------- | ----------------- |
| 1.95 | 32 | 20 | Minimum supported |
| stable | latest | varies | Also tested in CI |

When updating the minimum Node.js version, update these files:

- **package.json**: `engines.vscode`, `engines.node`, `@types/node`, `@tsconfig/nodeXX`
- **tsconfig.json**: `extends` (the `@tsconfig/nodeXX` package), `lib` (match base ESNext version)
- **esbuild.mjs**: `target`
- **.github/workflows/ci.yaml**: `electron-version` and `vscode-version` matrices

## Dependencies

Some dependencies are not directly used in the source but are required anyway.

- `bufferutil` and `utf-8-validate` are peer dependencies of `ws`.
- `ua-parser-js` and `dayjs` are used by the Coder API client.

The coder client is vendored from coder/coder. Every now and then, we should be running `yarn upgrade coder --latest`
The coder client is vendored from coder/coder. Every now and then, we should be running `pnpm update coder`
to make sure we're using up to date versions of the client.

## Releasing
Expand Down
Loading