diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b93b34709ccf..a0cf4524db72 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -199,7 +199,7 @@ jobs: - name: Run tests env: NODE_VERSION: ${{ matrix.node }} - run: ./scripts/test.sh + run: yarn test-ci - name: Compute test coverage uses: codecov/codecov-action@v1 diff --git a/package.json b/package.json index a333974ca7d0..ac34195ff847 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ "pack:changed": "lerna run pack --since", "prepublishOnly": "lerna run --stream --concurrency 1 prepublishOnly", "postpublish": "make publish-docs && lerna run --stream --concurrency 1 postpublish", - "test": "lerna run --ignore @sentry-internal/browser-integration-tests --stream --concurrency 1 --sort test" + "test": "lerna run --ignore @sentry-internal/browser-integration-tests --stream --concurrency 1 --sort test", + "test-ci": "ts-node ./scripts/test.ts" }, "volta": { "node": "14.17.0", @@ -84,7 +85,7 @@ "sinon": "^7.3.2", "size-limit": "^4.5.5", "ts-jest": "^24.3.0", - "ts-node": "^10.7.0", + "ts-node": "^8.10.2", "tslib": "^2.3.1", "typedoc": "^0.18.0", "typescript": "3.7.5" diff --git a/scripts/test.sh b/scripts/test.sh deleted file mode 100755 index 82ef3f3ac4fd..000000000000 --- a/scripts/test.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -set -e - -# control which packages we test on each version of node -if [[ "$(cut -d. -f1 <<<"$NODE_VERSION")" -le 6 ]]; then - - # install legacy versions of packages whose current versions don't support node 6 - # ignoring engines and scripts lets us get away with having incompatible things installed for packages we're not testing - cd packages/node - yarn add --dev --ignore-engines --ignore-scripts nock@10.x - cd ../.. - cd packages/tracing - yarn add --dev --ignore-engines --ignore-scripts jsdom@11.x - cd ../.. - cd packages/utils - yarn add --dev --ignore-engines --ignore-scripts jsdom@11.x - cd ../.. - - # only test against @sentry/node and its dependencies - node 6 is too old for anything else to work - yarn test --scope="@sentry/core" --scope="@sentry/hub" --scope="@sentry/minimal" --scope="@sentry/node" --scope="@sentry/utils" --scope="@sentry/tracing" - -elif [[ "$(cut -d. -f1 <<<"$NODE_VERSION")" -le 8 ]]; then - - # install legacy versions of packages whose current versions don't support node 8 - # ignoring engines and scripts lets us get away with having incompatible things installed for packages we're not testing - cd packages/tracing - yarn add --dev --ignore-engines --ignore-scripts jsdom@15.x - cd ../.. - cd packages/utils - yarn add --dev --ignore-engines --ignore-scripts jsdom@15.x - cd ../.. - - # ember tests happen separately, and the rest fail on node 8 for various syntax or dependency reasons - 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" - -else - yarn test --ignore="@sentry/ember" - -fi diff --git a/scripts/test.ts b/scripts/test.ts new file mode 100644 index 000000000000..36d6490cbd5f --- /dev/null +++ b/scripts/test.ts @@ -0,0 +1,52 @@ +const { spawnSync } = require('child_process'); +const { join } = require('path'); + +function run(cmd: string, cwd = '') { + const result = spawnSync(cmd, { shell: true, stdio: 'inherit', cwd: join(__dirname, '..', cwd || '') }); + + if (result.status !== 0) { + process.exit(result.status); + } +} + +const nodeMajorVersion = parseInt(process.version.split('.')[0].replace('v', ''), 10); + +// control which packages we test on each version of node +if (nodeMajorVersion <= 6) { + // install legacy versions of packages whose current versions don't support node 6 + // ignoring engines and scripts lets us get away with having incompatible things installed for packages we're not testing + run('yarn add --dev --ignore-engines --ignore-scripts nock@10.x', 'packages/node'); + run('yarn add --dev --ignore-engines --ignore-scripts jsdom@11.x', 'packages/tracing'); + run('yarn add --dev --ignore-engines --ignore-scripts jsdom@11.x', 'packages/utils'); + + // only test against @sentry/node and its dependencies - node 6 is too old for anything else to work + const scope = ['@sentry/core', '@sentry/hub', '@sentry/minimal', '@sentry/node', '@sentry/utils', '@sentry/tracing'] + .map(dep => `--scope="${dep}"`) + .join(' '); + + run(`yarn test ${scope}`); +} else if (nodeMajorVersion <= 8) { + // install legacy versions of packages whose current versions don't support node 8 + // ignoring engines and scripts lets us get away with having incompatible things installed for packages we're not testing + run('yarn add --dev --ignore-engines --ignore-scripts jsdom@15.x', 'packages/tracing'); + run('yarn add --dev --ignore-engines --ignore-scripts jsdom@15.x', 'packages/utils'); + + // ember tests happen separately, and the rest fail on node 8 for various syntax or dependency reasons + const ignore = [ + '@sentry/ember', + '@sentry-internal/eslint-plugin-sdk', + '@sentry/react', + '@sentry/wasm', + '@sentry/gatsby', + '@sentry/serverless', + '@sentry/nextjs', + ] + .map(dep => `--ignore="${dep}"`) + .join(' '); + + run(`yarn test ${ignore}`); +} else { + run('yarn test --ignore="@sentry/ember"'); +} + +process.exit(0); diff --git a/yarn.lock b/yarn.lock index e1cb1984c431..66e4ed7ea594 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1544,18 +1544,6 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@cspotcode/source-map-consumer@0.8.0": - version "0.8.0" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b" - integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg== - -"@cspotcode/source-map-support@0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz#4789840aa859e46d2f3173727ab707c66bf344f5" - integrity sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA== - dependencies: - "@cspotcode/source-map-consumer" "0.8.0" - "@ember-data/rfc395-data@^0.0.4": version "0.0.4" resolved "https://registry.yarnpkg.com/@ember-data/rfc395-data/-/rfc395-data-0.0.4.tgz#ecb86efdf5d7733a76ff14ea651a1b0ed1f8a843" @@ -3323,26 +3311,6 @@ "@types/semver" "^7.3.9" ts-type "^2.1.4" -"@tsconfig/node10@^1.0.7": - version "1.0.8" - resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9" - integrity sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg== - -"@tsconfig/node12@^1.0.7": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.9.tgz#62c1f6dee2ebd9aead80dc3afa56810e58e1a04c" - integrity sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw== - -"@tsconfig/node14@^1.0.0": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2" - integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg== - -"@tsconfig/node16@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e" - integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA== - "@types/aria-query@^4.2.0": version "4.2.1" resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.1.tgz#78b5433344e2f92e8b306c06a5622c50c245bf6b" @@ -4540,11 +4508,6 @@ acorn-walk@^8.0.0: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.0.2.tgz#d4632bfc63fd93d0f15fd05ea0e984ffd3f5a8c3" integrity sha512-+bpA9MJsHdZ4bgfDcpk0ozQyhhVct7rzOmO0s1IIr0AGGgKBljss8n2zp11rRP2wid5VGeh04CgeKzgat5/25A== -acorn-walk@^8.1.1: - version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== - acorn@^5.5.3: version "5.7.4" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.4.tgz#3e8d8a9947d0599a1796d10225d7432f4a4acf5e" @@ -8060,11 +8023,6 @@ create-react-context@^0.2.2: fbjs "^0.8.0" gud "^1.0.0" -create-require@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" - integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== - cross-env@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" @@ -19668,18 +19626,18 @@ source-map-support@^0.4.15, source-map-support@^0.4.18: dependencies: source-map "^0.5.6" -source-map-support@^0.5.6, source-map-support@~0.5.12: - version "0.5.19" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" - integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== +source-map-support@^0.5.17, source-map-support@~0.5.20: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== dependencies: buffer-from "^1.0.0" source-map "^0.6.0" -source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== +source-map-support@^0.5.6, source-map-support@~0.5.12: + version "0.5.19" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" + integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== dependencies: buffer-from "^1.0.0" source-map "^0.6.0" @@ -21003,23 +20961,15 @@ ts-jest@^24.3.0: semver "^5.5" yargs-parser "10.x" -ts-node@^10.7.0: - version "10.7.0" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.7.0.tgz#35d503d0fab3e2baa672a0e94f4b40653c2463f5" - integrity sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A== +ts-node@^8.10.2: + version "8.10.2" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.2.tgz#eee03764633b1234ddd37f8db9ec10b75ec7fb8d" + integrity sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA== dependencies: - "@cspotcode/source-map-support" "0.7.0" - "@tsconfig/node10" "^1.0.7" - "@tsconfig/node12" "^1.0.7" - "@tsconfig/node14" "^1.0.0" - "@tsconfig/node16" "^1.0.2" - acorn "^8.4.1" - acorn-walk "^8.1.1" arg "^4.1.0" - create-require "^1.1.0" diff "^4.0.1" make-error "^1.1.1" - v8-compile-cache-lib "^3.0.0" + source-map-support "^0.5.17" yn "3.1.1" ts-pnp@^1.1.6: @@ -21576,11 +21526,6 @@ uuid@^8.0.0, uuid@^8.3.0, uuid@^8.3.1, uuid@^8.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== -v8-compile-cache-lib@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz#0582bcb1c74f3a2ee46487ceecf372e46bce53e8" - integrity sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA== - v8-compile-cache@^2.0.3: version "2.3.0" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"