From dee21d2ccf7fbcba0bc5b85c95fc0d586ba820c0 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Mon, 8 May 2023 10:55:16 +0200 Subject: [PATCH 1/3] build: order _build/$PROFILE/lib before 'default' profile libs --- build | 29 +++++++++++++++-------------- dev | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/build b/build index 5e396fdd2..4dd3071a1 100755 --- a/build +++ b/build @@ -91,19 +91,18 @@ log() { echo "===< $msg" } +prepare_erl_libs() { + local libs_dir="$1" + local erl_libs="${ERL_LIBS:-}" + for app in "${libs_dir}"/*; do + if [ -d "${app}/ebin" ]; then + erl_libs="${erl_libs}:${app}" + fi + done + export ERL_LIBS="$erl_libs" +} + make_docs() { - local libs_dir1 libs_dir2 libs_dir3 docdir - libs_dir1="$("$FIND" "_build/$PROFILE/lib/" -maxdepth 2 -name ebin -type d)" - if [ -d "_build/default/lib/" ]; then - libs_dir2="$("$FIND" "_build/default/lib/" -maxdepth 2 -name ebin -type d)" - else - libs_dir2='' - fi - if [ -d "_build/$PROFILE/checkouts" ]; then - libs_dir3="$("$FIND" "_build/$PROFILE/checkouts/" -maxdepth 2 -name ebin -type d 2>/dev/null || true)" - else - libs_dir3='' - fi case "$(is_enterprise "$PROFILE")" in 'yes') SCHEMA_MODULE='emqx_enterprise_schema' @@ -112,10 +111,12 @@ make_docs() { SCHEMA_MODULE='emqx_conf_schema' ;; esac - docdir="_build/docgen/$PROFILE" + prepare_erl_libs "_build/$PROFILE/checkouts" + prepare_erl_libs "_build/$PROFILE/lib" + local docdir="_build/docgen/$PROFILE" mkdir -p "$docdir" # shellcheck disable=SC2086 - erl -noshell -pa $libs_dir1 $libs_dir2 $libs_dir3 -eval \ + erl -noshell -eval \ "ok = emqx_conf:dump_schema('$docdir', $SCHEMA_MODULE), \ halt(0)." } diff --git a/dev b/dev index 8cf07cfaf..01bee1269 100755 --- a/dev +++ b/dev @@ -157,7 +157,7 @@ fi prepare_erl_libs() { local profile="$1" local libs_dir="_build/${profile}/lib" - local erl_libs='' + local erl_libs="${ERL_LIBS:-}" if [ $FORCE_COMPILE -eq 1 ] || [ ! -d "$libs_dir" ]; then make "compile-${PROFILE}" else From 382ecf9d5c96e131dc931daf89064aeea5158bba Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Wed, 24 May 2023 21:23:04 +0200 Subject: [PATCH 2/3] build: adapt ERL_LIBS dir separator for windows Using ':' in ERL_LIBS environment variable e.g. ERL_LIBS='dir1:dir2' does not work in windows, it has to be ';' --- build | 12 +++++++++++- dev | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/build b/build index 4dd3071a1..7fd171402 100755 --- a/build +++ b/build @@ -94,9 +94,19 @@ log() { prepare_erl_libs() { local libs_dir="$1" local erl_libs="${ERL_LIBS:-}" + local sep + if [ "${SYSTEM}" = 'windows' ]; then + sep=';' + else + sep=':' + fi for app in "${libs_dir}"/*; do if [ -d "${app}/ebin" ]; then - erl_libs="${erl_libs}:${app}" + if [ -n "$erl_libs" ]; then + erl_libs="${erl_libs}${sep}${app}" + else + erl_libs="${app}" + fi fi done export ERL_LIBS="$erl_libs" diff --git a/dev b/dev index 01bee1269..5087cc30f 100755 --- a/dev +++ b/dev @@ -58,6 +58,7 @@ fi export HOCON_ENV_OVERRIDE_PREFIX='EMQX_' export EMQX_LOG__FILE__DEFAULT__ENABLE='false' export EMQX_LOG__CONSOLE__ENABLE='true' +SYSTEM="$(./scripts/get-distro.sh)" EMQX_NODE_NAME="${EMQX_NODE_NAME:-emqx@127.0.0.1}" PROFILE="${PROFILE:-emqx}" FORCE_COMPILE=0 @@ -158,13 +159,23 @@ prepare_erl_libs() { local profile="$1" local libs_dir="_build/${profile}/lib" local erl_libs="${ERL_LIBS:-}" + local sep + if [ "${SYSTEM}" = 'windows' ]; then + sep=';' + else + sep=':' + fi if [ $FORCE_COMPILE -eq 1 ] || [ ! -d "$libs_dir" ]; then make "compile-${PROFILE}" else echo "Running from code in $libs_dir" fi for app in "${libs_dir}"/*; do - erl_libs="${erl_libs}:${app}" + if [ -n "$erl_libs" ]; then + erl_libs="${erl_libs}${sep}${app}" + else + erl_libs="${app}" + fi done export ERL_LIBS="$erl_libs" } From a1b8e2a42a296f1541b16bba62f934bb4bad2745 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Wed, 24 May 2023 22:14:27 +0200 Subject: [PATCH 3/3] ci: test windows build with a ping after start --- .github/workflows/build_slim_packages.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_slim_packages.yaml b/.github/workflows/build_slim_packages.yaml index 836eaf079..7e664c1c7 100644 --- a/.github/workflows/build_slim_packages.yaml +++ b/.github/workflows/build_slim_packages.yaml @@ -111,8 +111,14 @@ jobs: timeout-minutes: 5 run: | ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx start - Start-Sleep -s 5 - echo "EMQX started" + Start-Sleep -s 10 + $pingOutput = ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx ping + if ($pingOutput = 'pong') { + echo "EMQX started OK" + } else { + echo "Failed to ping EMQX $pingOutput" + Exit 1 + } ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx stop echo "EMQX stopped" ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx install