Skip to content

Commit b30aefc

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

File tree

7 files changed

+174
-86
lines changed

7 files changed

+174
-86
lines changed

.drone.yml

+90-53
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,30 @@ 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: codercom/nbin:centos
23+
commands:
24+
- yum install -y openssl
25+
- yarn test
1826

1927
- name: build
2028
image: codercom/nbin:centos
2129
commands:
2230
- yum install -y libxkbfile-devel libsecret-devel
2331
- . /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'
32+
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
2533

2634
- name: cache:package
2735
image: node:12
@@ -40,10 +48,10 @@ steps:
4048
when:
4149
event: push
4250

43-
- name: test
44-
image: node:12
51+
- name: test:build
52+
image: codercom/nbin:centos
4553
commands:
46-
- yarn test
54+
- yarn test:build
4755

4856
- name: publish:github
4957
image: plugins/github-release
@@ -90,21 +98,28 @@ platform:
9098
arch: amd64
9199

92100
steps:
93-
- name: submodules
94-
image: alpine/git
95-
commands:
96-
- git submodule update --init
97-
98101
- name: cache:restore
99102
image: node:12-alpine
100103
commands:
104+
- apk add libxkbfile-dev libsecret-dev build-base git bash python
101105
- ./scripts/cacher.sh
102106

107+
- name: lint
108+
image: node:12-alpine
109+
commands:
110+
- yarn lint
111+
112+
- name: test
113+
image: node:12-alpine
114+
commands:
115+
- apk add openssl
116+
- yarn test
117+
103118
- name: build
104119
image: node:12-alpine
105120
commands:
106121
- 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'
122+
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
108123

109124
- name: cache:package
110125
image: node:12-alpine
@@ -123,10 +138,10 @@ steps:
123138
when:
124139
event: push
125140

126-
- name: test
141+
- name: test:build
127142
image: node:12-alpine
128143
commands:
129-
- yarn test
144+
- yarn test:build
130145

131146
- name: publish:github
132147
image: plugins/github-release
@@ -159,22 +174,27 @@ platform:
159174
arch: arm64
160175

161176
steps:
162-
- name: submodules
163-
image: alpine
164-
commands:
165-
- apk add git
166-
- git submodule update --init
167-
168177
- name: cache:restore
169178
image: node:12
170179
commands:
180+
- apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
171181
- ./scripts/cacher.sh
172182

183+
- name: lint
184+
image: node:12
185+
commands:
186+
- yarn lint
187+
188+
- name: test
189+
image: node:12
190+
commands:
191+
- yarn test
192+
173193
- name: build
174194
image: node:12
175195
commands:
176196
- 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'
197+
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
178198

179199
- name: cache:package
180200
image: node:12
@@ -193,10 +213,10 @@ steps:
193213
when:
194214
event: push
195215

196-
- name: test
216+
- name: test:build
197217
image: node:12
198218
commands:
199-
- yarn test
219+
- yarn test:build
200220

201221
- name: publish:github
202222
image: plugins/github-release
@@ -243,22 +263,28 @@ platform:
243263
arch: arm64
244264

245265
steps:
246-
- name: submodules
247-
image: alpine
248-
commands:
249-
- apk add git
250-
- git submodule update --init
251-
252266
- name: cache:restore
253267
image: node:12-alpine
254268
commands:
269+
- apk add libxkbfile-dev libsecret-dev build-base git bash python
255270
- ./scripts/cacher.sh
256271

272+
- name: lint
273+
image: node:12-alpine
274+
commands:
275+
- yarn lint
276+
277+
- name: test
278+
image: node:12-alpine
279+
commands:
280+
- apk add openssl
281+
- yarn test
282+
257283
- name: build
258284
image: node:12-alpine
259285
commands:
260286
- 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'
287+
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
262288

263289
- name: cache:package
264290
image: node:12-alpine
@@ -277,10 +303,10 @@ steps:
277303
when:
278304
event: push
279305

280-
- name: test
306+
- name: test:build
281307
image: node:12-alpine
282308
commands:
283-
- yarn test
309+
- yarn test:build
284310

285311
- name: publish:github
286312
image: plugins/github-release
@@ -313,22 +339,27 @@ platform:
313339
arch: arm
314340

315341
steps:
316-
- name: submodules
317-
image: alpine
318-
commands:
319-
- apk add git
320-
- git submodule update --init
321-
322342
- name: cache:restore
323343
image: node:12
324344
commands:
345+
- apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
325346
- ./scripts/cacher.sh
326347

348+
- name: lint
349+
image: node:12
350+
commands:
351+
- yarn lint
352+
353+
- name: test
354+
image: node:12
355+
commands:
356+
- yarn test
357+
327358
- name: build
328359
image: node:12
329360
commands:
330361
- 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'
362+
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
332363

333364
- name: cache:package
334365
image: node:12
@@ -347,11 +378,11 @@ steps:
347378
when:
348379
event: push
349380

350-
- name: test
381+
- name: test:build
351382
image: node:12
352383
failure: ignore
353384
commands:
354-
- yarn test
385+
- yarn test:build
355386

356387
# - name: publish:github
357388
# image: plugins/github-release
@@ -388,22 +419,28 @@ platform:
388419
arch: arm
389420

390421
steps:
391-
- name: submodules
392-
image: alpine
393-
commands:
394-
- apk add git
395-
- git submodule update --init
396-
397422
- name: cache:restore
398423
image: node:12-alpine
399424
commands:
425+
- apk add libxkbfile-dev libsecret-dev build-base git bash python
400426
- ./scripts/cacher.sh
401427

428+
- name: lint
429+
image: node:12-alpine
430+
commands:
431+
- yarn lint
432+
433+
- name: test
434+
image: node:12-alpine
435+
commands:
436+
- apk add openssl
437+
- yarn test
438+
402439
- name: build
403440
image: node:12-alpine
404441
commands:
405442
- 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'
443+
- timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing to preserve cache for the next run'
407444

408445
- name: cache:package
409446
image: node:12-alpine
@@ -422,11 +459,11 @@ steps:
422459
when:
423460
event: push
424461

425-
- name: test
462+
- name: test:build
426463
image: node:12-alpine
427464
failure: ignore
428465
commands:
429-
- yarn test
466+
- yarn test:build
430467

431468
# - name: publish:github
432469
# 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)