Skip to content

Commit 6c87b54

Browse files
committed
refactor: move unit tests to separate job
1 parent 13286bf commit 6c87b54

File tree

3 files changed

+50
-45
lines changed

3 files changed

+50
-45
lines changed

.github/workflows/build.yaml

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,55 @@ jobs:
182182
if: failure()
183183
uses: andymckay/[email protected]
184184

185+
test-unit:
186+
name: Run unit tests
187+
runs-on: ubuntu-latest
188+
timeout-minutes: 5
189+
steps:
190+
- name: Checkout repo
191+
uses: actions/checkout@v3
192+
193+
- name: Get changed files
194+
id: changed-files
195+
uses: tj-actions/[email protected]
196+
with:
197+
files: |
198+
src/**
199+
200+
- name: Install Node.js v16
201+
if: steps.changed-files.outputs.any_changed == 'true'
202+
uses: actions/setup-node@v3
203+
with:
204+
node-version: "16"
205+
206+
- name: Fetch dependencies from cache
207+
if: steps.changed-files.outputs.any_changed == 'true'
208+
id: cache-yarn
209+
uses: actions/cache@v3
210+
with:
211+
path: "node_modules"
212+
key: yarn-build-${{ hashFiles('yarn.lock') }}
213+
restore-keys: |
214+
yarn-build-
215+
216+
- name: Install dependencies
217+
if: steps.changed-files.outputs.any_changed == 'true' && steps.cache-yarn.outputs.cache-hit != 'true'
218+
run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile
219+
220+
- name: Run unit tests
221+
if: steps.changed-files.outputs.any_changed == 'true'
222+
run: yarn test:unit
223+
224+
- name: Upload coverage report to Codecov
225+
uses: codecov/codecov-action@v3
226+
with:
227+
token: ${{ secrets.CODECOV_TOKEN }}
228+
if: success()
229+
230+
- name: Fail workflow
231+
if: failure()
232+
uses: andymckay/[email protected]
233+
185234
typecheck:
186235
name: Check TypeScript types
187236
runs-on: ubuntu-latest
@@ -292,19 +341,6 @@ jobs:
292341
if: steps.cache-vscode.outputs.cache-hit != 'true'
293342
run: yarn build:vscode
294343

295-
# Our code imports code from VS Code's `out` directory meaning VS Code
296-
# must be built before running these tests.
297-
# TODO: Move to its own step?
298-
- name: Run code-server unit tests
299-
run: yarn test:unit
300-
if: success()
301-
302-
- name: Upload coverage report to Codecov
303-
uses: codecov/codecov-action@v3
304-
with:
305-
token: ${{ secrets.CODECOV_TOKEN }}
306-
if: success()
307-
308344
# The release package does not contain any native modules
309345
# and is neutral to architecture/os/libc version.
310346
- name: Create release package

ci/dev/test-unit.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"release:prep": "./ci/build/release-prep.sh",
1818
"test:e2e": "VSCODE_IPC_HOOK_CLI= ./ci/dev/test-e2e.sh",
1919
"test:e2e:proxy": "USE_PROXY=1 ./ci/dev/test-e2e.sh",
20-
"test:unit": "./ci/dev/test-unit.sh --forceExit --detectOpenHandles",
20+
"test:unit": "CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest --testRegex './test/unit/.*ts' --forceExit --detectOpenHandles",
2121
"test:integration": "./ci/dev/test-integration.sh",
2222
"test:scripts": "./ci/dev/test-scripts.sh",
2323
"package": "./ci/build/build-packages.sh",

0 commit comments

Comments
 (0)