Skip to content

Commit fa27a25

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

File tree

3 files changed

+109
-55
lines changed

3 files changed

+109
-55
lines changed

.github/workflows/build.yml

Lines changed: 69 additions & 16 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,14 +43,40 @@ 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
5682
needs: job_install_deps
@@ -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
@@ -107,7 +133,7 @@ jobs:
107133
- name: Check dependency cache
108134
uses: actions/cache@v2
109135
with:
110-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
136+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
111137
key: ${{ needs.job_build.outputs.dependency_cache_key }}
112138
- name: Check build cache
113139
uses: actions/cache@v2
@@ -137,7 +163,7 @@ jobs:
137163
- name: Check dependency cache
138164
uses: actions/cache@v2
139165
with:
140-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
166+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
141167
key: ${{ needs.job_build.outputs.dependency_cache_key }}
142168
- name: Check build cache
143169
uses: actions/cache@v2
@@ -160,7 +186,7 @@ jobs:
160186
- name: Check dependency cache
161187
uses: actions/cache@v2
162188
with:
163-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
189+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
164190
key: ${{ needs.job_build.outputs.dependency_cache_key }}
165191
- name: Check build cache
166192
uses: actions/cache@v2
@@ -171,7 +197,7 @@ jobs:
171197
run: yarn circularDepCheck
172198

173199
job_unit_test:
174-
name: Test (Node ${{ matrix.node }})
200+
name: Test (Node ${{ matrix.node }} - Linux)
175201
needs: job_build
176202
continue-on-error: true
177203
timeout-minutes: 30
@@ -189,20 +215,47 @@ jobs:
189215
- name: Check dependency cache
190216
uses: actions/cache@v2
191217
with:
192-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
218+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
193219
key: ${{ needs.job_build.outputs.dependency_cache_key }}
194220
- name: Check build cache
195221
uses: actions/cache@v2
196222
with:
197223
path: ${{ env.CACHED_BUILD_PATHS }}
198224
key: ${{ env.BUILD_CACHE_KEY }}
199225
- name: Run tests
200-
env:
201-
NODE_VERSION: ${{ matrix.node }}
202-
run: ./scripts/test.sh
226+
run: node ./scripts/test.js
203227
- name: Compute test coverage
204228
uses: codecov/codecov-action@v1
205229

230+
job_unit_test_windows:
231+
name: Test (Node ${{ matrix.node }} - Windows)
232+
needs: job_install_deps_windows
233+
continue-on-error: true
234+
timeout-minutes: 30
235+
runs-on: windows-latest
236+
strategy:
237+
matrix:
238+
node: [6, 8, 10, 12, 14, 16]
239+
steps:
240+
- name: Check out current commit (${{ github.sha }})
241+
uses: actions/checkout@v2
242+
- name: Set up Node
243+
uses: actions/setup-node@v1
244+
with:
245+
node-version: ${{ matrix.node }}
246+
- name: Check dependency cache
247+
uses: actions/cache@v2
248+
with:
249+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-windows
250+
key: ${{ needs.job_build.outputs.dependency_cache_key_windows }}
251+
# - name: Check build cache
252+
# uses: actions/cache@v2
253+
# with:
254+
# path: ${{ env.CACHED_BUILD_PATHS }}
255+
# key: ${{ env.BUILD_CACHE_KEY }}
256+
- name: Run tests
257+
run: node ./scripts/test.js
258+
206259
# Ember tests are separate from the rest because they are the slowest part of the test suite, and making them a
207260
# separate job allows them to run in parallel with the other tests.
208261
job_ember_tests:
@@ -231,7 +284,7 @@ jobs:
231284
- name: Check dependency cache
232285
uses: actions/cache@v2
233286
with:
234-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
287+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
235288
key: ${{ needs.job_build.outputs.dependency_cache_key }}
236289
- name: Check build cache
237290
uses: actions/cache@v2
@@ -255,7 +308,7 @@ jobs:
255308
- name: Check dependency cache
256309
uses: actions/cache@v2
257310
with:
258-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
311+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
259312
key: ${{ needs.job_build.outputs.dependency_cache_key }}
260313
- name: Check build cache
261314
uses: actions/cache@v2
@@ -289,7 +342,7 @@ jobs:
289342
- name: Check dependency cache
290343
uses: actions/cache@v2
291344
with:
292-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
345+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
293346
key: ${{ needs.job_build.outputs.dependency_cache_key }}
294347
- name: Check build cache
295348
uses: actions/cache@v2
@@ -322,7 +375,7 @@ jobs:
322375
- name: Check dependency cache
323376
uses: actions/cache@v2
324377
with:
325-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
378+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
326379
key: ${{ needs.job_build.outputs.dependency_cache_key }}
327380
- name: Check build cache
328381
uses: actions/cache@v2
@@ -351,7 +404,7 @@ jobs:
351404
- name: Check dependency cache
352405
uses: actions/cache@v2
353406
with:
354-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
407+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
355408
key: ${{ needs.job_build.outputs.dependency_cache_key }}
356409
- name: Check build cache
357410
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)