diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 497203af..6ba0793f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,8 +19,6 @@ jobs: name: Pre-build checks runs-on: ubuntu-latest timeout-minutes: 15 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} steps: - name: Checkout repo uses: actions/checkout@v2 @@ -54,14 +52,6 @@ jobs: run: yarn lint if: success() - - name: Run code-server unit tests - run: yarn test:unit - if: success() - - - name: Upload coverage report to Codecov - run: yarn coverage - if: success() - audit-ci: name: Run audit-ci needs: prebuild @@ -98,6 +88,8 @@ jobs: needs: prebuild runs-on: ubuntu-latest timeout-minutes: 30 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} steps: - uses: actions/checkout@v2 with: @@ -146,14 +138,25 @@ jobs: path: | 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 }} + vendor/modules/code-oss-dev/out-vscode-server + vendor/modules/code-oss-dev/out-vscode-server-min + key: vscode-server-build-${{ steps.vscode-rev.outputs.rev }} - name: Build vscode if: steps.cache-vscode.outputs.cache-hit != 'true' run: yarn build:vscode + # Our code imports code from VS Code's `out` directory meaning VS Code + # must be built before running these tests. + # TODO: Move to its own step? + - name: Run code-server unit tests + run: yarn test:unit + if: success() + + - name: Upload coverage report to Codecov + run: yarn coverage + if: success() + # The release package does not contain any native modules # and is neutral to architecture/os/libc version. - name: Create release package diff --git a/ci/build/build-code-server.sh b/ci/build/build-code-server.sh index b3b1967a..2b834f96 100755 --- a/ci/build/build-code-server.sh +++ b/ci/build/build-code-server.sh @@ -20,6 +20,8 @@ main() { source ./ci/lib.sh OS="$(uname | tr '[:upper:]' '[:lower:]')" + mkdir -p ./lib + if ! [ -f ./lib/coder-cloud-agent ]; then echo "Downloading the cloud agent..." diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index f7b7df26..263b8c3b 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -68,7 +68,7 @@ EOF bundle_vscode() { mkdir -p "$VSCODE_OUT_PATH" rsync "$VSCODE_SRC_PATH/yarn.lock" "$VSCODE_OUT_PATH" - rsync "$VSCODE_SRC_PATH/out-vscode${MINIFY:+-min}/" "$VSCODE_OUT_PATH/out" + rsync "$VSCODE_SRC_PATH/out-vscode-server${MINIFY:+-min}/" "$VSCODE_OUT_PATH/out" rsync "$VSCODE_SRC_PATH/.build/extensions/" "$VSCODE_OUT_PATH/extensions" if [ "$KEEP_MODULES" = 0 ]; then @@ -80,9 +80,8 @@ bundle_vscode() { rsync "$VSCODE_SRC_PATH/extensions/yarn.lock" "$VSCODE_OUT_PATH/extensions" rsync "$VSCODE_SRC_PATH/extensions/postinstall.js" "$VSCODE_OUT_PATH/extensions" - mkdir -p "$VSCODE_OUT_PATH/resources/"{linux,web} - rsync "$VSCODE_SRC_PATH/resources/linux/" "$VSCODE_OUT_PATH/resources/linux/" - rsync "$VSCODE_SRC_PATH/resources/web/" "$VSCODE_OUT_PATH/resources/web/" + mkdir -p "$VSCODE_OUT_PATH/resources/" + rsync "$VSCODE_SRC_PATH/resources/" "$VSCODE_OUT_PATH/resources/" # Add the commit and date and enable telemetry. This just makes telemetry # available; telemetry can still be disabled by flag or setting. @@ -91,6 +90,7 @@ bundle_vscode() { { "enableTelemetry": true, "commit": "$(git rev-parse HEAD)", + "quality": "stable", "date": $(jq -n 'now | todate') } EOF diff --git a/ci/build/build-vscode.sh b/ci/build/build-vscode.sh index 91e83e7f..59bd6759 100755 --- a/ci/build/build-vscode.sh +++ b/ci/build/build-vscode.sh @@ -11,13 +11,9 @@ main() { cd vendor/modules/code-oss-dev - yarn gulp compile-build compile-extensions-build compile-extension-media compile-web - - yarn gulp optimize --gulpfile ./coder.js - - if [[ $MINIFY ]]; then - yarn gulp minify --gulpfile ./coder.js - fi + # extensions-ci compiles extensions and includes their media. + # compile-web compiles web extensions. TODO: Unsure if used. + yarn gulp extensions-ci compile-web "vscode-server${MINIFY:+-min}" } main "$@" diff --git a/ci/build/npm-postinstall.sh b/ci/build/npm-postinstall.sh index 38412ee7..99b897ec 100755 --- a/ci/build/npm-postinstall.sh +++ b/ci/build/npm-postinstall.sh @@ -57,6 +57,9 @@ main() { esac OS="$(uname | tr '[:upper:]' '[:lower:]')" + + mkdir -p ./lib + if curl -fsSL "https://github.com/cdr/cloud-agent/releases/latest/download/cloud-agent-$OS-$ARCH" -o ./lib/coder-cloud-agent; then chmod +x ./lib/coder-cloud-agent else diff --git a/ci/dev/test-e2e.sh b/ci/dev/test-e2e.sh index f42deb83..bca78c55 100755 --- a/ci/dev/test-e2e.sh +++ b/ci/dev/test-e2e.sh @@ -1,6 +1,13 @@ #!/usr/bin/env bash set -euo pipefail +help() { + echo >&2 " You can build with 'yarn watch' or you can build a release" + echo >&2 " For example: 'yarn build && yarn build:vscode && KEEP_MODULES=1 yarn release'" + echo >&2 " Then 'CODE_SERVER_TEST_ENTRY=./release yarn test:e2e'" + echo >&2 " You can manually run that release with 'node ./release'" +} + main() { cd "$(dirname "$0")/../.." @@ -21,13 +28,13 @@ main() { # wrong (native modules version issues, incomplete build, etc). if [[ ! -d $dir/out ]]; then echo >&2 "No code-server build detected" - echo >&2 "You can build it with 'yarn build' or 'yarn watch'" + help exit 1 fi 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'" + help exit 1 fi diff --git a/ci/dev/test-unit.sh b/ci/dev/test-unit.sh index 65fa9400..f82413b9 100755 --- a/ci/dev/test-unit.sh +++ b/ci/dev/test-unit.sh @@ -3,12 +3,26 @@ set -euo pipefail main() { cd "$(dirname "$0")/../.." - cd test/unit/node/test-plugin + + source ./ci/lib.sh + + pushd test/unit/node/test-plugin make -s out/index.js + popd + + # Our code imports from `out` in order to work during development but if you + # have only built for production you will have not have this directory. In + # that case symlink `out` to a production build directory. + local vscode="vendor/modules/code-oss-dev" + local link="$vscode/out" + local target="out-build" + if [[ ! -e $link ]] && [[ -d $vscode/$target ]]; then + ln -s "$target" "$link" + fi + # We must keep jest in a sub-directory. See ../../test/package.json for more # information. We must also run it from the root otherwise coverage will not # include our source files. - cd "$OLDPWD" CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" } diff --git a/package.json b/package.json index 1b0c1277..4d52857d 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "release:prep": "./ci/build/release-prep.sh", "test:e2e": "./ci/dev/test-e2e.sh", "test:standalone-release": "./ci/build/test-standalone-release.sh", - "test:unit": "./ci/dev/test-unit.sh", + "test:unit": "./ci/dev/test-unit.sh --forceExit --detectOpenHandles", "test:scripts": "./ci/dev/test-scripts.sh", "package": "./ci/build/build-packages.sh", "postinstall": "./ci/dev/postinstall.sh", diff --git a/src/browser/pages/login.html b/src/browser/pages/login.html index f8837c8f..75aa86dc 100644 --- a/src/browser/pages/login.html +++ b/src/browser/pages/login.html @@ -30,6 +30,7 @@