mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-19 06:07:40 +00:00
maint(common): move typescript script functions into typescript.inc.sh
Fixes: #14448 Build-bot: build Test-bot: skip
This commit is contained in:
parent
3530fece47
commit
acefdf281a
14 changed files with 69 additions and 56 deletions
|
|
@ -7,6 +7,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
|||
|
||||
. "$KEYMAN_ROOT/resources/build/utils.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/node.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/typescript.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh"
|
||||
|
||||
builder_describe "Build Keyman Developer web utility module" \
|
||||
|
|
@ -50,5 +51,5 @@ function do_build() {
|
|||
builder_run_action clean rm -rf ./build/
|
||||
builder_run_action configure node_select_version_and_npm_ci
|
||||
builder_run_action build do_build
|
||||
builder_run_action test builder_do_typescript_tests 45
|
||||
builder_run_action test typescript_run_eslint_mocha_tests 45
|
||||
builder_run_action publish builder_publish_npm
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
|||
|
||||
. "$KEYMAN_ROOT/resources/build/utils.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/node.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/typescript.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh"
|
||||
|
||||
builder_describe "Keyman Developer Compiler Analysis Tools" \
|
||||
|
|
@ -30,5 +31,5 @@ builder_run_action clean rm -rf ./build/
|
|||
builder_run_action configure node_select_version_and_npm_ci
|
||||
builder_run_action build tsc --build
|
||||
builder_run_action api api-extractor run --local --verbose
|
||||
builder_run_action test builder_do_typescript_tests 70
|
||||
builder_run_action test typescript_run_eslint_mocha_tests 70
|
||||
builder_run_action publish builder_publish_npm
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
|||
|
||||
. "$KEYMAN_ROOT/resources/build/utils.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/node.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/typescript.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh"
|
||||
|
||||
builder_describe "Build Keyman kmc-copy module" \
|
||||
|
|
@ -40,6 +41,6 @@ builder_run_action api api-extractor run --local --verbose
|
|||
# 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 75
|
||||
builder_run_action test typescript_run_eslint_mocha_tests 75
|
||||
|
||||
builder_run_action publish builder_publish_npm
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
|||
|
||||
. "$KEYMAN_ROOT/resources/build/utils.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/node.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/typescript.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh"
|
||||
|
||||
builder_describe "Build Keyman kmc-generate module" \
|
||||
|
|
@ -42,5 +43,5 @@ builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo
|
|||
builder_run_action configure node_select_version_and_npm_ci
|
||||
builder_run_action build do_build
|
||||
builder_run_action api api-extractor run --local --verbose
|
||||
builder_run_action test builder_do_typescript_tests
|
||||
builder_run_action test typescript_run_eslint_mocha_tests
|
||||
builder_run_action publish builder_publish_npm
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
|||
|
||||
. "$KEYMAN_ROOT/resources/build/utils.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/node.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/typescript.inc.sh"
|
||||
|
||||
builder_describe "Build Keyman kmc keyboard-info Compiler module" \
|
||||
"@/common/web/langtags" \
|
||||
|
|
@ -35,7 +36,7 @@ builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo
|
|||
builder_run_action configure node_select_version_and_npm_ci
|
||||
builder_run_action build tsc --build
|
||||
builder_run_action api api-extractor run --local --verbose
|
||||
builder_run_action test builder_do_typescript_tests
|
||||
builder_run_action test typescript_run_eslint_mocha_tests
|
||||
|
||||
#-------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
|||
|
||||
. "$KEYMAN_ROOT/resources/build/utils.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/node.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/typescript.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh"
|
||||
|
||||
builder_describe "Keyman Developer Compiler Module for .kmn to .kmx" \
|
||||
|
|
@ -64,7 +65,7 @@ function do_build() {
|
|||
|
||||
function do_test() {
|
||||
copy_deps
|
||||
builder_do_typescript_tests 80
|
||||
typescript_run_eslint_mocha_tests 80
|
||||
}
|
||||
|
||||
builder_run_action build do_build
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
|||
|
||||
. "$KEYMAN_ROOT/resources/build/utils.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/node.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/typescript.inc.sh"
|
||||
|
||||
builder_describe "Keyman kmc Keyboard Compiler module" \
|
||||
"@/common/web/keyman-version" \
|
||||
|
|
@ -88,7 +89,7 @@ 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 builder_do_typescript_tests 90
|
||||
builder_run_action test typescript_run_eslint_mocha_tests 90
|
||||
|
||||
#-------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
|||
|
||||
. "$KEYMAN_ROOT/resources/build/utils.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/node.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/typescript.inc.sh"
|
||||
|
||||
builder_describe "Build Keyman kmc Lexical Model model-info Compiler module" \
|
||||
"@/common/web/types" \
|
||||
|
|
@ -32,7 +33,7 @@ builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo
|
|||
builder_run_action configure node_select_version_and_npm_ci
|
||||
builder_run_action build tsc --build
|
||||
builder_run_action api api-extractor run --local --verbose
|
||||
builder_run_action test builder_do_typescript_tests 55
|
||||
builder_run_action test typescript_run_eslint_mocha_tests 55
|
||||
|
||||
#-------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
|||
|
||||
. "$KEYMAN_ROOT/resources/build/utils.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/node.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/typescript.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh"
|
||||
|
||||
builder_describe "Keyman kmc Lexical Model Compiler module" \
|
||||
|
|
@ -40,6 +41,6 @@ builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo
|
|||
builder_run_action configure node_select_version_and_npm_ci
|
||||
builder_run_action build do_build
|
||||
builder_run_action api api-extractor run --local --verbose
|
||||
builder_run_action test builder_do_typescript_tests
|
||||
builder_run_action test typescript_run_eslint_mocha_tests
|
||||
builder_run_action publish builder_publish_npm
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
|||
|
||||
. "$KEYMAN_ROOT/resources/build/utils.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/node.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/typescript.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh"
|
||||
|
||||
builder_describe "Build Keyman kmc Package Compiler module" \
|
||||
|
|
@ -37,5 +38,5 @@ builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo
|
|||
builder_run_action configure node_select_version_and_npm_ci
|
||||
builder_run_action build tsc --build
|
||||
builder_run_action api api-extractor run --local --verbose
|
||||
builder_run_action test builder_do_typescript_tests
|
||||
builder_run_action test typescript_run_eslint_mocha_tests
|
||||
builder_run_action publish builder_publish_npm
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
|||
. "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/utils.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/node.inc.sh"
|
||||
. "$KEYMAN_ROOT/resources/build/typescript.inc.sh"
|
||||
. "$KEYMAN_ROOT/developer/src/packages.inc.sh"
|
||||
|
||||
builder_describe "Build Keyman Keyboard Compiler kmc" \
|
||||
|
|
@ -55,7 +56,7 @@ function do_build() {
|
|||
#-------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function do_test() {
|
||||
builder_do_typescript_tests 50
|
||||
typescript_run_eslint_mocha_tests 50
|
||||
./test/command-line-tests.sh test
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1228,7 +1228,7 @@ fi
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
## `builder_do_typescript_tests` function
|
||||
## `typescript_run_eslint_mocha_tests` function
|
||||
|
||||
Runs eslint, builds tests, and then runs tests with mocha + c8 (coverage)
|
||||
|
||||
|
|
@ -1238,7 +1238,7 @@ be moved to builder.typescript.inc.sh in the future.
|
|||
### Usage
|
||||
|
||||
```bash
|
||||
builder_run_action test builder_do_typescript_tests [coverage_threshold]
|
||||
builder_run_action test typescript_run_eslint_mocha_tests [coverage_threshold]
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
|
|
|||
43
resources/build/typescript.inc.sh
Normal file
43
resources/build/typescript.inc.sh
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# shellcheck shell=bash
|
||||
# Keyman is copyright (C) SIL Global. MIT License.
|
||||
|
||||
#
|
||||
# Runs eslint, builds tests, and then runs tests with mocha + c8 (coverage)
|
||||
#
|
||||
# Usage:
|
||||
# builder_run_action test typescript_run_eslint_mocha_tests [coverage_threshold]
|
||||
# Parameters:
|
||||
# 1: coverage_threshold optional, minimum coverage for c8 to pass tests,
|
||||
# defaults to 90 (percent)
|
||||
typescript_run_eslint_mocha_tests() {
|
||||
local MOCHA_FLAGS=
|
||||
|
||||
if builder_is_running_on_teamcity; 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"
|
||||
else
|
||||
# Seems like a bug in TeamCity reporter if we don't list default thresholds,
|
||||
# see #13418.
|
||||
#
|
||||
# Making branch and function thresholds slightly lower, because the default
|
||||
# for c8 is 0 for these anyway.
|
||||
THRESHOLD_PARAMS="--lines 90 --statements 90 --branches 80 --functions 80"
|
||||
fi
|
||||
|
||||
c8 --reporter=lcov --reporter=text --exclude-after-remap --check-coverage $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
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
_utils_inc_sh=1
|
||||
|
||||
# Allows for a quick macOS check for those scripts requiring a macOS environment.
|
||||
# TODO: move to resources/build/mac/<something.inc.sh>
|
||||
verify_on_mac() {
|
||||
if ! builder_is_macos; then
|
||||
builder_die "This build script will only run in a Mac environment."
|
||||
|
|
@ -25,6 +26,7 @@ verify_on_mac() {
|
|||
# 4: ARTIFACT_TYPE File extension of artifact, without initial period (e.g. tar.gz)
|
||||
# 5: PLATFORM Target platform for artifact
|
||||
#
|
||||
# TODO: Move to CI include?
|
||||
write_download_info() {
|
||||
local UPLOAD_DIR="$1"
|
||||
local ARTIFACT_FILENAME="$2"
|
||||
|
|
@ -137,46 +139,3 @@ check-markdown() {
|
|||
node "$KEYMAN_ROOT/resources/tools/check-markdown" --root "$1"
|
||||
}
|
||||
|
||||
#
|
||||
# Runs eslint, builds tests, and then runs tests with mocha + c8 (coverage)
|
||||
#
|
||||
# Usage:
|
||||
# builder_run_action test builder_do_typescript_tests [coverage_threshold]
|
||||
# Parameters:
|
||||
# 1: coverage_threshold optional, minimum coverage for c8 to pass tests,
|
||||
# defaults to 90 (percent)
|
||||
#
|
||||
# TODO: move to builder.typescript.inc.sh when this is established, rename to
|
||||
# builder_typescript_do_tests
|
||||
builder_do_typescript_tests() {
|
||||
local MOCHA_FLAGS=
|
||||
|
||||
if builder_is_running_on_teamcity; 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"
|
||||
else
|
||||
# Seems like a bug in TeamCity reporter if we don't list default thresholds,
|
||||
# see #13418.
|
||||
#
|
||||
# Making branch and function thresholds slightly lower, because the default
|
||||
# for c8 is 0 for these anyway.
|
||||
THRESHOLD_PARAMS="--lines 90 --statements 90 --branches 80 --functions 80"
|
||||
fi
|
||||
|
||||
c8 --reporter=lcov --reporter=text --exclude-after-remap --check-coverage $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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue