Skip to content

Commit

Permalink
[TASK] Add npm command dispatcher to Build/Scripts/runTests.sh
Browse files Browse the repository at this point in the history
`Build/Scripts/runTests.sh` is the monorepo main dispatcher of
script and tools to ensure same working state across developer
host system and installation by using well defined containers.
This mitigates issues with missing dependencies or wrong version
of tools on develper machines.

Until now local installation of `node` and `npm` in the matching
version was mandatory to work with the node ecosystem like manage
dependencies, executing node based tools or the build chain for
CSS and TypeScript/JavaScript.

This change adds now a `npm` dispatcher to `runTests.sh` similar
to the `composer` command dispatcher introduced with #103045 to
allow executing npm commands and defined scripts in `package.json`
in a well-defined environment and removes the hard-requirement of
installing it locally for new contributors.

Added `runTests.sh` suite:

* ./Build/Scripts/runTests.sh -s npm --  <npm-command-arguments>

which allows now to using npm commands always with the correct
npm and node version defined for the mono-repository state.

Some examples:

  ./Build/Scripts/runTests.sh -s npm -- audit
  ./Build/Scripts/runTests.sh -s npm -- ci
  ./Build/Scripts/runTests.sh -s npm -- run build
  ./Build/Scripts/runTests.sh -s npm -- run watch:build
  ./Build/Scripts/runTests.sh -s npm -- install \
    --save bootstrap@^5.3.2

Resolves: #103552
Related: #103045
Releases: main, 12.4, 11.5
Change-Id: Ie9de71f24dfd4805a98be7dc1b1604e5d0146eec
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83663
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
sbuerk committed Apr 8, 2024
1 parent 08a78a5 commit 20a8584
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Build/Scripts/runTests.sh
Expand Up @@ -226,6 +226,7 @@ Options:
- lintTypescript: TS linting
- lintHtml: HTML linting
- listExceptionCodes: list core exception codes in JSON format
- npm: "npm" command dispatcher, to execute various npm commands directly
- phpstan: phpstan tests
- phpstanGenerateBaseline: regenerate phpstan baseline, handy after phpstan updates
- unit (default): PHP unit tests
Expand Down Expand Up @@ -374,6 +375,13 @@ Examples:
# Some composer command examples
./Build/Scripts/runTests.sh -s composer -- dumpautoload
./Build/Scripts/runTests.sh -s composer -- info | grep "symfony"
# Some npm command examples
./Build/Scripts/runTests.sh -s npm -- audit
./Build/Scripts/runTests.sh -s npm -- ci
./Build/Scripts/runTests.sh -s npm -- run build
./Build/Scripts/runTests.sh -s npm -- run watch:build
./Build/Scripts/runTests.sh -s npm -- install --save bootstrap@^5.3.2
EOF
}

Expand Down Expand Up @@ -1044,6 +1052,11 @@ case ${TEST_SUITE} in
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name list-exception-codes-${SUFFIX} ${IMAGE_PHP} Build/Scripts/duplicateExceptionCodeCheck.sh -p
SUITE_EXIT_CODE=$?
;;
npm)
COMMAND=(npm "$@")
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} -w ${CORE_ROOT}/Build -e HOME=${CORE_ROOT}/.cache --name npm-${SUFFIX} ${IMAGE_NODEJS} "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
phpstan)
COMMAND=(php -dxdebug.mode=off bin/phpstan analyse -c Build/phpstan/${PHPSTAN_CONFIG_FILE} --no-progress --no-interaction --memory-limit 4G "$@")
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name phpstan-${SUFFIX} ${IMAGE_PHP} "${COMMAND[@]}"
Expand Down

0 comments on commit 20a8584

Please sign in to comment.