diff --git a/ci/README.md b/ci/README.md index 0bb983ef5..19d6778e8 100644 --- a/ci/README.md +++ b/ci/README.md @@ -52,7 +52,7 @@ Make sure you have `$GITHUB_TOKEN` set and [hub](https://github.com/github/hub) Currently, we run a command to manually generate the code coverage shield. Follow these steps: -1. Run `yarn test` and make sure all the tests are passing +1. Run `yarn test:unit` and make sure all the tests are passing 2. Run `yarn badges` 3. Go into the README and change the color from `red` to `green` in this line: @@ -72,8 +72,10 @@ This directory contains scripts used for the development of code-server. - Runs formatters. - [./ci/dev/lint.sh](./dev/lint.sh) (`yarn lint`) - Runs linters. -- [./ci/dev/test.sh](./dev/test.sh) (`yarn test`) - - Runs tests. +- [./ci/dev/test-unit.sh](./dev/test-unit.sh) (`yarn test:unit`) + - Runs unit tests. +- [./ci/dev/test-e2e.sh](./dev/test-e2e.sh) (`yarn test:e2e`) + - Runs end-to-end tests. - [./ci/dev/ci.sh](./dev/ci.sh) (`yarn ci`) - Runs `yarn fmt`, `yarn lint` and `yarn test`. - [./ci/dev/watch.ts](./dev/watch.ts) (`yarn watch`) @@ -142,11 +144,13 @@ This directory contains the scripts used in CI. Helps avoid clobbering the CI configuration. - [./steps/fmt.sh](./steps/fmt.sh) - - Runs `yarn fmt` after ensuring VS Code is patched. + - Runs `yarn fmt`. - [./steps/lint.sh](./steps/lint.sh) - - Runs `yarn lint` after ensuring VS Code is patched. -- [./steps/test.sh](./steps/test.sh) - - Runs `yarn test` after ensuring VS Code is patched. + - Runs `yarn lint`. +- [./steps/test-unit.sh](./steps/test-unit.sh) + - Runs `yarn test:unit`. +- [./steps/test-e2e.sh](./steps/test-e2e.sh) + - Runs `yarn test:e2e`. - [./steps/release.sh](./steps/release.sh) - Runs the release process. - Generates the npm package at `./release`. diff --git a/ci/dev/ci.sh b/ci/dev/ci.sh index e92682864..92265a975 100755 --- a/ci/dev/ci.sh +++ b/ci/dev/ci.sh @@ -6,7 +6,7 @@ main() { yarn fmt yarn lint - yarn test + yarn test:unit } main "$@" diff --git a/ci/dev/test.sh b/ci/dev/test-e2e.sh similarity index 85% rename from ci/dev/test.sh rename to ci/dev/test-e2e.sh index 82f6ad361..d81d25cba 100755 --- a/ci/dev/test.sh +++ b/ci/dev/test-e2e.sh @@ -3,12 +3,9 @@ set -euo pipefail main() { cd "$(dirname "$0")/../.." - cd test/test-plugin - make -s out/index.js # 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" if [[ -z ${PASSWORD-} ]] || [[ -z ${CODE_SERVER_ADDRESS-} ]]; then echo "The end-to-end testing suites rely on your local environment" echo -e "\n" @@ -21,7 +18,7 @@ main() { echo -e "\n" exit 1 fi - CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" + CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" --config ./test/jest.e2e.config.ts } main "$@" diff --git a/ci/dev/test-unit.sh b/ci/dev/test-unit.sh new file mode 100755 index 000000000..f2e76ee56 --- /dev/null +++ b/ci/dev/test-unit.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -euo pipefail + +main() { + cd "$(dirname "$0")/../.." + cd test/unit/test-plugin + make -s out/index.js + # 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 "$@" +} + +main "$@" diff --git a/ci/steps/test-e2e.sh b/ci/steps/test-e2e.sh new file mode 100755 index 000000000..c1aa148a2 --- /dev/null +++ b/ci/steps/test-e2e.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euo pipefail + +main() { + cd "$(dirname "$0")/../.." + + ./release-packages/code-server*-linux-amd64/bin/code-server --home $CODE_SERVER_ADDRESS/healthz & + yarn --frozen-lockfile + yarn test:e2e +} + +main "$@" diff --git a/ci/steps/test.sh b/ci/steps/test-unit.sh similarity index 87% rename from ci/steps/test.sh rename to ci/steps/test-unit.sh index 72aa3ca2c..77fd547ce 100755 --- a/ci/steps/test.sh +++ b/ci/steps/test-unit.sh @@ -6,7 +6,7 @@ main() { yarn --frozen-lockfile - yarn test + yarn test:unit } main "$@" diff --git a/package.json b/package.json index 6c3eebdf9..50541dda5 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,9 @@ "release:standalone": "./ci/build/build-standalone-release.sh", "release:github-draft": "./ci/build/release-github-draft.sh", "release:github-assets": "./ci/build/release-github-assets.sh", - "test:e2e": "./ci/dev/test.sh", + "test:e2e": "./ci/dev/test-e2e.sh", "test:standalone-release": "./ci/build/test-standalone-release.sh", - "test:unit": "./ci/dev/test.sh", + "test:unit": "./ci/dev/test-unit.sh", "package": "./ci/build/build-packages.sh", "postinstall": "./ci/dev/postinstall.sh", "update:vscode": "./ci/dev/update-vscode.sh", @@ -126,7 +126,8 @@ "testPathIgnorePatterns": [ "node_modules", "lib", - "out" + "out", + "test/e2e" ], "collectCoverage": true, "collectCoverageFrom": [ @@ -146,8 +147,6 @@ "lines": 40 } }, - "testTimeout": 30000, - "globalSetup": "/test/globalSetup.ts", "modulePathIgnorePatterns": [ "/lib/vscode", "/release-packages", @@ -158,7 +157,7 @@ "/release-images" ], "moduleNameMapper": { - "^.+\\.(css|less)$": "/test/cssStub.ts" + "^.+\\.(css|less)$": "/test/utils/cssStub.ts" } } }