Skip to content

Commit 862c977

Browse files
authored
Make installer work on any os/arch and add installer tests (#3712)
2 parents 723a274 + 4ffecd6 commit 862c977

File tree

9 files changed

+420
-135
lines changed

9 files changed

+420
-135
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: ci
1+
name: Build
22

33
on:
44
push:
@@ -16,7 +16,7 @@ on:
1616

1717
jobs:
1818
prebuild:
19-
name: Pre-Build checks
19+
name: Pre-build checks
2020
runs-on: ubuntu-latest
2121
timeout-minutes: 5
2222
env:

.github/workflows/installer.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Installer integration
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "installer.sh"
9+
pull_request:
10+
branches:
11+
- main
12+
13+
jobs:
14+
ubuntu:
15+
name: Test installer on Ubuntu
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repo
19+
uses: actions/checkout@v2
20+
21+
- name: Install code-server
22+
run: ./install.sh
23+
24+
- name: Test code-server
25+
run: yarn test:standalone-release code-server
26+
27+
alpine:
28+
name: Test installer on Alpine
29+
runs-on: ubuntu-latest
30+
container: "alpine:3.14"
31+
steps:
32+
- name: Checkout repo
33+
uses: actions/checkout@v2
34+
35+
- name: Install curl
36+
run: apk add curl
37+
38+
- name: Add user
39+
run: adduser coder --disabled-password
40+
41+
# Standalone should work without root.
42+
- name: Test standalone to a non-existent prefix
43+
run: su coder -c "./install.sh --method standalone --prefix /tmp/does/not/yet/exist"
44+
45+
macos:
46+
name: Test installer on macOS
47+
runs-on: macos-latest
48+
49+
steps:
50+
- name: Checkout repo
51+
uses: actions/checkout@v2
52+
53+
- name: Install code-server
54+
run: ./install.sh
55+
56+
- name: Test code-server
57+
run: yarn test:standalone-release code-server

.github/workflows/scripts.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Script unit tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "installer.sh"
9+
pull_request:
10+
branches:
11+
- main
12+
13+
jobs:
14+
test:
15+
name: Run script unit tests
16+
runs-on: ubuntu-latest
17+
# This runs on Alpine to make sure we're testing with actual sh.
18+
container: "alpine:3.14"
19+
steps:
20+
- name: Checkout repo
21+
uses: actions/checkout@v2
22+
23+
- name: Install test utilities
24+
run: apk add bats checkbashisms
25+
26+
- name: Check Bashisms
27+
run: checkbashisms ./install.sh
28+
29+
- name: Run script unit tests
30+
run: ./ci/dev/test-scripts.sh

ci/build/test-standalone-release.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
# Makes sure the release works.
4+
# Make sure a code-server release works. You can pass in the path otherwise it
5+
# will use release-standalone in the current directory.
6+
#
57
# This is to make sure we don't have Node version errors or any other
68
# compilation-related errors.
79
main() {
@@ -10,12 +12,14 @@ main() {
1012
local EXTENSIONS_DIR
1113
EXTENSIONS_DIR="$(mktemp -d)"
1214

13-
echo "Testing standalone release."
15+
local path=${1:-./release-standalone/bin/code-server}
1416

15-
# Note: using a basic theme extension because it doesn't update often and is more reliable for testing
16-
./release-standalone/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --install-extension wesbos.theme-cobalt2
17+
echo "Testing standalone release in $path."
18+
19+
# NOTE: using a basic theme extension because it doesn't update often and is more reliable for testing
20+
"$path" --extensions-dir "$EXTENSIONS_DIR" --install-extension wesbos.theme-cobalt2
1721
local installed_extensions
18-
installed_extensions="$(./release-standalone/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --list-extensions 2>&1)"
22+
installed_extensions="$("$path" --extensions-dir "$EXTENSIONS_DIR" --list-extensions 2>&1)"
1923
# We use grep as wesbos.theme-cobalt2 may have dependency extensions that change.
2024
if ! echo "$installed_extensions" | grep -q "wesbos.theme-cobalt2"; then
2125
echo "Unexpected output from listing extensions:"

ci/dev/test-scripts.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
main() {
5+
cd "$(dirname "$0")/../.."
6+
bats ./test/scripts
7+
}
8+
9+
main "$@"

docs/CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Here is what is needed:
4444
- Get this by running `apt-get install -y build-essential`
4545
- `rsync` and `unzip`
4646
- Used for code-server releases
47+
- `bats`
48+
- Used to run script unit tests
4749

4850
## Creating pull requests
4951

0 commit comments

Comments
 (0)