Skip to content

Commit 7c27b02

Browse files
authored
Merge branch 'main' into feature/k8s-lifecycle-hook
2 parents 9dfaf26 + 9087e0c commit 7c27b02

23 files changed

+209
-106
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
node-version: "16"
4040

4141
- name: Install helm
42-
uses: azure/setup-helm@v3.1
42+
uses: azure/setup-helm@v3.3
4343

4444
- name: Fetch dependencies from cache
4545
id: cache-yarn
@@ -156,7 +156,7 @@ jobs:
156156
uses: actions/cache@v3
157157
with:
158158
path: lib/vscode-reh-web-*
159-
key: vscode-reh-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ steps.version.outputs.version }}-${{ hashFiles('patches/*.diff') }}
159+
key: vscode-reh-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ steps.version.outputs.version }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}
160160

161161
- name: Build vscode
162162
if: steps.cache-vscode.outputs.cache-hit != 'true'
@@ -499,7 +499,7 @@ jobs:
499499
./test/node_modules/.bin/playwright install
500500
501501
- name: Run end-to-end tests
502-
run: yarn test:e2e
502+
run: yarn test:e2e --global-timeout 840000
503503

504504
- name: Upload test artifacts
505505
if: always()
@@ -523,7 +523,7 @@ jobs:
523523
fetch-depth: 0
524524

525525
- name: Run Trivy vulnerability scanner in repo mode
526-
uses: aquasecurity/trivy-action@503d3abc15463af68b817d685982721f134256a5
526+
uses: aquasecurity/trivy-action@cb606dfdb0d2b3698ace62192088ef4f5360b24f
527527
with:
528528
scan-type: "fs"
529529
scan-ref: "."

.github/workflows/trivy-docker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
uses: actions/checkout@v3
5252

5353
- name: Run Trivy vulnerability scanner in image mode
54-
uses: aquasecurity/trivy-action@503d3abc15463af68b817d685982721f134256a5
54+
uses: aquasecurity/trivy-action@cb606dfdb0d2b3698ace62192088ef4f5360b24f
5555
with:
5656
image-ref: "docker.io/codercom/code-server:latest"
5757
ignore-unfixed: true

ci/build/build-release.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ bundle_vscode() {
110110
rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions/package.json"
111111
rsync "$VSCODE_SRC_PATH/extensions/yarn.lock" "$VSCODE_OUT_PATH/extensions/yarn.lock"
112112
rsync "$VSCODE_SRC_PATH/extensions/postinstall.mjs" "$VSCODE_OUT_PATH/extensions/postinstall.mjs"
113-
114-
pushd "$VSCODE_OUT_PATH"
115-
symlink_asar
116-
popd
117113
}
118114

119115
main "$@"

ci/build/build-standalone-release.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ main() {
2727
ln -s "./bin/code-server" "$RELEASE_PATH/code-server"
2828
ln -s "./lib/node" "$RELEASE_PATH/node"
2929

30-
cd "$RELEASE_PATH"
30+
pushd "$RELEASE_PATH"
3131
yarn --production --frozen-lockfile
32+
popd
3233
}
3334

3435
main "$@"

ci/build/build-vscode.sh

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,38 @@ set -euo pipefail
66
# MINIFY controls whether a minified version of vscode is built.
77
MINIFY=${MINIFY-true}
88

9+
delete-bin-script() {
10+
rm -f "lib/vscode-reh-web-linux-x64/bin/$1"
11+
}
12+
13+
copy-bin-script() {
14+
local script="$1"
15+
local dest="lib/vscode-reh-web-linux-x64/bin/$script"
16+
cp "lib/vscode/resources/server/bin/$script" "$dest"
17+
sed -i.bak "s/@@VERSION@@/$(vscode_version)/g" "$dest"
18+
sed -i.bak "s/@@COMMIT@@/$VSCODE_DISTRO_COMMIT/g" "$dest"
19+
sed -i.bak "s/@@APPNAME@@/code-server/g" "$dest"
20+
21+
# Fix Node path on Darwin and Linux.
22+
# We do not want expansion here; this text should make it to the file as-is.
23+
# shellcheck disable=SC2016
24+
sed -i.bak 's/^ROOT=\(.*\)$/VSROOT=\1\nROOT="$(dirname "$(dirname "$VSROOT")")"/g' "$dest"
25+
sed -i.bak 's/ROOT\/out/VSROOT\/out/g' "$dest"
26+
27+
# Fix Node path on Windows.
28+
sed -i.bak 's/^set ROOT_DIR=\(.*\)$/set ROOT_DIR=%~dp0..\\..\\..\\..\r\nset VSROOT_DIR=\1/g' "$dest"
29+
sed -i.bak 's/%ROOT_DIR%\\out/%VSROOT_DIR%\\out/g' "$dest"
30+
31+
chmod +x "$dest"
32+
rm "$dest.bak"
33+
}
34+
935
main() {
1036
cd "$(dirname "${0}")/../.."
1137

1238
source ./ci/lib.sh
1339

14-
cd lib/vscode
40+
pushd lib/vscode
1541

1642
# Set the commit Code will embed into the product.json. We need to do this
1743
# since Code tries to get the commit from the `.git` directory which will fail
@@ -58,13 +84,31 @@ main() {
5884
EOF
5985
) > product.json
6086

61-
# Any platform works since we have our own packaging step (for now).
87+
# Any platform here works since we will do our own packaging. We have to do
88+
# this because we have an NPM package that could be installed on any platform.
89+
# The correct platform dependencies and scripts will be installed as part of
90+
# the post-install during `npm install` or when building a standalone release.
6291
yarn gulp "vscode-reh-web-linux-x64${MINIFY:+-min}"
6392

6493
# Reset so if you develop after building you will not be stuck with the wrong
6594
# commit (the dev client will use `oss-dev` but the dev server will still use
6695
# product.json which will have `stable-$commit`).
6796
git checkout product.json
97+
98+
popd
99+
100+
# These provide a `code-server` command in the integrated terminal to open
101+
# files in the current instance.
102+
delete-bin-script remote-cli/code-server
103+
copy-bin-script remote-cli/code-darwin.sh
104+
copy-bin-script remote-cli/code-linux.sh
105+
copy-bin-script remote-cli/code.cmd
106+
107+
# These provide a way for terminal applications to open browser windows.
108+
delete-bin-script helpers/browser.sh
109+
copy-bin-script helpers/browser-darwin.sh
110+
copy-bin-script helpers/browser-linux.sh
111+
copy-bin-script helpers/browser.cmd
68112
}
69113

70114
main "$@"

ci/build/npm-postinstall.sh

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,69 @@
11
#!/usr/bin/env sh
22
set -eu
33

4-
# Copied from arch() in ci/lib.sh.
5-
detect_arch() {
6-
case "$(uname -m)" in
7-
aarch64)
8-
echo arm64
9-
;;
10-
x86_64 | amd64)
11-
echo amd64
12-
;;
13-
*)
14-
# This will cause the download to fail, but is intentional
15-
uname -m
16-
;;
4+
# Copied from ../lib.sh.
5+
arch() {
6+
cpu="$(uname -m)"
7+
case "$cpu" in
8+
aarch64) cpu=arm64 ;;
9+
x86_64) cpu=amd64 ;;
1710
esac
11+
echo "$cpu"
1812
}
1913

20-
ARCH="${NPM_CONFIG_ARCH:-$(detect_arch)}"
14+
# Copied from ../lib.sh except we do not rename Darwin since the cloud agent
15+
# uses "darwin" in the release names and we do not need to detect Alpine.
16+
os() {
17+
osname=$(uname | tr '[:upper:]' '[:lower:]')
18+
case $osname in
19+
cygwin* | mingw*) osname="windows" ;;
20+
esac
21+
echo "$osname"
22+
}
23+
24+
# Create a symlink at $2 pointing to $1 on any platform. Anything that
25+
# currently exists at $2 will be deleted.
26+
symlink() {
27+
source="$1"
28+
dest="$2"
29+
rm -rf "$dest"
30+
case $OS in
31+
windows) mklink /J "$dest" "$source" ;;
32+
*) ln -s "$source" "$dest" ;;
33+
esac
34+
}
35+
36+
# VS Code bundles some modules into an asar which is an archive format that
37+
# works like tar. It then seems to get unpacked into node_modules.asar.
38+
#
39+
# I don't know why they do this but all the dependencies they bundle already
40+
# exist in node_modules so just symlink it. We have to do this since not only
41+
# Code itself but also extensions will look specifically in this directory for
42+
# files (like the ripgrep binary or the oniguruma wasm).
43+
symlink_asar() {
44+
symlink node_modules node_modules.asar
45+
}
46+
47+
# Make a symlink at bin/$1/$3 pointing to the platform-specific version of the
48+
# script in $2. The extension of the link will be .cmd for Windows otherwise it
49+
# will be whatever is in $4 (or no extension if $4 is not set).
50+
symlink_bin_script() {
51+
oldpwd="$(pwd)"
52+
cd "bin/$1"
53+
source="$2"
54+
dest="$3"
55+
ext="${4-}"
56+
case $OS in
57+
windows) symlink "$source.cmd" "$dest.cmd" ;;
58+
darwin | macos) symlink "$source-darwin.sh" "$dest$ext" ;;
59+
*) symlink "$source-linux.sh" "$dest$ext" ;;
60+
esac
61+
cd "$oldpwd"
62+
}
63+
64+
ARCH="${NPM_CONFIG_ARCH:-$(arch)}"
65+
OS="$(os)"
66+
2167
# This is due to an upstream issue with RHEL7/CentOS 7 comptability with node-argon2
2268
# See: https://github.com/cdr/code-server/pull/3422#pullrequestreview-677765057
2369
export npm_config_build_from_source=true
@@ -56,8 +102,6 @@ main() {
56102
;;
57103
esac
58104

59-
OS="$(uname | tr '[:upper:]' '[:lower:]')"
60-
61105
mkdir -p ./lib
62106

63107
if curl -fsSL "https://github.com/coder/cloud-agent/releases/latest/download/cloud-agent-$OS-$ARCH" -o ./lib/coder-cloud-agent; then
@@ -79,22 +123,14 @@ main() {
79123
fi
80124
}
81125

82-
# This is a copy of symlink_asar in ../lib.sh. Look there for details.
83-
symlink_asar() {
84-
rm -rf node_modules.asar
85-
if [ "${WINDIR-}" ]; then
86-
mklink /J node_modules.asar node_modules
87-
else
88-
ln -s node_modules node_modules.asar
89-
fi
90-
}
91-
92126
vscode_yarn() {
93127
echo 'Installing Code dependencies...'
94128
cd lib/vscode
95129
yarn --production --frozen-lockfile --no-default-rc
96130

97131
symlink_asar
132+
symlink_bin_script remote-cli code code-server
133+
symlink_bin_script helpers browser browser .sh
98134

99135
cd extensions
100136
yarn --production --frozen-lockfile

ci/helm-chart/values.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,25 @@ extraContainers: |
156156
# - name: DOCKER_DRIVER
157157
# value: "overlay2"
158158

159+
extraInitContainers: |
160+
# - name: customization
161+
# image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
162+
# imagePullPolicy: IfNotPresent
163+
# env:
164+
# - name: SERVICE_URL
165+
# value: https://open-vsx.org/vscode/gallery
166+
# - name: ITEM_URL
167+
# value: https://open-vsx.org/vscode/item
168+
# command:
169+
# - sh
170+
# - -c
171+
# - |
172+
# code-server --install-extension ms-python.python
173+
# code-server --install-extension golang.Go
174+
# volumeMounts:
175+
# - name: data
176+
# mountPath: /home/coder
177+
159178
## Additional code-server secret mounts
160179
extraSecretMounts: []
161180
# - name: secret-files

ci/lib.sh

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,30 @@ vscode_version() {
1818
}
1919

2020
os() {
21-
local os
22-
os=$(uname | tr '[:upper:]' '[:lower:]')
23-
if [[ $os == "linux" ]]; then
24-
# Alpine's ldd doesn't have a version flag but if you use an invalid flag
25-
# (like --version) it outputs the version to stderr and exits with 1.
26-
local ldd_output
27-
ldd_output=$(ldd --version 2>&1 || true)
28-
if echo "$ldd_output" | grep -iq musl; then
29-
os="alpine"
30-
fi
31-
elif [[ $os == "darwin" ]]; then
32-
os="macos"
33-
fi
34-
echo "$os"
21+
osname=$(uname | tr '[:upper:]' '[:lower:]')
22+
case $osname in
23+
linux)
24+
# Alpine's ldd doesn't have a version flag but if you use an invalid flag
25+
# (like --version) it outputs the version to stderr and exits with 1.
26+
# TODO: Better to check /etc/os-release; see ../install.sh.
27+
ldd_output=$(ldd --version 2>&1 || true)
28+
if echo "$ldd_output" | grep -iq musl; then
29+
osname="alpine"
30+
fi
31+
;;
32+
darwin) osname="macos" ;;
33+
cygwin* | mingw*) osname="windows" ;;
34+
esac
35+
echo "$osname"
3536
}
3637

3738
arch() {
3839
cpu="$(uname -m)"
3940
case "$cpu" in
40-
aarch64)
41-
echo arm64
42-
;;
43-
x86_64 | amd64)
44-
echo amd64
45-
;;
46-
*)
47-
echo "$cpu"
48-
;;
41+
aarch64) cpu=arm64 ;;
42+
x86_64) cpu=amd64 ;;
4943
esac
44+
echo "$cpu"
5045
}
5146

5247
# Grabs the most recent ci.yaml github workflow run that was triggered from the
@@ -104,21 +99,3 @@ export OS
10499
# RELEASE_PATH is the destination directory for the release from the root.
105100
# Defaults to release
106101
RELEASE_PATH="${RELEASE_PATH-release}"
107-
108-
# VS Code bundles some modules into an asar which is an archive format that
109-
# works like tar. It then seems to get unpacked into node_modules.asar.
110-
#
111-
# I don't know why they do this but all the dependencies they bundle already
112-
# exist in node_modules so just symlink it. We have to do this since not only VS
113-
# Code itself but also extensions will look specifically in this directory for
114-
# files (like the ripgrep binary or the oniguruma wasm).
115-
symlink_asar() {
116-
rm -rf node_modules.asar
117-
if [ "${WINDIR-}" ]; then
118-
# mklink takes the link name first.
119-
mklink /J node_modules.asar node_modules
120-
else
121-
# ln takes the link name second.
122-
ln -s node_modules node_modules.asar
123-
fi
124-
}

ci/steps/publish-npm.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ main() {
8181
# https://github.com/actions/upload-artifact/issues/38
8282
tar -xzf release-npm-package/package.tar.gz
8383

84-
# Ignore symlink when publishing npm package
85-
# See: https://github.com/coder/code-server/pull/3935
86-
echo "node_modules.asar" > release/.npmignore
87-
8884
# We use this to set the name of the package in the
8985
# package.json
9086
PACKAGE_NAME="code-server"

docs/assets/images/icons/collab.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)