Skip to content

Commit

Permalink
Test and lint in gh actions
Browse files Browse the repository at this point in the history
This commits add steps to lint and test extension before we publish on
tagging. In addition, another gh action is added to lint and test for
all pushes and PRs.

`xvfb-run` is used gh action so the vscode can run in a virtual X server
when running in the ubuntu testing environment.

npe is added as dev dependency and being used to change `main` of
`package.json` in pre and post test. When building to debug or deploy,
webpack is used which outputs a single script file to
`dist/extension.js`; When compile for test, typescript compiler (tsc)
is used which outputs transpiled js files to `out`. The path to `main`
needs to be changed to `out/extension.js` to accommodate the output of
tsc, so our extension launched can be activated in the test vscode
instance.

See microsoft/vscode#85779
stevenguh committed Aug 6, 2021
1 parent fdebaef commit 84013ab
Showing 4 changed files with 95 additions and 7 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on: [push, pull_request]

name: Build Extension
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout vscode-which-key
uses: actions/checkout@v2

- name: Set up node.js
uses: actions/setup-node@v2
with:
node-version: 12

- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Lint
run: npm run lint

- name: Test
run: xvfb-run -a npm run test
20 changes: 17 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -2,21 +2,35 @@ on:
push:
tags:
- v*

name: Deploy Extension
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- name: Checkout vscode-which-key
uses: actions/checkout@v2

- name: Set up node.js
uses: actions/setup-node@v2
with:
node-version: 12
- run: npm ci

- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Lint
run: npm run lint

- name: Test
run: xvfb-run -a npm run test

- name: Publish to Open VSX Registry
uses: HaaLeo/publish-vscode-extension@v0
id: publishToOpenVSX
with:
pat: ${{ secrets.OVSX_TOKEN }}

- name: Publish to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@v0
with:
50 changes: 50 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
"onCommand:whichkey.showTransient",
"onCommand:whichkey.register"
],
"main": "./dist/extension.js",
"main": "./dist/extension",
"contributes": {
"keybindings": [
{
@@ -1479,10 +1479,10 @@
"scripts": {
"vscode:prepublish": "webpack --mode production",
"compile": "webpack --mode development",
"watch": "tsc -watch -p ./",
"lint": "eslint src --ext ts",
"test-compile": "tsc -p ./",
"pretest": "npm run test-compile && npm run lint",
"test-compile": "tsc -p .",
"pretest": "npm run test-compile && npx npe main ./out/extension",
"posttest": "npx npe main ./dist/extension",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
@@ -1495,6 +1495,7 @@
"eslint": "^7.22.0",
"glob": "^7.1.6",
"mocha": "^8.3.2",
"npe": "^1.1.4",
"ts-loader": "^8.0.18",
"typescript": "^4.2.3",
"vscode-test": "^1.5.1",

0 comments on commit 84013ab

Please sign in to comment.