mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-23 17:13:10 +00:00
* nodejs: add tests to library * new tests * remove message splitting * fix race * docs * replace extract-zip with yauzl that it wraps (high severity issue) * fix ci tests * skip server tests on macos and win unless SMP_SERVER is set * fix win test * fix win test --------- Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
82 lines
2.1 KiB
Bash
Executable File
82 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/../.."
|
|
nodejs=packages/simplex-chat-nodejs
|
|
python_package=packages/simplex-chat-python
|
|
python=$(command -v python3 || command -v python)
|
|
temp=${RUNNER_TEMP:-$(mktemp -d)}
|
|
|
|
usage() {
|
|
echo "usage: $0 build <platform> | test | addon <platform> | publish <platform> [nodejs] [python]" >&2
|
|
exit 1
|
|
}
|
|
|
|
build_package() {
|
|
(cd packages/simplex-chat-client/types/typescript && npm install --no-audit --no-fund && npx tsc)
|
|
(cd "$nodejs" && npm install --ignore-scripts --no-save --no-audit --no-fund ../simplex-chat-client/types/typescript)
|
|
if [ -n "${1:-}" ]; then
|
|
(cd "$nodejs" && npx --yes node-gyp rebuild)
|
|
fi
|
|
(cd "$nodejs" && npx tsc && cp src/simplex.* dist)
|
|
if [ -n "${1:-}" ]; then
|
|
cp "$nodejs/build/Release/simplex.node" "$nodejs/build/simplex-chat-nodejs-$1.node"
|
|
fi
|
|
}
|
|
|
|
test_nodejs() {
|
|
(cd "$nodejs" && npx jest --forceExit)
|
|
}
|
|
|
|
test_python() {
|
|
(unset SIMPLEX_LIBS_DIR && cd "$python_package" && "$python" -m pip install -e ".[test]" && "$python" -m pytest -q)
|
|
}
|
|
|
|
case "${1:-}" in
|
|
build)
|
|
[ $# -eq 2 ] || usage
|
|
build_package "$2"
|
|
;;
|
|
test)
|
|
[ $# -eq 1 ] || usage
|
|
test_nodejs
|
|
test_python
|
|
;;
|
|
addon)
|
|
[ $# -eq 2 ] || usage
|
|
build_package "$2"
|
|
zip=simplex-chat-libs-$2.zip
|
|
"$python" scripts/ci/packages_release.py download "$LIBS_RELEASE" "$zip" "$temp/libs"
|
|
"$python" -m zipfile -e "$temp/libs/$zip" "$temp/libs"
|
|
SIMPLEX_LIBS_DIR=$temp/libs/libs test_nodejs
|
|
gh release upload "$ADDON_TAG" "$nodejs/build/simplex-chat-nodejs-$2.node" --clobber --repo "$LIBS_REPOSITORY"
|
|
;;
|
|
publish)
|
|
[ $# -ge 2 ] || usage
|
|
platform=$2
|
|
shift 2
|
|
for suite in "$@"; do
|
|
case "$suite" in
|
|
nodejs)
|
|
build_package
|
|
addon=simplex-chat-nodejs-$platform.node
|
|
"$python" scripts/ci/packages_release.py download-pinned "$addon" "$temp/addon"
|
|
mkdir -p "$nodejs/build/Release"
|
|
cp "$temp/addon/$addon" "$nodejs/build/Release/simplex.node"
|
|
test_nodejs
|
|
;;
|
|
python)
|
|
test_python
|
|
;;
|
|
*)
|
|
usage
|
|
;;
|
|
esac
|
|
done
|
|
;;
|
|
*)
|
|
usage
|
|
;;
|
|
esac
|