Skip to content

Commit 59638e1

Browse files
committed
Replace test.sh
1 parent 2d26879 commit 59638e1

File tree

4 files changed

+55
-41
lines changed

4 files changed

+55
-41
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ jobs:
199199
- name: Run tests
200200
env:
201201
NODE_VERSION: ${{ matrix.node }}
202-
run: ./scripts/test.sh
202+
run: yarn test-ci
203203
- name: Compute test coverage
204204
uses: codecov/codecov-action@v1
205205

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"pack:changed": "lerna run pack --since",
2323
"prepublishOnly": "lerna run --stream --concurrency 1 prepublishOnly",
2424
"postpublish": "make publish-docs && lerna run --stream --concurrency 1 postpublish",
25-
"test": "lerna run --ignore @sentry-internal/browser-integration-tests --stream --concurrency 1 --sort test"
25+
"test": "lerna run --ignore @sentry-internal/browser-integration-tests --stream --concurrency 1 --sort test",
26+
"test-ci": "ts-node scripts/test.ts"
2627
},
2728
"volta": {
2829
"node": "14.17.0",

scripts/test.sh

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

scripts/test.ts

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

0 commit comments

Comments
 (0)