refactor(Makefile): support download enterprise dashboard download

This commit is contained in:
Zaiming (Stone) Shi 2022-08-12 13:17:22 +02:00
parent c246e758be
commit c82a05a0e7
4 changed files with 49 additions and 8 deletions

View File

@ -9,6 +9,7 @@ export EMQX_DEFAULT_RUNNER = debian:11-slim
export OTP_VSN ?= $(shell $(CURDIR)/scripts/get-otp-vsn.sh)
export ELIXIR_VSN ?= $(shell $(CURDIR)/scripts/get-elixir-vsn.sh)
export EMQX_DASHBOARD_VERSION ?= v1.0.6
export EMQX_EE_DASHBOARD_VERSION ?= e1.0.0
export EMQX_REL_FORM ?= tgz
export QUICER_DOWNLOAD_FROM_RELEASE = 1
ifeq ($(OS),Windows_NT)
@ -56,10 +57,6 @@ mix-deps-get: $(ELIXIR_COMMON_DEPS)
$(REBAR): ensure-rebar3
.PHONY: get-dashboard
get-dashboard:
@$(SCRIPTS)/get-dashboard.sh
.PHONY: eunit
eunit: $(REBAR) conf-segs
@ENABLE_COVER_COMPILE=1 $(REBAR) eunit -v -c
@ -81,7 +78,12 @@ APPS=$(shell $(CURDIR)/scripts/find-apps.sh)
## app/name-ct targets are intended for local tests hence cover is not enabled
.PHONY: $(APPS:%=%-ct)
define gen-app-ct-target
$1-ct: $(REBAR) conf-segs
$1-ct: $(REBAR)
ifeq (,$(findstring lib-ee,$1))
@./scripts/pre-compile.sh emqx
else
@./scripts/pre-compile.sh emqx-enterprise
endif
@ENABLE_COVER_COMPILE=1 $(REBAR) ct --name $(CT_NODE_NAME) -c -v --cover_export_name $(subst /,-,$1) --suite $(shell $(CURDIR)/scripts/find-suites.sh $1)
endef
$(foreach app,$(APPS),$(eval $(call gen-app-ct-target,$(app))))
@ -112,7 +114,8 @@ cover: $(REBAR)
coveralls: $(REBAR)
@ENABLE_COVER_COMPILE=1 $(REBAR) as test coveralls send
COMMON_DEPS := $(REBAR) get-dashboard conf-segs
COMMON_DEPS := $(REBAR)
ELIXIR_COMMON_DEPS := ensure-hex ensure-mix-rebar3 ensure-mix-rebar
.PHONY: $(REL_PROFILES)
@ -148,6 +151,7 @@ deps-all: $(REBAR) $(PROFILES:%=deps-%)
## which may not have the right credentials
.PHONY: $(PROFILES:%=deps-%)
$(PROFILES:%=deps-%): $(COMMON_DEPS)
@./scripts/pre-compile.sh $(@:deps-%=%)
@$(REBAR) as $(@:deps-%=%) get-deps
@rm -f rebar.lock

2
build
View File

@ -106,6 +106,7 @@ assert_no_compile_time_only_deps() {
}
make_rel() {
./scripts/pre-compile.sh $PROFILE
# compile all beams
./rebar3 as "$PROFILE" compile
# generate docs (require beam compiled), generated to etc and priv dirs
@ -116,6 +117,7 @@ make_rel() {
}
make_elixir_rel() {
./scripts/pre-compile.sh "$PROFILE"
export_release_vars "$PROFILE"
mix release --overwrite
assert_no_compile_time_only_deps

View File

@ -5,8 +5,20 @@ set -euo pipefail
# ensure dir
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
RELEASE_ASSET_FILE="emqx-dashboard.zip"
VERSION="${EMQX_DASHBOARD_VERSION}"
VERSION="${1}"
case "$VERSION" in
v*)
RELEASE_ASSET_FILE="emqx-dashboard.zip"
;;
e*)
RELEASE_ASSET_FILE="emqx-enterprise-dashboard.zip"
;;
*)
echo "Unknown version $VERSION"
exit 1
;;
esac
DASHBOARD_PATH='apps/emqx_dashboard/priv'
DASHBOARD_REPO='emqx-dashboard-web-new'
DIRECT_DOWNLOAD_URL="https://github.com/emqx/${DASHBOARD_REPO}/releases/download/${VERSION}/${RELEASE_ASSET_FILE}"

23
scripts/pre-compile.sh Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail
# NOTE: PROFILE_STR may not be exactly PROFILE (emqx or emqx-enterprise)
# it might be with suffix such as -pkg etc.
PROFILE_STR="${1}"
case "$PROFILE_STR" in
*enterprise*)
dashboard_version="$EMQX_EE_DASHBOARD_VERSION"
;;
*)
dashboard_version="$EMQX_DASHBOARD_VERSION"
;;
esac
# ensure dir
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
./scripts/get-dashboard.sh "$dashboard_version"
./scripts/merge-config.escript
./scripts/merge-i18n.escript