Skip to content

Commit

Permalink
Merge branch 'release/1.9.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
serdigital64 committed Apr 13, 2023
2 parents 65b4aaf + cf40db4 commit 6f7f6d9
Show file tree
Hide file tree
Showing 22 changed files with 1,830 additions and 783 deletions.
51 changes: 36 additions & 15 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@
# Project development environment variables
#
# * Use along with .local and .secrets
# * Source template: dot.env (v1.0.3)
# * Template version: 2.0.0
#

# Base file and directory names for building paths
DEVCS_NAME_BUILD='build'
export DEVCS_NAME_BUILD
DEVCS_NAME_TEST='test'
export DEVCS_NAME_TEST
DEVCS_NAME_SRC='src'
export DEVCS_NAME_SRC

# Base path for builds
DEVCS_BUILD="${DEVCS_ROOT}/build"
DEVCS_BUILD="${DEVCS_ROOT}/${DEVCS_NAME_BUILD}"
export DEVCS_BUILD

# Base path for documentation
DEVCS_DOCS="${DEVCS_ROOT}/docs"
export DEVCS_DOCS

# Source files
DEVCS_SRC="${DEVCS_ROOT}/src"
DEVCS_SRC="${DEVCS_ROOT}/${DEVCS_NAME_SRC}"
export DEVCS_SRC

# Test files
DEVCS_TEST="${DEVCS_ROOT}/test"
DEVCS_TEST="${DEVCS_ROOT}/${DEVCS_NAME_TEST}"
export DEVCS_TEST

# Dev/Test scripts
Expand All @@ -30,6 +34,10 @@ export DEVCS_BIN
DEVCS_LIB="${DEVCS_ROOT}/lib"
export DEVCS_LIB

# Base path for documentation
DEVCS_DOCS="${DEVCS_ROOT}/docs"
export DEVCS_DOCS

# Temporary data location
DEVCS_TMP="${DEVCS_ROOT}/.tmp"
export DEVCS_TMP
Expand All @@ -39,14 +47,27 @@ DEVCS_VAR="${DEVCS_ROOT}/.var"
export DEVCS_VAR

#
# Tools
# Project specific variables
#

DEVCS_APP_NAME='codeskel64'
export DEVCS_APP_NAME
# CICD / Tools full paths
DEVCS_CICD_BUILD="${DEVCS_BIN}/dev-build"
export DEVCS_CICD_BUILD
DEVCS_CICD_LINT="${DEVCS_BIN}/dev-lint"
export DEVCS_CICD_LINT
DEVCS_CICD_TESTMANSH="${DEVCS_LIB}/testmansh"
export DEVCS_CICD_TESTMANSH
DEVCS_CICD_BASHLIB64="${DEVCS_LIB}/bashlib64.bash"
export DEVCS_CICD_BASHLIB64

# Test / Container
DEVCS_TEST_CONTAINER='bash-test/alpine-3-bash-test:latest'
export DEVCS_TEST_CONTAINER

DEVCS_BUILD_TARGET="${DEVCS_BUILD}/${DEVCS_APP_NAME}"
export DEVCS_BUILD_TARGET
# Build / Target file name
DEVCS_BUILD_NAME='codeskel64'
export DEVCS_BUILD_NAME

DEVCS_LIB_BASHLIB64="${DEVCS_LIB}/bashlib64.bash"
export DEVCS_LIB_BASHLIB64
# Build / Target full path
DEVCS_BUILD_FULL_PATH="${DEVCS_BUILD}/${DEVCS_BUILD_NAME}"
export DEVCS_BUILD_FULL_PATH
9 changes: 5 additions & 4 deletions .github/workflows/lint_bash_testmansh.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
# Template: 1.1.0
# Template Version: 2.0.0
name: "Lint / Bash / TestManSH"

on:
push:
branches:
- "feature/*"
- "develop"
- "master"
- "main"

jobs:
lint-bash-testmansh:
Expand All @@ -18,8 +18,9 @@ jobs:
uses: "actions/checkout@main"

- name: "Prepare build environment"
run: "./bin/devcs-lib"
run: "./bin/dev-lib"

- name: "Run Bash linter"
run: "./lib/testmansh -t -c codeskel64"
shell: 'script -q -e -c "bash {0}"'
run: "./bin/dev-lint"
...
11 changes: 4 additions & 7 deletions .github/workflows/test_bash_testmansh.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# Template: 1.1.0
# Template Version: 2.0.0
name: "Test / Bash / TestManSH"

on:
Expand All @@ -10,20 +10,17 @@ on:
- "main"

jobs:
test-batscore-alpine-3:
test-batscore:
runs-on: "ubuntu-latest"
steps:

- name: "Check out repository code"
uses: "actions/checkout@main"

- name: "Prepare build environment"
run: "./bin/devcs-lib"

- name: "Build app"
run: "./bin/devcs-build"
run: "./bin/dev-lib"

- name: "Run tests"
shell: 'script -q -e -c "bash {0}"'
run: "./lib/testmansh -b -o -e bash-test/alpine-3-bash-test:latest"
run: "./bin/dev-test"
...
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ git flow init
- Download dev support scripts

```shell
./bin/devcs-lib
./bin/dev-lib
```

## Update source code
Expand All @@ -41,7 +41,7 @@ git flow init
- Build CLI:

```shell
./bin/devcs-build
./bin/dev-build
```

- Catalog
Expand Down
26 changes: 26 additions & 0 deletions bin/dev-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
#
# Assemble modular script
#
# * Use to build script from multiple sources (modular)
# * Template Version: v1.0.1
#

# shellcheck source=SCRIPTDIR/dev-set
source ./bin/dev-set || exit 1
# shellcheck source=SCRIPTDIR/../lib/bashlib64.bash
source "$DEVCS_CICD_BASHLIB64" || exit 1

# shellcheck disable=SC2154
bl64_msg_show_task "Build app (${DEVCS_BUILD_NAME})"
bl64_fs_merge_files \
'0755' \
"$BL64_VAR_DEFAULT" \
"$BL64_VAR_DEFAULT" \
"$BL64_VAR_ON" \
"$DEVCS_BUILD_FULL_PATH" \
"${DEVCS_SRC}/cli/header.bash" \
"$DEVCS_CICD_BASHLIB64" \
"${DEVCS_SRC}/cli/env.bash" \
"${DEVCS_SRC}/cli/functions.bash" \
"${DEVCS_SRC}/cli/main.bash"
4 changes: 2 additions & 2 deletions bin/devcs-lib → bin/dev-lib
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# * Template Version: v1.0.0
#

# shellcheck source=SCRIPTDIR/devcs-set
source ./bin/devcs-set || exit 1
# shellcheck source=SCRIPTDIR/dev-set
source ./bin/dev-set || exit 1

echo 'Download bash library: BashLib64'
cd "$DEVCS_LIB" &&
Expand Down
16 changes: 16 additions & 0 deletions bin/dev-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
#
# Lint shell source code
#
# * Use to lint shell source code
# * Check is done using shellcheck
# * TestManSH is used to manage linting environment
# * Template Version: v1.0.0
#

# shellcheck source=SCRIPTDIR/dev-set
source ./bin/dev-set || exit 1

# DeleteMe # Build and Lint distributable. Remove if not needed
"$DEVCS_CICD_BUILD" &&
"$DEVCS_CICD_TESTMANSH" -t -o -c "${DEVCS_NAME_BUILD}/${DEVCS_BUILD_NAME}"
44 changes: 29 additions & 15 deletions bin/devcs-set → bin/dev-set
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,77 @@
# Set development environment variables
#
# * Source this script from the project's root directory
# * Template Version: v2.0.0
# * Template Version: v3.0.0
#

#
# Functions
#

function dev_set_error() {
local msg="$1"
echo "Error: ${msg}"
return 0
}

function dev_set_message() {
local msg="$1"
[[ "$_DEV_SET_VERBOSE" == 'verbose' ]] && echo "$msg"
return 0
}

function dev_set_load_local() {
local dot_local='.local'
local dot_secrets='.secrets'

echo "Load local environment variables ($(pwd)/${dot_local})"
dev_set_message "Load local environment variables ($(pwd)/${dot_local})"
# shellcheck source=SCRIPTDIR/../.local
source "$dot_local" ||
{
echo "Error: unable to source file"
dev_set_error "unable to source file (${dot_local})"
return 1
}
dot_secrets="${DEVCS_ROOT}/${dot_secrets}"
if [[ -f "$dot_secrets" ]]; then
echo "Load local secrets (${dot_secrets})"
dev_set_message "Load local secrets (${dot_secrets})"
# shellcheck source=SCRIPTDIR/../.secrets
source "${dot_secrets}" ||
{
echo "Error: unable to source file"
dev_set_error "unable to source file (${dot_secrets})"
return 1
}
fi
}

function dev_set_load_github() {
echo "GitHub detected, setting project root (${GITHUB_WORKSPACE})"
dev_set_message "GitHub detected, setting project root (${GITHUB_WORKSPACE})"
# shellcheck disable=SC2155
export DEVCS_ROOT="$GITHUB_WORKSPACE"
}

function dev_set_load_testmansh() {
echo "Testmansh container detected, setting project root (${TESTMANSH_PROJECT_ROOT})"
dev_set_message "Testmansh container detected, setting project root (${TESTMANSH_PROJECT_ROOT})"
export DEVCS_ROOT="$TESTMANSH_PROJECT_ROOT"
}

function dev_set_load_exported() {
echo 'Read DEVCS_ROOT variable from exported shell environment'
dev_set_message 'Read DEVCS_ROOT variable from exported shell environment'
}

function dev_set_check_root() {
if [[ -z "$DEVCS_ROOT" ]]; then
echo "Error: unable to identify current repository location. Check that the variable DEVCS_ROOT is correctly set" &&
dev_set_error 'unable to identify current repository location. Check that the variable DEVCS_ROOT is correctly set' &&
return 1
fi
}

function dev_set_load_env() {
local dot_env="${DEVCS_ROOT}/.env"
echo "Load project environment variables (${dot_env})"
dev_set_message "Load project environment variables (${dot_env})"
# shellcheck source=SCRIPTDIR/../.env
source "$dot_env" ||
{
echo "Error: unable to read environment variables"
dev_set_error "unable to read environment variables (${dot_env})"
return 1
}
}
Expand All @@ -70,6 +82,8 @@ function dev_set_load_env() {
# Main
#

declare _DEV_SET_VERBOSE="${1:-no}"

# shellcheck disable=SC2154
if [[ -f ./.local ]]; then
dev_set_load_local
Expand All @@ -81,8 +95,8 @@ else
dev_set_load_exported
fi

# shellcheck disable=SC2015
dev_set_check_root &&
dev_set_load_env ||
return $?

echo 'Dev environment variables loading completed OK'
dev_set_load_env &&
dev_set_message 'Dev environment variables loading completed OK' ||
{ dev_set_error 'Failed to load Dev environment variables'; return 1; }
16 changes: 16 additions & 0 deletions bin/dev-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
#
# Run test-cases
#
# * Test cases are done using bats-core
# * TestManSH is used to manage test environment
# * Tests are located in the default path "test/batscore"
# * Template Version: v1.0.0
#

# shellcheck source=SCRIPTDIR/dev-set
source ./bin/dev-set || exit 1

# DeleteMe # Build and test distributable. Remove if not needed
"$DEVCS_CICD_BUILD" &&
"$DEVCS_CICD_TESTMANSH" -b -o -e "$DEVCS_TEST_CONTAINER"
26 changes: 0 additions & 26 deletions bin/devcs-build

This file was deleted.

Loading

0 comments on commit 6f7f6d9

Please sign in to comment.