Skip to content

Commit 05e5c7e

Browse files
committed
Node CI tests on Windows
1 parent 1bf9883 commit 05e5c7e

File tree

3 files changed

+111
-56
lines changed

3 files changed

+111
-56
lines changed

.github/workflows/build.yml

Lines changed: 71 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ env:
2626

2727
jobs:
2828
job_install_deps:
29-
name: Install Dependencies
29+
name: Install Dependencies - Linux
3030
runs-on: ubuntu-latest
3131
timeout-minutes: 15
3232
steps:
@@ -43,17 +43,43 @@ jobs:
4343
uses: actions/cache@v2
4444
id: cache_dependencies
4545
with:
46-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
46+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
4747
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
4848
- name: Install dependencies
4949
if: steps.cache_dependencies.outputs.cache-hit == ''
5050
run: yarn install --ignore-engines
5151
outputs:
5252
dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }}
5353

54+
job_install_deps_windows:
55+
name: Install Dependencies - Windows
56+
runs-on: windows-latest
57+
timeout-minutes: 15
58+
steps:
59+
- name: Check out current commit (${{ github.sha }})
60+
uses: actions/checkout@v2
61+
- name: Set up Node
62+
uses: actions/setup-node@v1
63+
# we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed,
64+
# so no need to reinstall them
65+
- name: Compute dependency cache key
66+
id: compute_lockfile_hash
67+
run: echo "::set-output name=hash::${{ hashFiles('yarn.lock') }}"
68+
- name: Check dependency cache
69+
uses: actions/cache@v2
70+
id: cache_dependencies
71+
with:
72+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-windows
73+
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
74+
- name: Install dependencies
75+
if: steps.cache_dependencies.outputs.cache-hit == ''
76+
run: yarn install --ignore-engines
77+
outputs:
78+
dependency_cache_key_windows: ${{ steps.compute_lockfile_hash.outputs.hash }}
79+
5480
job_build:
5581
name: Build
56-
needs: job_install_deps
82+
needs: [job_install_deps, job_install_deps_windows]
5783
runs-on: ubuntu-latest
5884
timeout-minutes: 15
5985
steps:
@@ -64,7 +90,7 @@ jobs:
6490
- name: Check dependency cache
6591
uses: actions/cache@v2
6692
with:
67-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
93+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
6894
key: ${{ needs.job_install_deps.outputs.dependency_cache_key }}
6995
- name: Check build cache
7096
uses: actions/cache@v2
@@ -91,6 +117,7 @@ jobs:
91117
# this needs to be passed on, because the `needs` context only looks at direct ancestors (so steps which depend on
92118
# `job_build` can't see `job_install_deps` and what it returned)
93119
dependency_cache_key: ${{ needs.job_install_deps.outputs.dependency_cache_key }}
120+
dependency_cache_key_windows: ${{ needs.job_install_deps_windows.outputs.dependency_cache_key_windows }}
94121

95122
job_size_check:
96123
name: Size Check
@@ -107,7 +134,7 @@ jobs:
107134
- name: Check dependency cache
108135
uses: actions/cache@v2
109136
with:
110-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
137+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
111138
key: ${{ needs.job_build.outputs.dependency_cache_key }}
112139
- name: Check build cache
113140
uses: actions/cache@v2
@@ -137,7 +164,7 @@ jobs:
137164
- name: Check dependency cache
138165
uses: actions/cache@v2
139166
with:
140-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
167+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
141168
key: ${{ needs.job_build.outputs.dependency_cache_key }}
142169
- name: Check build cache
143170
uses: actions/cache@v2
@@ -160,7 +187,7 @@ jobs:
160187
- name: Check dependency cache
161188
uses: actions/cache@v2
162189
with:
163-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
190+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
164191
key: ${{ needs.job_build.outputs.dependency_cache_key }}
165192
- name: Check build cache
166193
uses: actions/cache@v2
@@ -171,7 +198,7 @@ jobs:
171198
run: yarn circularDepCheck
172199

173200
job_unit_test:
174-
name: Test (Node ${{ matrix.node }})
201+
name: Test (Node ${{ matrix.node }} - Linux)
175202
needs: job_build
176203
continue-on-error: true
177204
timeout-minutes: 30
@@ -189,20 +216,47 @@ jobs:
189216
- name: Check dependency cache
190217
uses: actions/cache@v2
191218
with:
192-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
219+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
193220
key: ${{ needs.job_build.outputs.dependency_cache_key }}
194221
- name: Check build cache
195222
uses: actions/cache@v2
196223
with:
197224
path: ${{ env.CACHED_BUILD_PATHS }}
198225
key: ${{ env.BUILD_CACHE_KEY }}
199226
- name: Run tests
200-
env:
201-
NODE_VERSION: ${{ matrix.node }}
202-
run: ./scripts/test.sh
227+
run: node ./scripts/test.js
203228
- name: Compute test coverage
204229
uses: codecov/codecov-action@v1
205230

231+
job_unit_test_windows:
232+
name: Test (Node ${{ matrix.node }} - Windows)
233+
needs: job_build
234+
continue-on-error: true
235+
timeout-minutes: 30
236+
runs-on: windows-latest
237+
strategy:
238+
matrix:
239+
node: [6, 8, 10, 12, 14, 16]
240+
steps:
241+
- name: Check out current commit (${{ github.sha }})
242+
uses: actions/checkout@v2
243+
- name: Set up Node
244+
uses: actions/setup-node@v1
245+
with:
246+
node-version: ${{ matrix.node }}
247+
- name: Check dependency cache
248+
uses: actions/cache@v2
249+
with:
250+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-windows
251+
key: ${{ needs.job_build.outputs.dependency_cache_key_windows }}
252+
- name: Check build cache
253+
uses: actions/cache@v2
254+
with:
255+
path: ${{ env.CACHED_BUILD_PATHS }}
256+
key: ${{ env.BUILD_CACHE_KEY }}
257+
- name: Run tests
258+
run: node ./scripts/test.js
259+
206260
# Ember tests are separate from the rest because they are the slowest part of the test suite, and making them a
207261
# separate job allows them to run in parallel with the other tests.
208262
job_ember_tests:
@@ -231,7 +285,7 @@ jobs:
231285
- name: Check dependency cache
232286
uses: actions/cache@v2
233287
with:
234-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
288+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
235289
key: ${{ needs.job_build.outputs.dependency_cache_key }}
236290
- name: Check build cache
237291
uses: actions/cache@v2
@@ -255,7 +309,7 @@ jobs:
255309
- name: Check dependency cache
256310
uses: actions/cache@v2
257311
with:
258-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
312+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
259313
key: ${{ needs.job_build.outputs.dependency_cache_key }}
260314
- name: Check build cache
261315
uses: actions/cache@v2
@@ -289,7 +343,7 @@ jobs:
289343
- name: Check dependency cache
290344
uses: actions/cache@v2
291345
with:
292-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
346+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
293347
key: ${{ needs.job_build.outputs.dependency_cache_key }}
294348
- name: Check build cache
295349
uses: actions/cache@v2
@@ -322,7 +376,7 @@ jobs:
322376
- name: Check dependency cache
323377
uses: actions/cache@v2
324378
with:
325-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
379+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
326380
key: ${{ needs.job_build.outputs.dependency_cache_key }}
327381
- name: Check build cache
328382
uses: actions/cache@v2
@@ -351,7 +405,7 @@ jobs:
351405
- name: Check dependency cache
352406
uses: actions/cache@v2
353407
with:
354-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
408+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
355409
key: ${{ needs.job_build.outputs.dependency_cache_key }}
356410
- name: Check build cache
357411
uses: actions/cache@v2

scripts/test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const { spawnSync } = require('child_process');
2+
const { join } = require('path');
3+
4+
const nodeVersion = parseInt(process.version.split('.')[0].replace('v', ''), 10);
5+
6+
function run(cmd) {
7+
const result = spawnSync(cmd, { shell: true, stdio: 'inherit', cwd: join(__dirname, '..') });
8+
9+
if (result.status !== 0) {
10+
process.exit(result.status);
11+
}
12+
}
13+
14+
// control which packages we test on each version of node
15+
if (nodeVersion <= 6) {
16+
// install legacy versions of packages whose current versions don't support node 6
17+
// ignoring engines and scripts lets us get away with having incompatible things installed for packages we're not testing
18+
run('cd packages/node && yarn add --dev --ignore-engines --ignore-scripts nock@10.x');
19+
run('cd packages/tracing && yarn add --dev --ignore-engines --ignore-scripts jsdom@11.x');
20+
run('cd packages/utils && yarn add --dev --ignore-engines --ignore-scripts jsdom@11.x');
21+
22+
// only test against @sentry/node and its dependencies - node 6 is too old for anything else to work
23+
run(
24+
'yarn test --scope="@sentry/core" --scope="@sentry/hub" --scope="@sentry/minimal" --scope="@sentry/node" --scope="@sentry/utils" --scope="@sentry/tracing"'
25+
);
26+
} else if (nodeVersion <= 8) {
27+
// install legacy versions of packages whose current versions don't support node 8
28+
// ignoring engines and scripts lets us get away with having incompatible things installed for packages we're not testing
29+
run('cd packages/tracing && yarn add --dev --ignore-engines --ignore-scripts jsdom@15.x');
30+
run('cd packages/utils && yarn add --dev --ignore-engines --ignore-scripts jsdom@15.x');
31+
32+
// ember tests happen separately, and the rest fail on node 8 for various syntax or dependency reasons
33+
run(
34+
'yarn test --ignore="@sentry/ember" --ignore="@sentry-internal/eslint-plugin-sdk" --ignore="@sentry/react" --ignore="@sentry/wasm" --ignore="@sentry/gatsby" --ignore="@sentry/serverless" --ignore="@sentry/nextjs"'
35+
);
36+
} else {
37+
run('yarn test --ignore="@sentry/ember"');
38+
}
39+
40+
process.exit(0);

scripts/test.sh

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

0 commit comments

Comments
 (0)