Skip to content

Commit

Permalink
Add vscode via vendor package.
Browse files Browse the repository at this point in the history
- Use yarn for vscode vendoring.
- Grab hash from package.
  • Loading branch information
GirlBossRush authored and Teffen Ellis committed Sep 15, 2021
1 parent 28ba59a commit f885b29
Show file tree
Hide file tree
Showing 32 changed files with 1,546 additions and 253 deletions.
3 changes: 0 additions & 3 deletions .github/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
name: "code-server CodeQL config"

paths-ignore:
- lib/vscode
16 changes: 8 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,26 @@ jobs:
- name: Build code-server
run: yarn build

# Parse the hash of the latest commit inside lib/vscode
# Parse the hash of the latest commit inside vendor/modules/code-oss-dev
# use this to avoid rebuilding it if nothing changed
# How it works: the `git log` command fetches the hash of the last commit
# that changed a file inside `lib/vscode`. If a commit changes any file in there,
# that changed a file inside `vendor/modules/code-oss-dev`. If a commit changes any file in there,
# the hash returned will change, and we rebuild vscode. If the hash did not change,
# (for example, a change to `src/` or `docs/`), we reuse the same build as last time.
# This saves a lot of time in CI, as compiling VSCode can take anywhere from 5-10 minutes.
- name: Get latest lib/vscode rev
- name: Get latest vendor/modules/code-oss-dev rev
id: vscode-rev
run: echo "::set-output name=rev::$(git log -1 --format='%H' ./lib/vscode)"
run: echo "::set-output name=rev::$(jq -r '.devDependencies["code-oss-dev"]' vendor/package.json | sed -r 's|.*#(.*)$|\1|')"

- name: Attempt to fetch vscode build from cache
id: cache-vscode
uses: actions/cache@v2
with:
path: |
lib/vscode/.build
lib/vscode/out-build
lib/vscode/out-vscode
lib/vscode/out-vscode-min
vendor/modules/code-oss-dev/.build
vendor/modules/code-oss-dev/out-build
vendor/modules/code-oss-dev/out-vscode
vendor/modules/code-oss-dev/out-vscode-min
key: vscode-build-${{ steps.vscode-rev.outputs.rev }}

- name: Build vscode
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ release-packages/
release-gcp/
release-images/
node_modules
/lib/vscode/node_modules.asar
vendor/modules
node-*
/plugins
/lib/coder-cloud-agent
Expand Down
4 changes: 2 additions & 2 deletions .tours/contributing.tour
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@
"description": "Static images and the manifest live here in `src/browser/media` (see the explorer)."
},
{
"directory": "lib/vscode",
"directory": "vendor/modules/code-oss-dev",
"line": 1,
"description": "code-server makes use of VS Code's frontend web/remote support. Most of the modifications implement the remote server since that portion of the code is closed source and not released with VS Code.\n\nWe also have a few bug fixes and have added some features (like client-side extensions). See [https://github.com/cdr/code-server/blob/master/docs/CONTRIBUTING.md#modifications-to-vs-code](https://github.com/cdr/code-server/blob/master/docs/CONTRIBUTING.md#modifications-to-vs-code) for a list.\n\nWe make an effort to keep the modifications as few as possible."
}
]
}
}
7 changes: 4 additions & 3 deletions ci/build/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ KEEP_MODULES="${KEEP_MODULES-0}"

main() {
cd "$(dirname "${0}")/../.."

source ./ci/lib.sh

VSCODE_SRC_PATH="lib/vscode"
VSCODE_OUT_PATH="$RELEASE_PATH/lib/vscode"
VSCODE_SRC_PATH="vendor/modules/code-oss-dev"
VSCODE_OUT_PATH="$RELEASE_PATH/vendor/modules/code-oss-dev"

mkdir -p "$RELEASE_PATH"

Expand All @@ -24,7 +25,7 @@ main() {

rsync ./docs/README.md "$RELEASE_PATH"
rsync LICENSE.txt "$RELEASE_PATH"
rsync ./lib/vscode/ThirdPartyNotices.txt "$RELEASE_PATH"
rsync ./vendor/modules/code-oss-dev/ThirdPartyNotices.txt "$RELEASE_PATH"
}

bundle_code_server() {
Expand Down
4 changes: 3 additions & 1 deletion ci/build/build-standalone-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export npm_config_build_from_source=true

main() {
cd "$(dirname "${0}")/../.."

source ./ci/lib.sh

rsync "$RELEASE_PATH/" "$RELEASE_PATH-standalone"
Expand All @@ -19,6 +20,7 @@ main() {
node_path="$(yarn -s node <<< 'console.info(process.execPath)')"

mkdir -p "$RELEASE_PATH/bin"
mkdir -p "$RELEASE_PATH/lib"
rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server"
rsync "$node_path" "$RELEASE_PATH/lib/node"

Expand All @@ -32,7 +34,7 @@ main() {
# leaves a few stray symlinks. Clean them up so nfpm does not fail.
# Remove this line when its no longer needed.

rm -fr "$RELEASE_PATH/lib/vscode/extensions/node_modules/.bin"
rm -fr "$RELEASE_PATH/vendor/modules/code-oss-dev/extensions/node_modules/.bin"
}

main "$@"
5 changes: 3 additions & 2 deletions ci/build/build-vscode.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail

# Builds vscode into lib/vscode/out-vscode.
# Builds vscode into vendor/modules/code-oss-dev/out-vscode.

# MINIFY controls whether a minified version of vscode is built.
MINIFY=${MINIFY-true}

main() {
cd "$(dirname "${0}")/../.."
cd lib/vscode

cd vendor/modules/code-oss-dev

yarn gulp compile-build compile-extensions-build compile-extension-media
yarn gulp optimize --gulpfile ./coder.js
Expand Down
4 changes: 0 additions & 4 deletions ci/build/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ main() {
source ./ci/lib.sh

git clean -Xffd

pushd lib/vscode
git clean -xffd
popd
}

main "$@"
4 changes: 3 additions & 1 deletion ci/build/npm-postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ symlink_asar() {
}

vscode_yarn() {
cd lib/vscode
echo 'Installing vendor dependencies...'
cd vendor/modules/code-oss-dev
yarn --production --frozen-lockfile

symlink_asar

cd extensions
yarn --production --frozen-lockfile

for ext in */; do
ext="${ext%/}"
echo "extensions/$ext: installing dependencies"
Expand Down
3 changes: 2 additions & 1 deletion ci/dev/fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ main() {
"*.sh"
)
prettier --write --loglevel=warn $(
git ls-files "${prettierExts[@]}" | grep -v "lib/vscode" | grep -v 'helm-chart'
git ls-files "${prettierExts[@]}" | grep -v "lib/vscode" | grep -v "vendor/modules/code-oss-dev" | grep -v 'helm-chart'
)

doctoc --title '# FAQ' docs/FAQ.md > /dev/null
Expand All @@ -32,6 +32,7 @@ main() {
doctoc --title '# iPad' docs/ipad.md > /dev/null
doctoc --title '# Termux' docs/termux.md > /dev/null

# TODO: replace with a method that generates fewer false positives.
if [[ ${CI-} && $(git ls-files --other --modified --exclude-standard) ]]; then
echo "Files need generation or are formatted incorrectly:"
git -c color.ui=always status | grep --color=no '\[31m'
Expand Down
9 changes: 3 additions & 6 deletions ci/dev/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ set -euo pipefail
main() {
cd "$(dirname "$0")/../.."

eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js" | grep -v "lib/vscode")
stylelint $(git ls-files "*.css" | grep -v "lib/vscode")
eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js" | grep -v "vendor/modules/code-oss-dev" | grep -v "lib/vscode")
stylelint $(git ls-files "*.css" | grep -v "vendor/modules/code-oss-dev" | grep -v "lib/vscode")
tsc --noEmit --skipLibCheck
shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090,SC2002 $(git ls-files "*.sh" | grep -v "lib/vscode")
shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090,SC2002 $(git ls-files "*.sh" | grep -v "vendor/modules/code-oss-dev" | grep -v "lib/vscode")
if command -v helm && helm kubeval --help > /dev/null; then
helm kubeval ci/helm-chart
fi

cd lib/vscode
# Run this periodically in vanilla VS code to make sure we don't add any more warnings.
yarn -s eslint --max-warnings=3
cd "$OLDPWD"
}

Expand Down
23 changes: 17 additions & 6 deletions ci/dev/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@ set -euo pipefail

main() {
cd "$(dirname "$0")/../.."
source ./ci/lib.sh

# This installs the dependencies needed for testing
echo 'Installing code-server test dependencies...'

cd test
yarn
yarn install
cd ..

cd lib/vscode
yarn ${CI+--frozen-lockfile}
cd vendor
echo 'Installing vendor dependencies...'

# * We install in 'modules' instead of 'node_modules' because VS Code's extensions
# use a webpack config which cannot differentiate between its own node_modules
# and itself being in a directory with the same name.
#
# * We ignore scripts because NPM/Yarn's default behavior is to assume that
# devDependencies are not needed, and that even git repo based packages are
# assumed to be compiled. Because the default behavior for VS Code's `postinstall`
# assumes we're also compiled, this needs to be ignored.
yarn install --modules-folder modules --ignore-scripts --frozen-lockfile

symlink_asar
# Finally, run the vendor `postinstall`
yarn run postinstall
}

main "$@"
3 changes: 2 additions & 1 deletion ci/dev/test-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -euo pipefail

main() {
cd "$(dirname "$0")/../.."

source ./ci/lib.sh

local dir="$PWD"
Expand All @@ -24,7 +25,7 @@ main() {
exit 1
fi

if [[ ! -d $dir/lib/vscode/out ]]; then
if [[ ! -d $dir/vendor/modules/code-oss-dev/out ]]; then
echo >&2 "No VS Code build detected"
echo >&2 "You can build it with 'yarn build:vscode' or 'yarn watch'"
exit 1
Expand Down
133 changes: 0 additions & 133 deletions ci/dev/update-vscode.sh

This file was deleted.

2 changes: 1 addition & 1 deletion ci/dev/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function main(): Promise<void> {

class Watcher {
private readonly rootPath = path.resolve(__dirname, "../..")
private readonly vscodeSourcePath = path.join(this.rootPath, "lib/vscode")
private readonly vscodeSourcePath = path.join(this.rootPath, "vendor/modules/code-oss-dev")

private static log(message: string, skipNewline = false): void {
process.stdout.write(message)
Expand Down
2 changes: 1 addition & 1 deletion ci/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pkg_json_version() {
}

vscode_version() {
jq -r .version lib/vscode/package.json
jq -r .version vendor/modules/code-oss-dev/package.json
}

os() {
Expand Down
Loading

0 comments on commit f885b29

Please sign in to comment.