Verifies the source files of a NodeJS package - by running its verify
script within the scripts
section of package.json
.
It is worth noting this action can support any technology - as long as you comply with the requirements described below.
steps:
- uses: actions/checkout@v4
- uses: giancosta86/aurora-github/actions/verify-npm-package@v8
IMPORTANT: please, remember to declare your verification process in the verify
script within package.json
! For example:
"scripts": {
"test": "vitest",
"build": "tsc",
"verify": "pnpm test && pnpm build"
}
-
Run enforce-branch-version, forwarding the
enforce-branch-version
input to itsmode
input. -
Install the required NodeJS version, pnpm and the dependencies, via setup-nodejs-context
-
Run
pnpm verify
- so that the related script inpackage.json
can decide what to do. -
By default, run check-subpath-exports to verify that the
exports
field inpackage.json
actually references existing files. -
If a tests directory exists within
project-directory
, execute run-custom-tests on it, with theoptional
flag enabled.💡The rationale for this step is a parallelism with Rust's tests directory - dedicated to verify the crate under test from a client perspective; however, in
verify-npm-package
you have even more fine-grained control over the test process: for example, you can automatically launch a Bash script to test the system, while still relying on the tests directory to host utility modules imported by different tests in the src directory tree.Please, note: should you need to execute a shell script for testing, a
verify.sh
script, run by Bash, is required; for further details, please refer to run-custom-tests. -
Find critical TODOs in the source code - which crash the workflow by default.
-
The entire verification process for the package must be triggered by the
verify
script inpackage.json
(see the example). -
The requirements for setup-nodejs-context.
Name | Type | Description | Default value |
---|---|---|---|
crash-on-critical-todos |
boolean | Crash the workflow if critical TODOs are found | true |
source-file-regex |
string | PCRE pattern describing the source files | view source |
enforce-branch-version |
inject ,check ,skip |
How the branch version should be enforced | inject |
check-subpath-exports |
boolean | Run check-subpath-exports after the verify script |
true |
project-directory |
string | The directory containing package.json |
. |