diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 23d6e2d5..922f4bcd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,16 +11,6 @@ repos: fail_fast: true stages: [commit] - - repo: local - hooks: - - id: fixShebangExecutionBit - name: fixShebangExecutionBit - entry: bash -c './bin/findShebangFiles chmod +x' - language: system - always_run: true - fail_fast: true - stages: [commit] - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: @@ -76,31 +66,26 @@ repos: - id: prettier stages: [commit] - - repo: local + - repo: https://github.com/fchastanet/bash-tools-framework + rev: 1.0.4 hooks: + - id: fixShebangExecutionBit + - id: frameworkLinter + args: + [ + --expected-warnings-count, + '6', + --format, + plain, + --theme, + default-force, + ] - id: shellcheckLint - name: shellcheckLint - entry: bash -c './bin/shellcheckLint --staged -f tty' - language: system - always_run: true - fail_fast: true - stages: [commit] - repo: local hooks: - - id: frameworkLint - name: frameworkLint - entry: | - bash -c './bin/frameworkLint --verbose --expected-warnings-count 6' - language: system - always_run: true - fail_fast: true - stages: [commit] - - - repo: local - hooks: - - id: build-sh-files - name: build-sh-files + - id: buildShFiles + name: build sh files entry: bash -c './bin/buildBinFiles --ignore-missing' language: system always_run: true @@ -110,8 +95,8 @@ repos: - repo: local hooks: - - id: build-doc-files - name: build-doc-files + - id: buildDocFiles + name: build doc files entry: bash -c './bin/doc' language: system always_run: true @@ -119,51 +104,11 @@ repos: fail_fast: true stages: [push] - - repo: local - hooks: - - id: run-unit-tests - name: run-unit-tests - entry: bash -c './bin/test -r src -j 1' - language: system - always_run: true - require_serial: true - fail_fast: true - stages: [commit] - - - repo: local - hooks: - - id: megalinter-check-version - name: megalinter-check-version - language: system - entry: ./bin/megalinter - args: - [ - --image, - 'oxsecurity/megalinter-terraform:v7.5.0', - --check-megalinter-version, - ] - pass_filenames: false - always_run: true - fail_fast: true - stages: [push] - - - repo: local + - repo: https://github.com/fchastanet/bash-tools-framework + rev: 1.0.4 hooks: + - id: runUnitTests + - id: plantuml + - id: megalinterCheckVersion - id: megalinter - name: megalinter - language: system - entry: ./bin/megalinter - args: - [ - --image, - 'oxsecurity/megalinter-terraform:v7.5.0', - --config-file, - '.mega-linter-light.yml', - --fix, - ] - pass_filenames: false - require_serial: true - always_run: true - fail_fast: true - verbose: true - stages: [push] + - id: megalinterGithubAction diff --git a/src/_binaries/DbImport/dbImportProfile.bats b/src/_binaries/DbImport/dbImportProfile.bats index 1ace02ba..320a65a8 100755 --- a/src/_binaries/DbImport/dbImportProfile.bats +++ b/src/_binaries/DbImport/dbImportProfile.bats @@ -101,7 +101,8 @@ function Database::dbImportProfile::remote_db_fully_functional_default_ratio { # assert_output --partial "Profile generated - 1/3 tables bigger than 70% of max table size (29MB) automatically excluded" diff >&3 "${HOME}/tableSizeQuery.sql" "${BATS_TEST_DIRNAME}/testsData/expectedDbImportProfileTableListQuery.sql" [[ -f "${HOME}/.bash-tools/dbImportProfiles/auto_default.local_fromDb.sh" ]] - [[ "$(md5sum "${HOME}/.bash-tools/dbImportProfiles/auto_default.local_fromDb.sh" | awk '{ print $1 }')" == "$(md5sum "${BATS_TEST_DIRNAME}/testsData/auto_default.local_fromDb_70.sh" | awk '{ print $1 }')" ]] + diff -u "${HOME}/.bash-tools/dbImportProfiles/auto_default.local_fromDb.sh" \ + "${BATS_TEST_DIRNAME}/testsData/auto_default.local_fromDb_70.sh" } function Database::dbImportProfile::remote_db_fully_functional_ratio_20 { #@test @@ -114,10 +115,14 @@ function Database::dbImportProfile::remote_db_fully_functional_ratio_20 { #@test run "${binDir}/dbImportProfile" --verbose -f default.local -r 20 fromDb 2>&1 [[ -f "${HOME}/tableSizeQuery.sql" ]] - assert_output --partial "Profile generated - 2/3 tables bigger than 20% of max table size (29MB) automatically excluded" + assert_lines_count 3 + assert_line --index 0 --partial "INFO - Using from dsn" + assert_line --index 1 --partial "Profile generated - 2/3 tables bigger than 20% of max table size (29MB) automatically excluded" + assert_line --index 2 --partial "INFO - File saved in" [[ "$(md5sum "${HOME}/tableSizeQuery.sql" | awk '{ print $1 }')" == "$(md5sum "${BATS_TEST_DIRNAME}/testsData/expectedDbImportProfileTableListQuery.sql" | awk '{ print $1 }')" ]] [[ -f "${HOME}/.bash-tools/dbImportProfiles/auto_default.local_fromDb.sh" ]] - [[ "$(md5sum "${HOME}/.bash-tools/dbImportProfiles/auto_default.local_fromDb.sh" | awk '{ print $1 }')" == "$(md5sum "${BATS_TEST_DIRNAME}/testsData/auto_default.local_fromDb_20.sh" | awk '{ print $1 }')" ]] + diff -u "${HOME}/.bash-tools/dbImportProfiles/auto_default.local_fromDb.sh" \ + "${BATS_TEST_DIRNAME}/testsData/auto_default.local_fromDb_20.sh" } diff --git a/src/_binaries/DbImport/testsData/auto_default.local_fromDb_20.sh b/src/_binaries/DbImport/testsData/auto_default.local_fromDb_20.sh index ed42667b..726241d0 100755 --- a/src/_binaries/DbImport/testsData/auto_default.local_fromDb_20.sh +++ b/src/_binaries/DbImport/testsData/auto_default.local_fromDb_20.sh @@ -2,7 +2,7 @@ # cat represents the whole list of tables cat | - grep -v '^table1$' | # table size 29MB - grep -v '^table2$' | # table size 10MB - # grep -v '^table3$' | # table size 4MB - cat + grep -v '^table1$' | # table size 29MB + grep -v '^table2$' | # table size 10MB +# grep -v '^table3$' | # table size 4MB +cat diff --git a/src/_binaries/DbImport/testsData/auto_default.local_fromDb_70.sh b/src/_binaries/DbImport/testsData/auto_default.local_fromDb_70.sh index c153018c..1a491a9e 100755 --- a/src/_binaries/DbImport/testsData/auto_default.local_fromDb_70.sh +++ b/src/_binaries/DbImport/testsData/auto_default.local_fromDb_70.sh @@ -2,7 +2,7 @@ # cat represents the whole list of tables cat | - grep -v '^table1$' | # table size 29MB - # grep -v '^table2$' | # table size 10MB - # grep -v '^table3$' | # table size 4MB - cat + grep -v '^table1$' | # table size 29MB +# grep -v '^table2$' | # table size 10MB +# grep -v '^table3$' | # table size 4MB +cat diff --git a/src/_binaries/Utils/testsData/waitForIt.help.txt b/src/_binaries/Utils/testsData/waitForIt.help.txt index fbe8505e..cc8da451 100644 --- a/src/_binaries/Utils/testsData/waitForIt.help.txt +++ b/src/_binaries/Utils/testsData/waitForIt.help.txt @@ -1,12 +1,12 @@ DESCRIPTION: wait for host:port to be available USAGE: waitForIt [OPTIONS] [ARGUMENTS] -USAGE: waitForIt --host|-i --port|-p +USAGE: waitForIt [--timeout|-t ] --host|-i --port|-p [--algorithm|--algo ] [--exec-command-on-success-only|--strict|-s] - [--timeout|-t ] [--bash-framework-config ] [--config] - [--verbose|-v] [-vv] [-vvv] [--env-file ] [--no-color] - [--theme ] [--help|-h] [--version] [--quiet|-q] [--log-level ] - [--log-file ] [--display-level ] + [--bash-framework-config ] [--config] [--verbose|-v] [-vv] [-vvv] + [--env-file ] [--no-color] [--theme ] [--help|-h] [--version] + [--quiet|-q] [--log-level ] [--log-file ] + [--display-level ] ARGUMENTS: [commandArgs {list} (optional)] @@ -14,6 +14,9 @@ f no command provided. OPTIONS: + --timeout, -t  {single} + Timeout in seconds, zero for no timeout. + Default value: 15 --host, -i  {single} (mandatory) Host or IP under test. --port, -p  {single} (mandatory) @@ -23,9 +26,6 @@ n based on commands availability and timeout option value). --exec-command-on-success-only, --strict, -s {single} Only execute sub-command if the test succeeds. - --timeout, -t  {single} - Timeout in seconds, zero for no timeout. - Default value: 15 GLOBAL OPTIONS: --bash-framework-config  {single}