Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to more resilient testing #343

Merged
merged 1 commit into from Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions bin/runTests.sh
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -eEuo pipefail

#
# As of Node 20, the --test parameter does not support globbing, and it does not
# support variable Windows paths. We also cannot invoke the test runner
# directly, because while it has an API, there's no way to force it to transpile
# the Typescript into JavaScript before passing it to the runner.
#
# So we're left with this solution, which shells out to Node to list all files
# that end in *.test.ts (excluding node_modules/), and then execs out to that
# process. We have to exec so the stderr/stdout and exit code is appropriately
# fed to the caller.
#

FILES="$(node -e "process.stdout.write(require('node:fs').readdirSync('./', { recursive: true }).filter((e) => {return e.endsWith('.test.ts') && !e.startsWith('node_modules');}).sort().join(' '));")"

set -x
exec node --require ts-node/register --test-reporter spec --test ${FILES}
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -7,7 +7,7 @@
"build": "ncc build -m src/main.ts -o dist/main && ncc build -m src/post.ts -o dist/post",
"lint": "eslint . --ext .ts,.tsx",
"format": "prettier --write **/*.ts",
"test": " node --require ts-node/register --test **/*.test.ts **/**/*.test.ts"
"test": "bash ./bin/runTests.sh"
},
"repository": {
"type": "git",
Expand All @@ -25,7 +25,7 @@
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/http-client": "^2.2.0",
"@google-github-actions/actions-utils": "^0.4.9"
"@google-github-actions/actions-utils": "^0.4.10"
},
"devDependencies": {
"@types/node": "^20.9.0",
Expand Down