| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- #!/usr/bin/env bash
- set -euo pipefail
- # ensure dir
- cd -P -- "$(dirname -- "$0")/.."
- help() {
- echo
- echo "-h|--help: To display this usage info"
- echo "--ci: Print apps in json format for github ci matrix"
- }
- MODE='list'
- while [ "$#" -gt 0 ]; do
- case $1 in
- -h|--help)
- help
- exit 0
- ;;
- --ci)
- MODE='ci'
- shift 1
- ;;
- *)
- echo "unknown option $1"
- exit 1
- ;;
- esac
- done
- if [ "$(./scripts/get-distro.sh)" = 'windows' ]; then
- # Otherwise windows may resolve to find.exe
- FIND="/usr/bin/find"
- else
- FIND='find'
- fi
- find_app() {
- local appdir="$1"
- "$FIND" "${appdir}" -mindepth 1 -maxdepth 1 -type d
- }
- APPS_ALL="$(find_app 'apps')"
- if [ "$MODE" = 'list' ]; then
- echo "${APPS_ALL}"
- exit 0
- fi
- ##################################################
- ###### now deal with the github action's matrix.
- ##################################################
- format_app_entry() {
- local groups="$2"
- local group=0
- while [ "$groups" -gt $group ]; do
- if [ $group -gt 0 ]; then
- echo ", "
- fi
- group=$(( group + 1 ))
- ## prefix is for github actions (they don't like slash in variables)
- local prefix=${1//\//_}
- echo -n -e "$(
- cat <<END
- {"app": "${1}", "suitegroup": "${group}_${groups}", "profile": "${3}", "runner": "${4}", "prefix": "${prefix}"}
- END
- )"
- done
- }
- matrix() {
- local runner
- local profile
- local entries=()
- for app in ${APPS_ALL}; do
- if [ -f "${app}/docker-ct" ]; then
- runner="docker"
- else
- runner="host"
- fi
- case "${app}" in
- apps/emqx)
- entries+=("$(format_app_entry "$app" 5 emqx "$runner")")
- entries+=("$(format_app_entry "$app" 5 emqx-enterprise "$runner")")
- ;;
- apps/emqx_bridge)
- entries+=("$(format_app_entry "$app" 1 emqx "$runner")")
- entries+=("$(format_app_entry "$app" 1 emqx-enterprise "$runner")")
- ;;
- apps/emqx_connector)
- entries+=("$(format_app_entry "$app" 1 emqx "$runner")")
- entries+=("$(format_app_entry "$app" 1 emqx-enterprise "$runner")")
- ;;
- apps/emqx_dashboard)
- entries+=("$(format_app_entry "$app" 1 emqx "$runner")")
- entries+=("$(format_app_entry "$app" 1 emqx-enterprise "$runner")")
- ;;
- apps/emqx_rule_engine)
- entries+=("$(format_app_entry "$app" 1 emqx "$runner")")
- entries+=("$(format_app_entry "$app" 1 emqx-enterprise "$runner")")
- ;;
- apps/emqx_management)
- entries+=("$(format_app_entry "$app" 1 emqx "$runner")")
- entries+=("$(format_app_entry "$app" 1 emqx-enterprise "$runner")")
- ;;
- apps/*)
- if [[ -f "${app}/BSL.txt" ]]; then
- profile='emqx-enterprise'
- else
- profile='emqx'
- fi
- entries+=("$(format_app_entry "$app" 1 "$profile" "$runner")")
- ;;
- *)
- echo "unknown app: $app"
- exit 1
- ;;
- esac
- done
- echo -n "[$(IFS=,; echo "${entries[*]}")]"
- }
- matrix
|