diff --git a/.github/workflows/.zipignore b/.github/workflows/.zipignore new file mode 100644 index 000000000..d72c7ba23 --- /dev/null +++ b/.github/workflows/.zipignore @@ -0,0 +1,3 @@ +.git/* +*/.git/* +*/.github/* diff --git a/.github/workflows/_pr_entrypoint.yaml b/.github/workflows/_pr_entrypoint.yaml index f2688d8d1..930182c7e 100644 --- a/.github/workflows/_pr_entrypoint.yaml +++ b/.github/workflows/_pr_entrypoint.yaml @@ -138,9 +138,10 @@ jobs: ENABLE_COVER_COMPILE: 1 run: | make ensure-rebar3 - make ${PROFILE} - make test-compile - zip -ryq $PROFILE.zip . + make ${PROFILE}-compile test-compile + echo "PROFILE=${PROFILE}" | tee -a .env + echo "PKG_VSN=$(./pkg-vsn.sh ${PROFILE})" | tee -a .env + zip -ryq -x@.github/workflows/.zipignore $PROFILE.zip . - uses: actions/upload-artifact@v3 with: name: ${{ matrix.profile }} diff --git a/.github/workflows/_push-entrypoint.yaml b/.github/workflows/_push-entrypoint.yaml index a8a01fb45..b2d7e2c4a 100644 --- a/.github/workflows/_push-entrypoint.yaml +++ b/.github/workflows/_push-entrypoint.yaml @@ -149,7 +149,9 @@ jobs: ENABLE_COVER_COMPILE: 1 run: | make $PROFILE - zip -ryq $PROFILE.zip . + echo "PROFILE=${PROFILE}" | tee -a .env + echo "PKG_VSN=$(./pkg-vsn.sh ${PROFILE})" | tee -a .env + zip -ryq -x@.github/workflows/.zipignore $PROFILE.zip . - uses: actions/upload-artifact@v3 with: name: ${{ matrix.profile }} diff --git a/.github/workflows/run_conf_tests.yaml b/.github/workflows/run_conf_tests.yaml index e218ae838..9a9367c70 100644 --- a/.github/workflows/run_conf_tests.yaml +++ b/.github/workflows/run_conf_tests.yaml @@ -21,8 +21,6 @@ jobs: run_conf_tests: runs-on: ${{ fromJSON(inputs.runner_labels) }} container: ${{ inputs.builder }} - env: - PROFILE: ${{ matrix.profile }} strategy: fail-fast: false matrix: @@ -37,6 +35,8 @@ jobs: run: | unzip -o -q ${{ matrix.profile }}.zip git config --global --add safe.directory "$GITHUB_WORKSPACE" + - run: cat .env | tee -a $GITHUB_ENV + - run: make ${{ matrix.profile }} - run: ./scripts/test/check-example-configs.sh - run: ./scripts/conf-test/run.sh - name: print erlang log diff --git a/.github/workflows/static_checks.yaml b/.github/workflows/static_checks.yaml index 98c718829..f0b8dbd6c 100644 --- a/.github/workflows/static_checks.yaml +++ b/.github/workflows/static_checks.yaml @@ -46,7 +46,6 @@ jobs: key: rebar3-dialyzer-plt-${{ matrix.profile }}-${{ matrix.otp }}-${{ hashFiles('rebar.*', 'apps/*/rebar.*') }} restore-keys: | rebar3-dialyzer-plt-${{ matrix.profile }}-${{ matrix.otp }}- + - run: cat .env | tee -a $GITHUB_ENV - name: run static checks - env: - PROFILE: ${{ matrix.profile }} run: make static_checks diff --git a/apps/emqx/test/emqx_bpapi_static_checks.erl b/apps/emqx/test/emqx_bpapi_static_checks.erl index 6766912c0..657776317 100644 --- a/apps/emqx/test/emqx_bpapi_static_checks.erl +++ b/apps/emqx/test/emqx_bpapi_static_checks.erl @@ -244,19 +244,28 @@ get_param_types(Signatures, {M, F, A}) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% dump() -> - case - { - filelib:wildcard(project_root_dir() ++ "/*_plt"), - filelib:wildcard(project_root_dir() ++ "/_build/check/lib") - } - of + RootDir = project_root_dir(), + TryRelDir = RootDir ++ "/_build/check/lib", + case {filelib:wildcard(RootDir ++ "/*_plt"), filelib:wildcard(TryRelDir)} of {[PLT | _], [RelDir | _]} -> dump(#{ plt => PLT, reldir => RelDir }); - _ -> - error("failed to guess run options") + {[], _} -> + logger:error( + "No usable PLT files found in \"~s\", abort ~n" + "Try running `rebar3 as check dialyzer` at least once first", + [RootDir] + ), + error(run_failed); + {_, []} -> + logger:error( + "No built applications found in \"~s\", abort ~n" + "Try running `rebar3 as check compile` at least once first", + [TryRelDir] + ), + error(run_failed) end. %% Collect the local BPAPI modules to a dump file @@ -411,10 +420,19 @@ setnok() -> put(bpapi_ok, false). dumps_dir() -> - filename:join(project_root_dir(), "apps/emqx/test/emqx_static_checks_data"). - -project_root_dir() -> - string:trim(os:cmd("git rev-parse --show-toplevel")). + filename:join(emqx_app_dir(), "test/emqx_static_checks_data"). versions_file() -> - filename:join(project_root_dir(), "apps/emqx/priv/bpapi.versions"). + filename:join(emqx_app_dir(), "priv/bpapi.versions"). + +emqx_app_dir() -> + Info = ?MODULE:module_info(compile), + case proplists:get_value(source, Info) of + Source when is_list(Source) -> + filename:dirname(filename:dirname(Source)); + undefined -> + "apps/emqx" + end. + +project_root_dir() -> + filename:dirname(filename:dirname(emqx_app_dir())). diff --git a/scripts/check-i18n-style.escript b/scripts/check-i18n-style.escript index f48e5a513..e7e0ea42e 100755 --- a/scripts/check-i18n-style.escript +++ b/scripts/check-i18n-style.escript @@ -8,10 +8,9 @@ -define(RED, "\e[31m"). -define(RESET, "\e[39m"). -main([Files0]) -> +main(Files) -> io:format(user, "checking i18n file styles~n", []), _ = put(errors, 0), - Files = string:tokens(Files0, "\n"), ok = load_hocon(), ok = lists:foreach(fun check/1, Files), case get(errors) of diff --git a/scripts/check-i18n-style.sh b/scripts/check-i18n-style.sh index d21f43a72..b7d4d2113 100755 --- a/scripts/check-i18n-style.sh +++ b/scripts/check-i18n-style.sh @@ -3,6 +3,4 @@ set -euo pipefail cd -P -- "$(dirname -- "$0")/.." -all_files="$(git ls-files 'rel/i18n/*.hocon')" - -./scripts/check-i18n-style.escript "$all_files" +./scripts/check-i18n-style.escript rel/i18n/*.hocon diff --git a/scripts/test/check-example-configs.sh b/scripts/test/check-example-configs.sh index f71fb15eb..cffea24ce 100755 --- a/scripts/test/check-example-configs.sh +++ b/scripts/test/check-example-configs.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash set -euo pipefail -PROJ_DIR="$(git rev-parse --show-toplevel)" + +cd -P -- "$(dirname -- "$0")/../.." PROFILE="${PROFILE:-emqx}" DIR_NAME='examples' @@ -11,7 +12,7 @@ if [ "${PROFILE}" = 'emqx-enterprise' ]; then SCHEMA_MOD='emqx_enterprise_schema' fi -IFS=$'\n' read -r -d '' -a FILES < <(find "${PROJ_DIR}/rel/config/${DIR_NAME}" -name "*.example" 2>/dev/null | sort && printf '\0') +IFS=$'\n' read -r -d '' -a FILES < <(find "rel/config/${DIR_NAME}" -name "*.example" 2>/dev/null | sort && printf '\0') prepare_erl_libs() { local libs_dir="$1" @@ -30,7 +31,7 @@ prepare_erl_libs() { } # This is needed when checking schema -export EMQX_ETC_DIR="${PROJ_DIR}/apps/emqx/etc" +export EMQX_ETC_DIR="apps/emqx/etc" prepare_erl_libs "_build/$PROFILE/lib"