diff --git a/developer/src/common/web/utils/build.sh b/developer/src/common/web/utils/build.sh index b8137619877..f7433cb2faf 100755 --- a/developer/src/common/web/utils/build.sh +++ b/developer/src/common/web/utils/build.sh @@ -46,24 +46,8 @@ function do_build() { tsc --build } -function do_test() { - local MOCHA_FLAGS= - - if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then - # we're running in TeamCity - MOCHA_FLAGS="-reporter mocha-teamcity-reporter" - fi - - eslint . - tsc --build test - readonly C8_THRESHOLD=50 - c8 --reporter=lcov --reporter=text --exclude-after-remap --check-coverage=false --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha ${MOCHA_FLAGS} - builder_echo warning "Coverage thresholds are currently $C8_THRESHOLD%, which is lower than ideal." - builder_echo warning "Please increase threshold in build.sh as test coverage improves." -} - builder_run_action clean rm -rf ./build/ builder_run_action configure verify_npm_setup builder_run_action build do_build -builder_run_action test do_test +builder_run_action test builder_do_typescript_tests 50 builder_run_action publish builder_publish_npm diff --git a/developer/src/kmc-analyze/build.sh b/developer/src/kmc-analyze/build.sh index d78bd146cdf..ace83ffbbe4 100755 --- a/developer/src/kmc-analyze/build.sh +++ b/developer/src/kmc-analyze/build.sh @@ -25,25 +25,9 @@ builder_parse "$@" #------------------------------------------------------------------------------------------------------------------- -function do_test() { - local MOCHA_FLAGS= - - if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then - # we're running in TeamCity - MOCHA_FLAGS="-reporter mocha-teamcity-reporter" - fi - - eslint . - cd test - tsc --build - cd .. - readonly C8_THRESHOLD=70 - c8 --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha ${MOCHA_FLAGS} -} - builder_run_action clean rm -rf ./build/ builder_run_action configure verify_npm_setup builder_run_action build tsc --build builder_run_action api api-extractor run --local --verbose -builder_run_action test do_test +builder_run_action test builder_do_typescript_tests 70 builder_run_action publish builder_publish_npm diff --git a/developer/src/kmc-copy/build.sh b/developer/src/kmc-copy/build.sh index f916bec556d..ee8615fc44a 100755 --- a/developer/src/kmc-copy/build.sh +++ b/developer/src/kmc-copy/build.sh @@ -29,29 +29,16 @@ builder_parse "$@" #------------------------------------------------------------------------------------------------------------------- -do_test() { - # note: `export TEST_SAVE_ARTIFACTS=1` to save a copy of artifacts to temp path - # note: `export TEST_SAVE_FIXTURES=1` to get a copy of cloud-based fixtures saved to online/ - local MOCHA_FLAGS= - - if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then - # we're running in TeamCity - MOCHA_FLAGS="-reporter mocha-teamcity-reporter" - fi - - eslint . - cd test - tsc --build - cd .. - readonly C8_THRESHOLD=70 - c8 -skip-full --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha ${MOCHA_FLAGS} "${builder_extra_params[@]}" - builder_echo warning "Coverage thresholds are currently $C8_THRESHOLD%, which is lower than ideal." - builder_echo warning "Please increase threshold in build.sh as test coverage improves." -} + builder_run_action clean rm -rf ./build/ builder_run_action configure verify_npm_setup builder_run_action build tsc --build builder_run_action api api-extractor run --local --verbose -builder_run_action test do_test + +# note: `export TEST_SAVE_ARTIFACTS=1` to save a copy of artifacts to temp path +# note: `export TEST_SAVE_FIXTURES=1` to get a copy of cloud-based fixtures saved to online/ +# TODO: -skip-full +builder_run_action test builder_do_typescript_tests 70 + builder_run_action publish builder_publish_npm diff --git a/developer/src/kmc-generate/build.sh b/developer/src/kmc-generate/build.sh index 5380ee3eb24..e99e8288c26 100755 --- a/developer/src/kmc-generate/build.sh +++ b/developer/src/kmc-generate/build.sh @@ -36,24 +36,9 @@ do_build() { cp -R ./src/template/ ./build/src/ } -do_test() { - local MOCHA_FLAGS= - - if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then - # we're running in TeamCity - MOCHA_FLAGS="-reporter mocha-teamcity-reporter" - fi - - eslint . - cd test - tsc --build - cd .. - c8 --reporter=lcov --reporter=text mocha ${MOCHA_FLAGS} "${builder_extra_params[@]}" -} - builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo builder_run_action configure verify_npm_setup builder_run_action build do_build builder_run_action api api-extractor run --local --verbose -builder_run_action test do_test +builder_run_action test builder_do_typescript_tests builder_run_action publish builder_publish_npm diff --git a/developer/src/kmc-keyboard-info/build.sh b/developer/src/kmc-keyboard-info/build.sh index 5ccc41a8138..acd6bd65deb 100755 --- a/developer/src/kmc-keyboard-info/build.sh +++ b/developer/src/kmc-keyboard-info/build.sh @@ -34,26 +34,13 @@ function do_configure() { cat "$KEYMAN_ROOT/resources/standards-data/langtags/langtags.json" >> src/imports/langtags.js } -function do_test() { - local MOCHA_FLAGS= - - if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then - # we're running in TeamCity - MOCHA_FLAGS="-reporter mocha-teamcity-reporter" - fi - - eslint . - tsc --build test - c8 --reporter=lcov --reporter=text --exclude-after-remap --check-coverage=false mocha ${MOCHA_FLAGS} -} - #------------------------------------------------------------------------------------------------------------------- builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo builder_run_action configure do_configure builder_run_action build tsc --build builder_run_action api api-extractor run --local --verbose -builder_run_action test do_test +builder_run_action test builder_do_typescript_tests #------------------------------------------------------------------------------------------------------------------- diff --git a/developer/src/kmc-kmn/build.sh b/developer/src/kmc-kmn/build.sh index 5f81a367a9f..c6ed29b6f94 100755 --- a/developer/src/kmc-kmn/build.sh +++ b/developer/src/kmc-kmn/build.sh @@ -62,20 +62,8 @@ function do_build() { } function do_test() { - local MOCHA_FLAGS= - - if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then - # we're running in TeamCity - MOCHA_FLAGS="-reporter mocha-teamcity-reporter" - fi - copy_deps - tsc --build test/ - npm run lint - readonly C8_THRESHOLD=80 - c8 --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha ${MOCHA_FLAGS} - builder_echo warning "Coverage thresholds are currently $C8_THRESHOLD%, which is lower than ideal." - builder_echo warning "Please increase threshold in build.sh as test coverage improves." + builder_do_typescript_tests 80 } builder_run_action build do_build diff --git a/developer/src/kmc-ldml/build.sh b/developer/src/kmc-ldml/build.sh index 61fc2a695c5..a961fea6fdc 100755 --- a/developer/src/kmc-ldml/build.sh +++ b/developer/src/kmc-ldml/build.sh @@ -56,27 +56,12 @@ function do_build_fixtures() { node ../../../common/tools/hextobin/build/hextobin.js ./test/fixtures/basic.txt ./build/test/fixtures/basic-txt.kmx } -function do_test() { - local MOCHA_FLAGS= - - if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then - # we're running in TeamCity - MOCHA_FLAGS="-reporter mocha-teamcity-reporter" - fi - - eslint . - cd test - tsc -b - cd .. - c8 --reporter=lcov --reporter=text mocha ${MOCHA_FLAGS} "${builder_extra_params[@]}" -} - builder_run_action clean do_clean builder_run_action configure do_configure builder_run_action build do_build builder_run_action build-fixtures do_build_fixtures builder_run_action api api-extractor run --local --verbose -builder_run_action test do_test +builder_run_action test builder_do_typescript_tests #------------------------------------------------------------------------------------------------------------------- diff --git a/developer/src/kmc-model-info/build.sh b/developer/src/kmc-model-info/build.sh index 2563da22248..153c3567369 100755 --- a/developer/src/kmc-model-info/build.sh +++ b/developer/src/kmc-model-info/build.sh @@ -27,43 +27,11 @@ builder_parse "$@" #------------------------------------------------------------------------------------------------------------------- -if builder_start_action clean; then - rm -rf ./build/ ./tsconfig.tsbuildinfo - builder_finish_action success clean -fi - -#------------------------------------------------------------------------------------------------------------------- - -if builder_start_action configure; then - verify_npm_setup - builder_finish_action success configure -fi - -#------------------------------------------------------------------------------------------------------------------- - -if builder_start_action build; then - npm run build - builder_finish_action success build -fi - -builder_run_action api api-extractor run --local --verbose - -#------------------------------------------------------------------------------------------------------------------- - -function do_test() { - local MOCHA_FLAGS= - - if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then - # we're running in TeamCity - MOCHA_FLAGS="-reporter mocha-teamcity-reporter" - fi - eslint . - tsc --build test - c8 --reporter=lcov --reporter=text --exclude-after-remap --check-coverage=false --lines 80 mocha ${MOCHA_FLAGS} - # TODO: remove --lines 80 and improve coverage -} - -builder_run_action test do_test +builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo +builder_run_action configure verify_npm_setup +builder_run_action build tsc --build +builder_run_action api api-extractor run --local --verbose +builder_run_action test builder_do_typescript_tests 80 #------------------------------------------------------------------------------------------------------------------- diff --git a/developer/src/kmc-model-info/package.json b/developer/src/kmc-model-info/package.json index 20be72d1899..54437e7b3ec 100644 --- a/developer/src/kmc-model-info/package.json +++ b/developer/src/kmc-model-info/package.json @@ -30,7 +30,6 @@ "url": "https://github.com/keymanapp/keyman/issues" }, "dependencies": { - "@keymanapp/common-types": "*", "@keymanapp/common-types": "*", "@keymanapp/developer-utils": "*" }, diff --git a/developer/src/kmc-model/build.sh b/developer/src/kmc-model/build.sh index 7186c3ef891..9e7166f8b74 100755 --- a/developer/src/kmc-model/build.sh +++ b/developer/src/kmc-model/build.sh @@ -32,27 +32,13 @@ builder_parse "$@" function do_build() { tsc -b ./tools/tsconfig.json - npm run build -} - -function do_test() { - local MOCHA_FLAGS= - - if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then - # we're running in TeamCity - MOCHA_FLAGS="-reporter mocha-teamcity-reporter" - fi - npm run lint - cd test tsc -b - cd .. - c8 --reporter=lcov --reporter=text mocha ${MOCHA_FLAGS} } builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo builder_run_action configure verify_npm_setup builder_run_action build do_build builder_run_action api api-extractor run --local --verbose -builder_run_action test do_test +builder_run_action test builder_do_typescript_tests builder_run_action publish builder_publish_npm diff --git a/developer/src/kmc-model/package.json b/developer/src/kmc-model/package.json index 3f95b5e181b..9c4e99118ab 100644 --- a/developer/src/kmc-model/package.json +++ b/developer/src/kmc-model/package.json @@ -32,7 +32,6 @@ "dependencies": { "@keymanapp/common-types": "*", "@keymanapp/keyman-version": "*", - "@keymanapp/common-types": "*", "typescript": "^5.4.5" }, "devDependencies": { diff --git a/developer/src/kmc-package/build.sh b/developer/src/kmc-package/build.sh index bad3bb1d183..81f8b928c70 100755 --- a/developer/src/kmc-package/build.sh +++ b/developer/src/kmc-package/build.sh @@ -30,25 +30,11 @@ builder_describe_outputs \ builder_parse "$@" -function do_test() { - local MOCHA_FLAGS= - - if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then - # we're running in TeamCity - MOCHA_FLAGS="-reporter mocha-teamcity-reporter" - fi - eslint . - cd test - tsc --build - cd .. - c8 --reporter=lcov --reporter=text mocha ${MOCHA_FLAGS} -} - #------------------------------------------------------------------------------------------------------------------- builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo builder_run_action configure verify_npm_setup builder_run_action build tsc --build builder_run_action api api-extractor run --local --verbose -builder_run_action test do_test +builder_run_action test builder_do_typescript_tests builder_run_action publish builder_publish_npm diff --git a/developer/src/kmc/build.sh b/developer/src/kmc/build.sh index 6e4ebc0a587..684a9acbeaf 100755 --- a/developer/src/kmc/build.sh +++ b/developer/src/kmc/build.sh @@ -61,24 +61,6 @@ function do_api() { #------------------------------------------------------------------------------------------------------------------- -function do_test() { - local MOCHA_FLAGS= - - if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then - # we're running in TeamCity - MOCHA_FLAGS="-reporter mocha-teamcity-reporter" - fi - - eslint . - tsc --build test/ - readonly C8_THRESHOLD=50 - c8 --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha ${MOCHA_FLAGS} - builder_echo warning "Coverage thresholds are currently $C8_THRESHOLD%, which is lower than ideal." - builder_echo warning "Please increase threshold in build.sh as test coverage improves." -} - -#------------------------------------------------------------------------------------------------------------------- - function do_bundle() { SOURCEMAP_PATHS=( "${PACKAGES[@]}" ) SOURCEMAP_PATHS=( "${SOURCEMAP_PATHS[@]/%//build}" ) @@ -117,7 +99,7 @@ function do_bundle() { builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo builder_run_action configure verify_npm_setup builder_run_action build do_build -builder_run_action test do_test +builder_run_action test builder_do_typescript_tests 50 builder_run_action api do_api builder_run_action bundle do_bundle builder_run_action publish builder_publish_npm diff --git a/resources/shellHelperFunctions.sh b/resources/shellHelperFunctions.sh index 6f8e1b52681..a2eee530147 100755 --- a/resources/shellHelperFunctions.sh +++ b/resources/shellHelperFunctions.sh @@ -304,4 +304,30 @@ _select_node_version_with_nvm() { check-markdown() { node "$KEYMAN_ROOT/resources/tools/check-markdown" --root "$1" +} + +builder_do_typescript_tests() { + local MOCHA_FLAGS= + + if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then + # we're running in TeamCity + MOCHA_FLAGS="-reporter mocha-teamcity-reporter" + fi + + eslint . + tsc --build test/ + + local THRESHOLD_PARAMS= + local C8_THRESHOLD= + if [[ $# -gt 0 ]]; then + C8_THRESHOLD=$1 + THRESHOLD_PARAMS="--lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD" + fi + + c8 --reporter=lcov --reporter=text --exclude-after-remap --check-coverage=false $THRESHOLD_PARAMS mocha ${MOCHA_FLAGS} "${builder_extra_params[@]}" + + if [[ ! -z "$C8_THRESHOLD" ]]; then + builder_echo warning "Coverage thresholds are currently $C8_THRESHOLD%, which is lower than ideal." + builder_echo warning "Please increase threshold in build.sh as test coverage improves." + fi } \ No newline at end of file