Skip to content

Commit a109ffd

Browse files
committed
Add linting steps and improve testing steps
1 parent b29346e commit a109ffd

File tree

7 files changed

+172
-85
lines changed

7 files changed

+172
-85
lines changed

.drone.yml

+88-52
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,29 @@ platform:
66
arch: amd64
77

88
steps:
9-
- name: submodules
10-
image: alpine/git
9+
- name: cache:restore
10+
image: codercom/nbin:centos
1111
commands:
12-
- git submodule update --init
12+
- yum install -y libxkbfile-devel libsecret-devel
13+
- . /opt/rh/devtoolset-6/enable
14+
- ./scripts/cacher.sh
1315

14-
- name: cache:restore
16+
- name: lint
1517
image: node:12
1618
commands:
17-
- ./scripts/cacher.sh
19+
- yarn lint
20+
21+
- name: test
22+
image: node:12
23+
commands:
24+
- yarn test
1825

1926
- name: build
2027
image: codercom/nbin:centos
2128
commands:
2229
- yum install -y libxkbfile-devel libsecret-devel
2330
- . /opt/rh/devtoolset-6/enable
24-
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing so we can preserve cache for the next run'
31+
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
2532

2633
- name: cache:package
2734
image: node:12
@@ -40,10 +47,10 @@ steps:
4047
when:
4148
event: push
4249

43-
- name: test
50+
- name: test:build
4451
image: node:12
4552
commands:
46-
- yarn test
53+
- yarn test:build
4754

4855
- name: publish:github
4956
image: plugins/github-release
@@ -90,21 +97,28 @@ platform:
9097
arch: amd64
9198

9299
steps:
93-
- name: submodules
94-
image: alpine/git
95-
commands:
96-
- git submodule update --init
97-
98100
- name: cache:restore
99101
image: node:12-alpine
100102
commands:
103+
- apk add libxkbfile-dev libsecret-dev build-base git bash python
101104
- ./scripts/cacher.sh
102105

106+
- name: lint
107+
image: node:12-alpine
108+
commands:
109+
- yarn lint
110+
111+
- name: test
112+
image: node:12-alpine
113+
commands:
114+
- apk add openssl
115+
- yarn test
116+
103117
- name: build
104118
image: node:12-alpine
105119
commands:
106120
- apk add libxkbfile-dev libsecret-dev build-base git bash python
107-
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing so we can preserve cache for the next run'
121+
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
108122

109123
- name: cache:package
110124
image: node:12-alpine
@@ -123,10 +137,10 @@ steps:
123137
when:
124138
event: push
125139

126-
- name: test
140+
- name: test:build
127141
image: node:12-alpine
128142
commands:
129-
- yarn test
143+
- yarn test:build
130144

131145
- name: publish:github
132146
image: plugins/github-release
@@ -159,22 +173,27 @@ platform:
159173
arch: arm64
160174

161175
steps:
162-
- name: submodules
163-
image: alpine
164-
commands:
165-
- apk add git
166-
- git submodule update --init
167-
168176
- name: cache:restore
169177
image: node:12
170178
commands:
179+
- apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
171180
- ./scripts/cacher.sh
172181

182+
- name: lint
183+
image: node:12
184+
commands:
185+
- yarn lint
186+
187+
- name: test
188+
image: node:12
189+
commands:
190+
- yarn test
191+
173192
- name: build
174193
image: node:12
175194
commands:
176195
- apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
177-
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing so we can preserve cache for the next run'
196+
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
178197

179198
- name: cache:package
180199
image: node:12
@@ -193,10 +212,10 @@ steps:
193212
when:
194213
event: push
195214

196-
- name: test
215+
- name: test:build
197216
image: node:12
198217
commands:
199-
- yarn test
218+
- yarn test:build
200219

201220
- name: publish:github
202221
image: plugins/github-release
@@ -243,22 +262,28 @@ platform:
243262
arch: arm64
244263

245264
steps:
246-
- name: submodules
247-
image: alpine
248-
commands:
249-
- apk add git
250-
- git submodule update --init
251-
252265
- name: cache:restore
253266
image: node:12-alpine
254267
commands:
268+
- apk add libxkbfile-dev libsecret-dev build-base git bash python
255269
- ./scripts/cacher.sh
256270

271+
- name: lint
272+
image: node:12-alpine
273+
commands:
274+
- yarn lint
275+
276+
- name: test
277+
image: node:12-alpine
278+
commands:
279+
- apk add openssl
280+
- yarn test
281+
257282
- name: build
258283
image: node:12-alpine
259284
commands:
260285
- apk add libxkbfile-dev libsecret-dev build-base git bash python
261-
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing so we can preserve cache for the next run'
286+
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
262287

263288
- name: cache:package
264289
image: node:12-alpine
@@ -277,10 +302,10 @@ steps:
277302
when:
278303
event: push
279304

280-
- name: test
305+
- name: test:build
281306
image: node:12-alpine
282307
commands:
283-
- yarn test
308+
- yarn test:build
284309

285310
- name: publish:github
286311
image: plugins/github-release
@@ -313,22 +338,27 @@ platform:
313338
arch: arm
314339

315340
steps:
316-
- name: submodules
317-
image: alpine
318-
commands:
319-
- apk add git
320-
- git submodule update --init
321-
322341
- name: cache:restore
323342
image: node:12
324343
commands:
344+
- apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
325345
- ./scripts/cacher.sh
326346

347+
- name: lint
348+
image: node:12
349+
commands:
350+
- yarn lint
351+
352+
- name: test
353+
image: node:12
354+
commands:
355+
- yarn test
356+
327357
- name: build
328358
image: node:12
329359
commands:
330360
- apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
331-
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing so we can preserve cache for the next run'
361+
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
332362

333363
- name: cache:package
334364
image: node:12
@@ -347,11 +377,11 @@ steps:
347377
when:
348378
event: push
349379

350-
- name: test
380+
- name: test:build
351381
image: node:12
352382
failure: ignore
353383
commands:
354-
- yarn test
384+
- yarn test:build
355385

356386
# - name: publish:github
357387
# image: plugins/github-release
@@ -388,22 +418,28 @@ platform:
388418
arch: arm
389419

390420
steps:
391-
- name: submodules
392-
image: alpine
393-
commands:
394-
- apk add git
395-
- git submodule update --init
396-
397421
- name: cache:restore
398422
image: node:12-alpine
399423
commands:
424+
- apk add libxkbfile-dev libsecret-dev build-base git bash python
400425
- ./scripts/cacher.sh
401426

427+
- name: lint
428+
image: node:12-alpine
429+
commands:
430+
- yarn lint
431+
432+
- name: test
433+
image: node:12-alpine
434+
commands:
435+
- apk add openssl
436+
- yarn test
437+
402438
- name: build
403439
image: node:12-alpine
404440
commands:
405441
- apk add libxkbfile-dev libsecret-dev build-base git bash python
406-
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing so we can preserve cache for the next run'
442+
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
407443

408444
- name: cache:package
409445
image: node:12-alpine
@@ -422,11 +458,11 @@ steps:
422458
when:
423459
event: push
424460

425-
- name: test
461+
- name: test:build
426462
image: node:12-alpine
427463
failure: ignore
428464
commands:
429-
- yarn test
465+
- yarn test:build
430466

431467
# - name: publish:github
432468
# image: plugins/github-release

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"patch:generate": "cd ./lib/vscode && git diff HEAD > ../../scripts/vscode.patch",
1010
"patch:apply": "cd ./lib/vscode && git apply ../../scripts/vscode.patch",
1111
"test": "mocha -r ts-node/register ./test/*.test.ts",
12-
"lint:js": "eslint {src,test,scripts} --ext .ts,.tsx",
12+
"test:build": "./scripts/test.sh",
13+
"lint:js": "eslint src test scripts --ext .ts,.tsx",
1314
"lint:css": "stylelint 'src/**/*.css'",
1415
"lint": "./scripts/lint.sh",
1516
"watch": "yarn runner watch",

scripts/cacher.sh

+12-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,18 @@ main() {
4646

4747
# The action is determined by the name of the step.
4848
case $DRONE_STEP_NAME in
49-
*restore*) restore "$branch" "$DRONE_REPO_BRANCH" ;;
49+
*restore*)
50+
# Sub-modules must be pulled first since extracting the cache directories
51+
# will prevent git from cloning into them.
52+
git submodule update --init
53+
54+
restore "$branch" "$DRONE_REPO_BRANCH"
55+
56+
# Now make sure the pulled Node modules are up to date.
57+
YARN_CACHE_FOLDER="$(pwd)/yarn-cache"
58+
export YARN_CACHE_FOLDER
59+
yarn
60+
;;
5061
*rebuild*|*package*) package "$branch" ;;
5162
*) exit 1 ;;
5263
esac

scripts/ci.bash

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
set -euo pipefail
55

6+
# This script assumes that yarn has already ran.
67
function main() {
78
cd "$(dirname "${0}")/.."
89

@@ -21,10 +22,6 @@ function main() {
2122
export PACKAGE="true"
2223
fi
2324

24-
if [[ -z ${SKIP_YARN:-} ]] ; then
25-
yarn
26-
fi
27-
2825
yarn build
2926
yarn binary
3027
if [[ -n ${PACKAGE:-} ]] ; then

scripts/test.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env sh
2+
# test.sh -- Simple build test.
3+
4+
set -eu
5+
6+
main() {
7+
cd "$(dirname "$0")/.."
8+
9+
# The main goal here is to ensure that the build fully completed and the
10+
# result looks usable.
11+
version=$(node ./build/out/node/entry.js --version --json)
12+
echo "Got '$version' for the version"
13+
case $version in
14+
"{ codeServer":*) exit 0 ;;
15+
*) exit 1 ;;
16+
esac
17+
}
18+
19+
main "$@"

src/node/entry.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const main = async (args: Args = {}): Promise<void> => {
4949
new VscodeHttpProvider([], { base: "/vscode-embed", auth, password })
5050
)
5151

52-
ipcMain.onDispose(() => httpServer.dispose())
52+
ipcMain().onDispose(() => httpServer.dispose())
5353

5454
const serverAddress = await httpServer.listen()
5555
logger.info(`Server listening on ${serverAddress}`)
@@ -84,4 +84,18 @@ const main = async (args: Args = {}): Promise<void> => {
8484
}
8585
}
8686

87-
wrap(main)
87+
// TODO: Implement CLI parser.
88+
if (process.argv.includes("--version")) {
89+
const version = require("../../package.json").version
90+
if (process.argv.includes("--json")) {
91+
console.log({
92+
codeServer: version,
93+
vscode: require("../../lib/vscode/package.json").version,
94+
})
95+
} else {
96+
console.log(version)
97+
}
98+
process.exit(0)
99+
} else {
100+
wrap(main)
101+
}

0 commit comments

Comments
 (0)