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
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Run CI jobs
on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '22'
- run: npm install
- run: npm run lint

test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '22'
- run: npm install
- run: xvfb-run -a npm test
14 changes: 0 additions & 14 deletions .github/workflows/lint.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from '@vscode/test-cli';

export default defineConfig({
files: 'out/test/**/*.test.js',
files: ['dist/test/setup.js', 'dist/test/**/*.test.js'],
});
102 changes: 42 additions & 60 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,46 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"label": "watch",
"dependsOn": [
"npm: watch:tsc",
"npm: watch:esbuild"
],
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"script": "watch:esbuild",
"group": "build",
"problemMatcher": "$esbuild-watch",
"isBackground": true,
"label": "npm: watch:esbuild",
"presentation": {
"group": "watch",
"reveal": "never"
}
},
{
"type": "npm",
"script": "watch:tsc",
"group": "build",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"label": "npm: watch:tsc",
"presentation": {
"group": "watch",
"reveal": "never"
}
},
{
"type": "npm",
"script": "watch-tests",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": "build"
},
{
"label": "tasks: watch-tests",
"dependsOn": [
"npm: watch",
"npm: watch-tests"
],
"problemMatcher": []
}
]
"version": "2.0.0",
"tasks": [
{
"label": "watch",
"dependsOn": ["npm: watch:esbuild"],
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"script": "watch:esbuild",
"group": "build",
"problemMatcher": "$esbuild-watch",
"isBackground": true,
"label": "npm: watch:esbuild",
"presentation": {
"group": "watch",
"reveal": "never"
}
},
{
"type": "npm",
"script": "watch-tests",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": "build"
},
{
"label": "tasks: watch-tests",
"dependsOn": ["npm: watch", "npm: watch-tests"],
"problemMatcher": []
}
]
}
89 changes: 89 additions & 0 deletions esbuild.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const esbuild = require('esbuild');
const fs = require('fs');
const path = require('path');

const production = process.argv.includes('--production');
const watch = process.argv.includes('--watch');

/**
* @type {import('esbuild').Plugin}
*/
const esbuildProblemMatcherPlugin = {
name: 'esbuild-problem-matcher',

setup(build) {
build.onStart(() => {
console.log('[watch] test build started');
});
build.onEnd(result => {
result.errors.forEach(({ text, location }) => {
console.error(`✘ [ERROR] ${text}`);
console.error(` ${location.file}:${location.line}:${location.column}:`);
});
console.log('[watch] test build finished');
});
},
};

/**
* @type {import('esbuild').Plugin}
*/
const copyAssetsPlugin = {
name: 'copy-assets',
setup(build) {
build.onEnd(() => {
const copyDir = (src, dest) => {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}

const entries = fs.readdirSync(src, { withFileTypes: true });

for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);

if (entry.isDirectory()) {
copyDir(srcPath, destPath);
} else {
fs.copyFileSync(srcPath, destPath);
}
}
};

copyDir('test-resources', 'dist/test-resources');
});
},
};

async function main() {
// Test build context
const testCtx = await esbuild.context({
entryPoints: ['src/test/**/*.ts'],
bundle: true,
format: 'cjs',
minify: production,
sourcemap: true,
sourcesContent: !production,
platform: 'node',
outdir: 'dist/test',
define: {
'process.env.NODE_ENV': JSON.stringify(production ? 'production' : 'development'),
},
external: ['vscode', 'mocha'],
logLevel: 'info',
plugins: [esbuildProblemMatcherPlugin, copyAssetsPlugin],
});

if (watch) {
await testCtx.watch();
} else {
await testCtx.rebuild();
await testCtx.dispose();
}
}

main().catch(e => {
console.error(e);
process.exit(1);
});
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import eslintConfigPrettier from 'eslint-config-prettier';

export default [
{
files: ['**/*.ts', '**/*.tsx'],
files: ['src/**/*.ts', 'src/**/*.tsx'],
},
{
plugins: {
Expand Down
Loading