mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-27 00:21:01 -05:00
d2d73347d3
- Move USE_FIND_ALGORITHM and VALIDATE_ALL_CODEBASE validation in a dedicated function (ValidateFindMode). - Move ANSIBLE_DIRECTORY validation to a dedicated function (ValidateAnsibleDirectory). - Move VALIDATE_xxxx variables validation to a dedicated function (ValidateValidationVariables). - Mark ANY_SET, ANY_TRUE, ANY_FALSE as local because we don't need to reference them anywhere outside ValidateValidationVariables. - Add some debug statements in validation functions. - Merge the loops to initialize VALIDATE_xxx variables and to print enable/disable language debug messages. - Add tests for these validation functions. - Add test start message for all tests.
60 lines
1.7 KiB
Bash
Executable file
60 lines
1.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
# shellcheck disable=SC2034
|
|
CREATE_LOG_FILE=false
|
|
# Default log level
|
|
# shellcheck disable=SC2034
|
|
LOG_LEVEL="DEBUG"
|
|
|
|
# shellcheck source=/dev/null
|
|
source "lib/functions/log.sh"
|
|
|
|
# shellcheck source=/dev/null
|
|
source "lib/functions/validation.sh"
|
|
# shellcheck source=/dev/null
|
|
source "lib/functions/githubEvent.sh"
|
|
|
|
function GetGithubPushEventCommitCountTest() {
|
|
local FUNCTION_NAME
|
|
FUNCTION_NAME="${FUNCNAME[0]}"
|
|
info "${FUNCTION_NAME} start"
|
|
|
|
local GITHUB_EVENT_COMMIT_COUNT
|
|
GITHUB_EVENT_COMMIT_COUNT=$(GetGithubPushEventCommitCount "test/data/github-event/github-event-push.json")
|
|
|
|
debug "GITHUB_EVENT_COMMIT_COUNT: ${GITHUB_EVENT_COMMIT_COUNT}"
|
|
|
|
if [ "${GITHUB_EVENT_COMMIT_COUNT}" -ne 1 ]; then
|
|
fatal "GITHUB_EVENT_COMMIT_COUNT is not equal to 1: ${GITHUB_EVENT_COMMIT_COUNT}"
|
|
fi
|
|
|
|
notice "${FUNCTION_NAME} PASS"
|
|
}
|
|
|
|
GetGithubPushEventCommitCountTest
|
|
|
|
function GetGithubRepositoryDefaultBranchTest() {
|
|
local FUNCTION_NAME
|
|
FUNCTION_NAME="${FUNCNAME[0]}"
|
|
info "${FUNCTION_NAME} start"
|
|
|
|
local GITHUB_REPOSITORY_DEFAULT_BRANCH
|
|
GITHUB_REPOSITORY_DEFAULT_BRANCH=$(GetGithubRepositoryDefaultBranch "test/data/github-event/github-event-push.json")
|
|
|
|
debug "GITHUB_REPOSITORY_DEFAULT_BRANCH: ${GITHUB_REPOSITORY_DEFAULT_BRANCH}"
|
|
|
|
local EXPECTED_GITHUB_REPOSITORY_DEFAULT_BRANCH
|
|
EXPECTED_GITHUB_REPOSITORY_DEFAULT_BRANCH="main"
|
|
|
|
if [ "${GITHUB_REPOSITORY_DEFAULT_BRANCH}" != "${EXPECTED_GITHUB_REPOSITORY_DEFAULT_BRANCH}" ]; then
|
|
fatal "GITHUB_REPOSITORY_DEFAULT_BRANCH (${GITHUB_REPOSITORY_DEFAULT_BRANCH}) is not equal to: ${EXPECTED_GITHUB_REPOSITORY_DEFAULT_BRANCH}"
|
|
fi
|
|
|
|
notice "${FUNCTION_NAME} PASS"
|
|
}
|
|
|
|
GetGithubRepositoryDefaultBranchTest
|