Skip to content

Commit

Permalink
Load environment refactoring
Browse files Browse the repository at this point in the history
new way to load env files and refactored github actions to use pre-commit hooks

tag: 1.1.5

# Breaking changes

- merged .env with `BASH_FRAMEWORK_*` variables inside .framework-config

# Bug fixes

- make command be able to be called from any directory, particularly from
  pre-commit hook directory

# Compiler changes

- use new way load env files

# Binaries changes

- deprecate usage of --env-file option in favor to --bash-framework-config

# Updated Bash framework functions

- refactored Env::requireLoad, changed the way config files are loaded.

# New Bash framework functions

# Documentation

- updated doc/guides/Options.md and doc/guides/ConfigFiles.md

# Validation/Tooling

- refactored github actions to use pre-commit hooks
- upgraded some github actions versions
- added github dependabot to update github actions
  • Loading branch information
fchastanet committed Nov 19, 2023
1 parent 7113f02 commit c5bb40f
Show file tree
Hide file tree
Showing 55 changed files with 1,164 additions and 4,043 deletions.
3 changes: 3 additions & 0 deletions .cspell/bash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,6 @@ uuidgen
DELIMS
Slatis
doesn
Facadesh
Scriptsh
SHELLCHECKLINT
31 changes: 23 additions & 8 deletions .framework-config
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
#!/usr/bin/env bash
# shellcheck disable=SC2034

REAL_SCRIPT_FILE="${REAL_SCRIPT_FILE:-$(readlink -e "$(realpath "${BASH_SOURCE[0]}")")}"
FRAMEWORK_ROOT_DIR="${FRAMEWORK_ROOT_DIR:-$(cd "$(readlink -e "${REAL_SCRIPT_FILE%/*}")/../.." && pwd -P)}"
FRAMEWORK_SRC_DIR="${FRAMEWORK_SRC_DIR:-${FRAMEWORK_ROOT_DIR}/src}"
FRAMEWORK_BIN_DIR="${FRAMEWORK_BIN_DIR:-${FRAMEWORK_ROOT_DIR}/bin}"
FRAMEWORK_VENDOR_DIR="${FRAMEWORK_VENDOR_DIR:-${FRAMEWORK_ROOT_DIR}/vendor}"
FRAMEWORK_VENDOR_BIN_DIR="${FRAMEWORK_VENDOR_BIN_DIR:-${FRAMEWORK_ROOT_DIR}/vendor/bin}"

# describe the functions that will be skipped from being imported
FRAMEWORK_FUNCTIONS_IGNORE_REGEXP='^(Namespace::functions|Functions::myFunction|Namespace::requireSomething|IMPORT::dir::file|Acquire::ForceIPv4)$'
FRAMEWORK_FUNCTIONS_IGNORE_REGEXP="${FRAMEWORK_FUNCTIONS_IGNORE_REGEXP:-^(Namespace::functions|Functions::myFunction|Namespace::requireSomething|IMPORT::dir::file|Acquire::ForceIPv4)$}"
# describe the files that do not contain function to be imported
NON_FRAMEWORK_FILES_REGEXP="(^bin/|^hooks/|.framework-config|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/_binaries|^src/_includes|^src/batsHeaders.sh$|^src/_standalone)"
NON_FRAMEWORK_FILES_REGEXP="${NON_FRAMEWORK_FILES_REGEXP:-(^bin/|^hooks/|.framework-config|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/_binaries|^src/_includes|^src/batsHeaders.sh$|^src/_standalone)}"
# describe the files that are allowed to not have an associated bats file
BATS_FILE_NOT_NEEDED_REGEXP="(^bin/|.framework-config|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/batsHeaders.sh$|^src/_includes)"
BATS_FILE_NOT_NEEDED_REGEXP="${BATS_FILE_NOT_NEEDED_REGEXP:-(^bin/|.framework-config|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/batsHeaders.sh$|^src/_includes)}"
# describe the files that are allowed to not have a function matching the filename
FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP="^bin/|^\.framework-config$|^build.sh$|\.tpl$|/testsData/|^manualTests/|\.bats$"
FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP="${FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP:-^bin/|^\.framework-config$|^build.sh$|\.tpl$|/testsData/|^manualTests/|\.bats$}"
# Source directories
FRAMEWORK_SRC_DIRS=(
"${FRAMEWORK_ROOT_DIR}/src"
)
if [[ ! -v FRAMEWORK_SRC_DIRS ]]; then
FRAMEWORK_SRC_DIRS=(
"${FRAMEWORK_ROOT_DIR}/src"
)
fi

# export here all the variables that will be used in your templates
export REPOSITORY_URL="https://github.com/fchastanet/bash-tools-framework"
export REPOSITORY_URL="${REPOSITORY_URL:-https://github.com/fchastanet/bash-tools-framework}"

BASH_FRAMEWORK_THEME="${BASH_FRAMEWORK_THEME:-default}"
BASH_FRAMEWORK_LOG_LEVEL="${BASH_FRAMEWORK_LOG_LEVEL:-0}"
BASH_FRAMEWORK_DISPLAY_LEVEL="${BASH_FRAMEWORK_DISPLAY_LEVEL:-3}"
BASH_FRAMEWORK_LOG_FILE="${BASH_FRAMEWORK_LOG_FILE:-${FRAMEWORK_ROOT_DIR}/logs/$(basename "$0").log}"
BASH_FRAMEWORK_LOG_FILE_MAX_ROTATION="${BASH_FRAMEWORK_LOG_FILE_MAX_ROTATION:-5}"
10 changes: 10 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Set update schedule for GitHub Actions

version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
# Check for updates to GitHub Actions every week
interval: 'weekly'
day: 'friday'
4 changes: 2 additions & 2 deletions .github/workflows/docsify-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: docker pull image
run: docker pull scrasnups/build:bash-tools-ubuntu-5.1
Expand Down
30 changes: 22 additions & 8 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,42 @@ jobs:
- vendor: ubuntu
bashImage: ubuntu:20.04
batsOptions: -j 30
bashTarVersion: 4.4
runPrecommitTests: false
- vendor: ubuntu
bashImage: ubuntu:20.04
bashTarVersion: 5.0
batsOptions: -j 30
runPrecommitTests: false
- vendor: ubuntu
bashImage: ubuntu:20.04
bashTarVersion: 5.1
batsOptions: -j 30
runPrecommitTests: true
- vendor: alpine
bashTarVersion: 4.4
bashImage: amd64/bash:4.4-alpine3.18
batsOptions: -j 30
runPrecommitTests: false
- vendor: alpine
bashTarVersion: 5.0
bashImage: amd64/bash:5.0-alpine3.18
batsOptions: -j 30
runPrecommitTests: false
- vendor: alpine
bashTarVersion: 5.1
bashImage: amd64/bash:5.1-alpine3.18
batsOptions: -j 30
runPrecommitTests: false
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand All @@ -55,13 +69,13 @@ jobs:

- name: Pull/Build/Push docker image
env:
BRANCH: ${{ matrix.branch }}
BRANCH: ${GITHUB_REF##*/}
run: |
./bin/buildPushDockerImage \
--vendor "${{ matrix.vendor }}" \
--bash-version "${{ matrix.bashTarVersion }}" \
--bash-base-image "${{ matrix.bashImage }}" \
--branch-name "${{ matrix.branch }}" \
--branch-name "${GITHUB_REF##*/}" \
--push -vvv
- name: Check image
Expand Down Expand Up @@ -102,7 +116,7 @@ jobs:
- name: Create Pull Request
if: matrix.runPrecommitTests && failure()
uses: peter-evans/create-pull-request@v4
uses: peter-evans/create-pull-request@v5
with:
branch: update/pre-commit-fixes
title: lint fixes
Expand All @@ -129,8 +143,8 @@ jobs:
--vendor "${{matrix.vendor}}" \
--bash-version "${{matrix.bashTarVersion}}" \
--bash-base-image "${{matrix.bashImage}}" \
--branch-name "${BRANCH}" \
${{matrix.options}} --report-formatter junit -o logs -r src --ci
--branch-name "${GITHUB_REF##*/}" \
${{matrix.batsOptions}} --report-formatter junit -o logs -r src --ci
- name: Upload Test Results
if: always()
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/precommit-autoupdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
auto-update:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -19,7 +19,7 @@ jobs:
- name: Run pre-commit autoupdate
run: pre-commit autoupdate
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
uses: peter-evans/create-pull-request@v5
with:
branch: update/pre-commit-autoupdate
title: Auto-update pre-commit hooks
Expand Down
5 changes: 5 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,14 @@ JAVASCRIPT_DEFAULT_STYLE: prettier
JAVASCRIPT_ES_CONFIG_FILE: .eslintrc.js
JAVASCRIPT_ES_FILTER_REGEX_EXCLUDE: report/

ACTION_ACTIONLINT_FILTER_REGEX_EXCLUDE: |
(?x)(
^\.github/workflows/dependabot\.yml$
)
YAML_V8R_FILTER_REGEX_EXCLUDE: |
(?x)(
^\.vscode/\.checkov\.yml|
^\.github/workflows/dependabot\.yml$|
^\.secretlintrc\.yml|
^\.grype\.yaml
)
Expand Down
26 changes: 14 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ repos:
)
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
rev: v3.1.0
hooks:
- id: prettier
exclude: ^doc/guides/Options/generate.*.md$
Expand All @@ -53,12 +53,10 @@ repos:
rev: 1.1.5
hooks:
- id: fixShebangExecutionBit
- id: fixShebangExecutionBitGithubActions
- id: awkLint
- id: shellcheckLint
- id: shellcheckLint
args: [-f, checkstyle, --xargs]
pass_filenames: true
stages: [manual]
- id: shellcheckLintGithubAction
- id: frameworkLinter
args:
[
Expand All @@ -69,6 +67,16 @@ repos:
--theme,
default-force,
]
- id: frameworkLinterGithubAction
args:
[
--expected-warnings-count,
'72',
--format,
checkstyle,
--theme,
default-force,
]
- id: plantuml
- id: buildShFiles
- id: buildShFilesGithubAction
Expand All @@ -79,13 +87,7 @@ repos:
name: build doc files
language: script
entry: bin/doc
args:
[
--bash-framework-config,
.framework-config,
--verbose,
--skip-docker-build,
]
args: [--verbose, --skip-docker-build]
pass_filenames: false
require_serial: true
always_run: true
Expand Down
Loading

0 comments on commit c5bb40f

Please sign in to comment.