Skip to content

Commit

Permalink
Migrated to bash-tools-framework 2.1.0 (#26)
Browse files Browse the repository at this point in the history
Rewrite all the binaries using bash-tools-framework 2.1.0
New bin/upgradeGithubRelease
Better validation pipeline and pre-commit config 

# Breaking changes

- Migrated to bash-tools-framework 2.1.0
- Now using .framework-config
- Removed bash-tools-framework binaries that were copied to bin directory
- moved Installers/installDockerInWsl.sh to bash-dev-env project
- Repository structure changed
  - moved binary files to src/_binaries folder
  - moved bats files in same directory as tested file
  - renamed ROOT_DIR to FRAMEWORK_ROOT_DIR or BASH_TOOLS_ROOT_DIR
  - renamed BIN_DIR to COMMAND_BIN_DIR
  - cut header.tpl in _header.tpl and _load.tpl
  - removed other _header*.tpl files
- binaries - fixed colors were replaced during compilation

# Bug fixes

- fix issue when bash-tools-framework dir does not exists yet
- fix doc - buildPushDockerImages from framework
- updated framework
  - framework refact Profiles::* to Conf::*
  - fixed REPOSITORY_URL + removed author.tpl

# Binaries changes

- added upgradeGithubRelease
- all the binaries set as v2.0 are using 
  - bash-tools-framework new facade template
  - bash-tools-framework Options capabilities
    - global options:
      - --bash-framework-config
      - --config {single}
      - --verbose, -v {single}
      - -vv {single}
      - -vvv {single}
      - --env-file <String> {list} (optional)
      - --no-color {single}
      - --theme <String> {single}
      - --help, -h {single}
      - --version {single}
      - --quiet, -q {single}
      - --log-level <String> {single}
      - --log-file <String> {single}
      - --display-level <String> {single}
    - options specifics to each binary
    - --help option automatically uses Array::wrap2 improving performances
    - options standardization
    - use of compile dynamicSrcFile/dynamicTemplateDir/dynamicSrcDir helpers
- added new unit tests
  - src/_binaries/Git/upgradeGithubRelease.bats
  - src/_binaries/Utils/waitForIt.bats
  - src/_binaries/Utils/waitForMysql.bats
  - src/_binaries/DbImport/dbImportStream.bats
  - src/_binaries/Git/gitIsAncestorOf.bats
- Removed bin/dbQueryOneDatabase directly used as embedded binary in 
  - bin/dbQueryAllDatabases
  - bin/dbScriptAllDatabases
- removed build.sh script replaced by `vendor/bash-tools-framework/bin/buildBinFiles`
- installRequirements is now just installing bash-tools-framework
  - Removed bash-tools-framework binaries that were copied to bin directory
  - all the compilation, linters, test tools are using the ones coming from 
    bash-tools-framework.
  - pages/Commands.md is no more referencing bash-tools-framework binaries.

# Documentation

- added ShellDoc::fixMarkdownToc to fix docsify navigation

# Validation/Tooling

- .pre-commit-config.yaml is now using bash-tools-framework pre-commit hooks
  - added shellcheckLint and frameworkLint
  - fixed linter issues
- migrated from megalinter 6.16.0 to megalinter 7.7
  - added several megalinter linters + applied related fixes
- github actions
  - added .github/dependabot.yml allowing to check github actions updates
  - upgraded github actions to latest versions
  - use the same strategy as bash-tools-framework using pre-commit hooks to 
    validate files
  - automatically creates pull request if updated files after pre-commit
- vscode
  - added extensions
  - added bashdb debug configuration
  • Loading branch information
fchastanet authored Dec 11, 2023
1 parent 4949079 commit ddba2b5
Show file tree
Hide file tree
Showing 245 changed files with 31,935 additions and 12,695 deletions.
2 changes: 2 additions & 0 deletions .checkov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skip-path:
- vendor
19 changes: 17 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,40 @@
".jscpd.json",
".mega-linter.yml",
".shellcheckrc",
".env"
"**/*.svg",
".env",
"**/*.help.txt"
],
"noConfigSearch": true,
"words": ["megalinter", "oxsecurity"],
"dictionaryDefinitions": [
{"name": "bashCustom", "path": ".cspell/bash.txt"},
{"name": "loremIpsum", "path": ".cspell/loremIpsum.txt"},
{"name": "config", "path": ".cspell/config.txt"},
{"name": "softwares", "path": ".cspell/softwares.txt"},
{"name": "readme", "path": ".cspell/readme.txt"},
{"name": "dirColors", "path": ".cspell/dirColors.txt"},
{"name": "plantUml", "path": ".cspell/plantUml.txt"}
],
"dictionaries": ["bash", "bashCustom", "config", "softwares", "plantUml"],
"dictionaries": [
"bash",
"bashCustom",
"config",
"softwares",
"plantUml",
"loremIpsum"
],
"languageSettings": [
{
"languageId": "dirColors",
"locale": "*",
"dictionaries": ["dirColors"]
},
{
"languageId": "loremIpsum",
"locale": "*",
"dictionaries": ["loremIpsum"]
},
{
"languageId": "bashCustom",
"locale": "*",
Expand Down
10 changes: 10 additions & 0 deletions .cspell/bash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,13 @@ Chastanet
Scrasnups
datetime
gensub
hlocalhost
uuser
ppassword
DELIMS
Facadesh
Scriptsh
noargs
exitcode
Datash
installsh
8 changes: 8 additions & 0 deletions .cspell/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,11 @@ difftool
apos
hpdy
tagname
Aftertabs
GKHF
cyclonedx
cpes
UNINDEXED
unindexed
logrus
JSONLINT
40 changes: 40 additions & 0 deletions .cspell/loremIpsum.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Lorem
ipsum
dolor
sit
amet
consectetur
adipiscing
elit
Maecenas
vel
eros
id
ipsum
lobortis
cursus
id
dignissim
turpis
Nam
pretium
placerat
nulla
in
posuere
Mauris
libero
purus
aliquet
et
commodo
quis
semper
sit
amet
sapien
Curabitur
condimentum
finibus
abitur
fini
5 changes: 5 additions & 0 deletions .cspell/softwares.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,8 @@ docsify
htmlhintrc
gitleaks
nojekyll
RUBOCOP
TRIVY
KICS
TRUFFLEHOG
GRYPE
20 changes: 20 additions & 0 deletions .ecrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"Verbose": false,
"Debug": false,
"IgnoreDefaults": false,
"SpacesAftertabs": false,
"NoColor": false,
"Exclude": [
"/testsData/"
],
"AllowedContentTypes": [],
"PassedFiles": [],
"Disable": {
"EndOfLine": false,
"Indentation": false,
"IndentSize": false,
"InsertFinalNewline": false,
"TrimTrailingWhitespace": false,
"MaxLineLength": false
}
}
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[.vscode/*.json]
indent_size = unset
18 changes: 17 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,21 @@ module.exports = {
commonjs: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
plugins: ['json'],
extends: [
'eslint:recommended',
'plugin:json/recommended',
'eslint-config-prettier',
],
rules: {
'json/*': ['error', {allowComments: false}],
},
overrides: [
{
files: ['.vscode/*.json'],
rules: {
'json/*': ['error', {allowComments: true}],
},
},
],
};
52 changes: 52 additions & 0 deletions .framework-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# shellcheck disable=SC2034

BASH_TOOLS_ROOT_DIR="$(cd -- "$(dirname -- "${CURRENT_LOADED_ENV_FILE}")" &>/dev/null && pwd -P)"
FRAMEWORK_ROOT_DIR="${BASH_TOOLS_ROOT_DIR}/vendor/bash-tools-framework"
FRAMEWORK_SRC_DIR="${FRAMEWORK_ROOT_DIR}/src"
FRAMEWORK_BIN_DIR="${FRAMEWORK_ROOT_DIR}/bin"
FRAMEWORK_VENDOR_DIR="${FRAMEWORK_ROOT_DIR}/vendor"
FRAMEWORK_VENDOR_BIN_DIR="${FRAMEWORK_VENDOR_DIR}/bin"

# allows to generate bin file in the right directory
export BASH_TOOLS_ROOT_DIR

# compile parameters
# srcFile : file that needs to be compiled
# templateDir : directory from which bash-tpl templates will be searched
# binDir : fallback bin directory in case BIN_FILE has not been provided
# rootDir : directory used to compute src file relative path
# srcDirs : additional directories where to find the functions
COMPILE_PARAMETERS=(
--src-dir "${BASH_TOOLS_ROOT_DIR}/src"
--src-dir "${FRAMEWORK_ROOT_DIR}/src"
--bin-dir "${BASH_TOOLS_ROOT_DIR}/bin"
--root-dir "${BASH_TOOLS_ROOT_DIR}"
--template-dir "${BASH_TOOLS_ROOT_DIR}/src"
)

# describe the functions that will be skipped from being imported
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="${NON_FRAMEWORK_FILES_REGEXP:-(^bin/|.framework-config|^install$|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/_binaries|^src/_includes|^src/batsHeaders.sh$|^conf/)}"
# describe the files that are allowed to not have an associated bats file
BATS_FILE_NOT_NEEDED_REGEXP="${BATS_FILE_NOT_NEEDED_REGEXP:-(^conf/|^bin/|.framework-config|^install$|.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="${FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP:-^conf/|^bin/|^\.framework-config$|\.tpl$|testsData/binaryFile$}"
# Source directories
if [[ ! -v FRAMEWORK_SRC_DIRS ]]; then
FRAMEWORK_SRC_DIRS=(
"${BASH_TOOLS_ROOT_DIR}/src"
"${FRAMEWORK_SRC_DIR}"
)
fi

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

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}"
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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'
open-pull-requests-limit: 1
28 changes: 0 additions & 28 deletions .github/workflows/buildBinFiles.sh

This file was deleted.

6 changes: 4 additions & 2 deletions .github/workflows/docsify-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
# kics-scan disable=555ab8f9-2001-455e-a077-f2d0f41e2fb9
# build and deploy Docsify site to GitHub Pages
name: Deploy Docsify

Expand Down Expand Up @@ -27,10 +28,11 @@ 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
# kics-scan ignore-line
uses: docker/setup-buildx-action@v3

- name: docker pull image
run: docker pull scrasnups/build:bash-tools-ubuntu-5.1
Expand Down
Loading

0 comments on commit ddba2b5

Please sign in to comment.