diff --git a/developer/src/common/web/utils/build.sh b/developer/src/common/web/utils/build.sh index ddc66549937..618c9040b31 100755 --- a/developer/src/common/web/utils/build.sh +++ b/developer/src/common/web/utils/build.sh @@ -46,18 +46,24 @@ function do_build() { tsc --build } -builder_run_action clean rm -rf ./build/ -builder_run_action configure verify_npm_setup -builder_run_action build 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 -if builder_start_action test; then eslint . tsc --build test readonly C8_THRESHOLD=50 - c8 --reporter=lcov --reporter=text --exclude-after-remap --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha + c8 --reporter=lcov --reporter=text --exclude-after-remap --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_finish_action success test -fi +} -builder_run_action publish builder_publish_npm +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 publish builder_publish_npm diff --git a/developer/src/kmc-copy/build.sh b/developer/src/kmc-copy/build.sh index 023f0c73bf8..7907b6e1814 100755 --- a/developer/src/kmc-copy/build.sh +++ b/developer/src/kmc-copy/build.sh @@ -32,12 +32,19 @@ 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 "${builder_extra_params[@]}" + 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." } diff --git a/developer/src/kmc-generate/build.sh b/developer/src/kmc-generate/build.sh index 6a86a9339fe..b52010a0390 100755 --- a/developer/src/kmc-generate/build.sh +++ b/developer/src/kmc-generate/build.sh @@ -37,11 +37,18 @@ do_build() { } 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 "${builder_extra_params[@]}" + c8 --reporter=lcov --reporter=text mocha ${MOCHA_FLAGS} "${builder_extra_params[@]}" } builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo diff --git a/developer/src/kmc-keyboard-info/build.sh b/developer/src/kmc-keyboard-info/build.sh index c85d76db015..0f1c7f95d50 100755 --- a/developer/src/kmc-keyboard-info/build.sh +++ b/developer/src/kmc-keyboard-info/build.sh @@ -32,23 +32,28 @@ function do_configure() { mkdir -p src/imports echo 'export default ' > src/imports/langtags.js 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 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 - -#------------------------------------------------------------------------------------------------------------------- - -if builder_start_action test; then - eslint . - tsc --build test - c8 --reporter=lcov --reporter=text --exclude-after-remap mocha - builder_finish_action success test -fi +builder_run_action test do_test #------------------------------------------------------------------------------------------------------------------- diff --git a/developer/src/kmc-kmn/build.sh b/developer/src/kmc-kmn/build.sh index a0732414758..618e9a4edaf 100755 --- a/developer/src/kmc-kmn/build.sh +++ b/developer/src/kmc-kmn/build.sh @@ -56,27 +56,31 @@ function copy_deps() { cp ../kmcmplib/build/wasm/$BUILDER_CONFIGURATION/src/wasm-host.wasm ./build/src/import/kmcmplib/wasm-host.wasm } -if builder_start_action build; then +function do_build() { copy_deps tsc --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 -if builder_start_action test; then 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 + 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_finish_action success test -fi +builder_run_action build do_build +builder_run_action api api-extractor run --local --verbose +builder_run_action test do_test #------------------------------------------------------------------------------------------------------------------- diff --git a/developer/src/kmc-ldml/build.sh b/developer/src/kmc-ldml/build.sh index 73a40c79d75..23a2682e353 100755 --- a/developer/src/kmc-ldml/build.sh +++ b/developer/src/kmc-ldml/build.sh @@ -33,30 +33,19 @@ builder_describe_outputs \ builder_parse "$@" -#------------------------------------------------------------------------------------------------------------------- - -if builder_start_action clean; then +function do_clean() { rm -rf ./build/ ./tsconfig.tsbuildinfo - builder_finish_action success clean -fi +} -#------------------------------------------------------------------------------------------------------------------- - -if builder_start_action configure; then +function do_configure() { verify_npm_setup - builder_finish_action success configure -fi - -#------------------------------------------------------------------------------------------------------------------- +} -if builder_start_action build; then +function do_build() { npm run build - builder_finish_action success build -fi - -#------------------------------------------------------------------------------------------------------------------- +} -if builder_start_action build-fixtures; then +function do_build_fixtures() { # Build basic.kmx and emit its checksum mkdir -p ./build/test/fixtures node ../kmc build ./test/fixtures/basic.xml --no-compiler-version --debug --out-file ./build/test/fixtures/basic-xml.kmx @@ -65,22 +54,29 @@ if builder_start_action build-fixtures; then # Generate a binary file from basic.txt for comparison purposes node ../../../common/tools/hextobin/build/hextobin.js ./test/fixtures/basic.txt ./build/test/fixtures/basic-txt.kmx +} - builder_finish_action success build-fixtures -fi +function do_test() { + local MOCHA_FLAGS= -builder_run_action api api-extractor run --local --verbose - -#------------------------------------------------------------------------------------------------------------------- + if [[ "${TEAMCITY_GIT_PATH}" != "" ]]; then + # we're running in TeamCity + MOCHA_FLAGS="-reporter mocha-teamcity-reporter" + fi -if builder_start_action test; then eslint . cd test tsc -b cd .. - c8 --reporter=lcov --reporter=text mocha "${builder_extra_params[@]}" - builder_finish_action success test -fi + 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 #------------------------------------------------------------------------------------------------------------------- diff --git a/developer/src/kmc-model/build.sh b/developer/src/kmc-model/build.sh index 372a145312a..9b53402f551 100755 --- a/developer/src/kmc-model/build.sh +++ b/developer/src/kmc-model/build.sh @@ -35,10 +35,24 @@ function do_build() { 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 npm test +builder_run_action test do_test builder_run_action publish builder_publish_npm diff --git a/developer/src/kmc-package/build.sh b/developer/src/kmc-package/build.sh index 0b2d7bda9b9..c7d5108ff74 100755 --- a/developer/src/kmc-package/build.sh +++ b/developer/src/kmc-package/build.sh @@ -30,20 +30,25 @@ builder_describe_outputs \ builder_parse "$@" -#------------------------------------------------------------------------------------------------------------------- - -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 +function do_test() { + local MOCHA_FLAGS= -if builder_start_action test; then + 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 - builder_finish_action success test -fi + 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 publish builder_publish_npm