Skip to content

Commit

Permalink
feat: get_flavor_from_git
Browse files Browse the repository at this point in the history
  • Loading branch information
robinbourianes-kalisio committed May 16, 2024
1 parent e060cd7 commit fa6e4b4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
24 changes: 24 additions & 0 deletions kash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,30 @@ load_value_files() {
### Kalisio
###

# Returns the kalisio flavor (prod, test, dev) according to current branch/tag name
# Expected args:
# 1. the repository root folder
get_flavor_from_git() {
local REPO_DIR=$1
# Matches 'test' but also 'test-v1.2'
local TEST_FLAVOR_REGEX="^test(-v[0-9]+\.[0-9]+)?$"
# Only matches 'prod-v1.2.3'
local PROD_FLAVOR_REGEX="^prod-v[0-9]+\.[0-9]+\.[0-9]+$"

local GIT_TAG
GIT_TAG=$(get_git_tag "$REPO_DIR")
local GIT_BRANCH
GIT_BRANCH=$(get_git_branch "$REPO_DIR")

if [[ "$GIT_TAG" =~ $PROD_FLAVOR_REGEX ]]; then
printf "prod"
elif [[ "$GIT_BRANCH" =~ $TEST_FLAVOR_REGEX ]]; then
printf "test"
else
printf "dev"
fi
}

# Runs kli in a separate folder.
# Expected args:
# 1. the folder where to install everything
Expand Down
4 changes: 4 additions & 0 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ setup_workspace "$TMP_DIR/fake" "https://github.com/kalisio/kApp.git" \
[ ! -d "$TMP_DIR/fake/feathers-s3" ] && exit 1
[ ! -d "$TMP_DIR/fake/feathers-import-export" ] && exit 1

[ "$(get_flavor_from_git "$TMP_DIR/kApp.master" )" != "dev" ] && exit 1
[ "$(get_flavor_from_git "$TMP_DIR/kApp.v1.3" )" != "test" ] && exit 1
[ "$(get_flavor_from_git "$TMP_DIR/kApp.v1.3.0" )" != "prod" ] && exit 1

## App helpers

init_app_infos "$TMP_DIR/kApp.master" "$TMP_DIR/kli"
Expand Down

0 comments on commit fa6e4b4

Please sign in to comment.