superlint/lib/functions/buildFileList.sh

505 lines
24 KiB
Bash
Raw Normal View History

2020-06-29 10:55:59 -04:00
#!/usr/bin/env bash
function IssueHintForFullGitHistory() {
info "Check that the local repository has the full history and that the repository is not shallow."
info "See https://github.com/super-linter/super-linter#get-started"
info "Is shallow repository: $(git -C "${GITHUB_WORKSPACE}" rev-parse --is-shallow-repository)"
}
function GenerateFileDiff() {
DIFF_GIT_DEFAULT_BRANCH_CMD="git -C \"${GITHUB_WORKSPACE}\" diff --diff-filter=d --name-only ${DEFAULT_BRANCH}...${GITHUB_SHA} | xargs -I % sh -c 'echo \"${GITHUB_WORKSPACE}/%\"' 2>&1"
DIFF_TREE_CMD="git -C \"${GITHUB_WORKSPACE}\" diff-tree --no-commit-id --name-only -r ${GITHUB_SHA} ${GITHUB_BEFORE_SHA} | xargs -I % sh -c 'echo \"${GITHUB_WORKSPACE}/%\"' 2>&1"
if [ "${GITHUB_EVENT_NAME:-}" == "push" ]; then
RunFileDiffCommand "${DIFF_TREE_CMD}"
if [ ${#RAW_FILE_ARRAY[@]} -eq 0 ]; then
debug "Generating the file array with diff-tree produced [0] items, trying with git diff against the default branch..."
RunFileDiffCommand "${DIFF_GIT_DEFAULT_BRANCH_CMD}"
fi
else
RunFileDiffCommand "${DIFF_GIT_DEFAULT_BRANCH_CMD}"
fi
}
function RunFileDiffCommand() {
local CMD
CMD="${1}"
debug "Generating Diff with:[$CMD]"
#################################################
# Get the Array of files changed in the commits #
#################################################
if ! CMD_OUTPUT=$(eval "set -eo pipefail; $CMD; set +eo pipefail"); then
error "Failed to get Diff with:[$CMD]"
IssueHintForFullGitHistory
fatal "Diff command output: ${CMD_OUTPUT}"
fi
mapfile -t RAW_FILE_ARRAY < <(echo -n "$CMD_OUTPUT")
}
2020-07-01 17:40:40 -04:00
function BuildFileList() {
debug "Building file list..."
2020-06-29 10:55:59 -04:00
VALIDATE_ALL_CODEBASE="${1}"
debug "VALIDATE_ALL_CODEBASE: ${VALIDATE_ALL_CODEBASE}"
TEST_CASE_RUN="${2}"
debug "TEST_CASE_RUN: ${TEST_CASE_RUN}"
if [ "${VALIDATE_ALL_CODEBASE}" == "false" ] && [ "${TEST_CASE_RUN}" != "true" ]; then
debug "Build the list of all changed files"
GenerateFileDiff
else
if [ "${USE_FIND_ALGORITHM}" == 'true' ]; then
2024-01-30 14:24:55 -05:00
debug "Populating the file list with all the files in the ${GITHUB_WORKSPACE} workspace using FIND algorithm"
if ! mapfile -t RAW_FILE_ARRAY < <(find "${GITHUB_WORKSPACE}" \
-not \( -path '*/\.git' -prune \) \
-not \( -path '*/\.pytest_cache' -prune \) \
-not \( -path '*/\.rbenv' -prune \) \
-not \( -path '*/\.terragrunt-cache' -prune \) \
-not \( -path '*/\.venv' -prune \) \
-not \( -path '*/\__pycache__' -prune \) \
-not \( -path '*/\node_modules' -prune \) \
-not -name ".DS_Store" \
-not -name "*.gif" \
-not -name "*.ico" \
-not -name "*.jpg" \
-not -name "*.jpeg" \
-not -name "*.pdf" \
-not -name "*.png" \
-not -name "*.webp" \
-not -name "*.woff" \
-not -name "*.woff2" \
-not -name "*.zip" \
-type f \
2>&1 | sort); then
fatal "Failed to get a list of changed files. USE_FIND_ALGORITHM: ${USE_FIND_ALGORITHM}"
fi
else
2024-01-30 14:24:55 -05:00
DIFF_GIT_VALIDATE_ALL_CODEBASE="git -C \"${GITHUB_WORKSPACE}\" ls-tree -r --name-only HEAD | xargs -I % sh -c \"echo ${GITHUB_WORKSPACE}/%\" 2>&1"
debug "Populating the file list with: ${DIFF_GIT_VALIDATE_ALL_CODEBASE}"
if ! mapfile -t RAW_FILE_ARRAY < <(eval "set -eo pipefail; ${DIFF_GIT_VALIDATE_ALL_CODEBASE}; set +eo pipefail"); then
fatal "Failed to get a list of changed files. USE_FIND_ALGORITHM: ${USE_FIND_ALGORITHM}"
fi
fi
2020-06-29 10:55:59 -04:00
fi
debug "RAW_FILE_ARRAY contents: ${RAW_FILE_ARRAY[*]}"
2020-06-29 10:55:59 -04:00
2020-10-14 11:31:55 -04:00
if [ ${#RAW_FILE_ARRAY[@]} -eq 0 ]; then
warn "No files were found in the GITHUB_WORKSPACE:[${GITHUB_WORKSPACE}] to lint!"
fi
####################################################
# Configure linters that scan the entire workspace #
####################################################
2024-01-30 14:24:55 -05:00
debug "Checking if we are in test mode before configuring the list of directories to lint. TEST_CASE_RUN: ${TEST_CASE_RUN}"
if [ "${TEST_CASE_RUN}" == "true" ]; then
debug "We are running in test mode."
2024-01-30 14:24:55 -05:00
debug "Adding test case directories to the list of directories to analyze with JSCPD."
DEFAULT_JSCPD_TEST_CASE_DIRECTORY="${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/jscpd"
2024-01-30 14:24:55 -05:00
# We need this for parallel
export DEFAULT_JSCPD_TEST_CASE_DIRECTORY
debug "DEFAULT_JSCPD_TEST_CASE_DIRECTORY: ${DEFAULT_JSCPD_TEST_CASE_DIRECTORY}"
2024-01-30 14:24:55 -05:00
RAW_FILE_ARRAY+=("${DEFAULT_JSCPD_TEST_CASE_DIRECTORY}/bad")
RAW_FILE_ARRAY+=("${DEFAULT_JSCPD_TEST_CASE_DIRECTORY}/good")
fi
debug "Add GITHUB_WORKSPACE (${GITHUB_WORKSPACE}) to the list of files to lint because we might need it for linters that lint the whole workspace"
RAW_FILE_ARRAY+=("${GITHUB_WORKSPACE}")
if [ -d "${ANSIBLE_DIRECTORY}" ]; then
debug "Adding ANSIBLE_DIRECTORY (${ANSIBLE_DIRECTORY}) to the list of files and directories to lint."
RAW_FILE_ARRAY+=("${ANSIBLE_DIRECTORY}")
else
2024-01-30 14:24:55 -05:00
debug "ANSIBLE_DIRECTORY (${ANSIBLE_DIRECTORY}) does NOT exist."
fi
2024-01-30 14:24:55 -05:00
local PARALLEL_RESULTS_FILE_PATH
PARALLEL_RESULTS_FILE_PATH="/tmp/super-linter-parallel-results-build-file-list.json"
debug "PARALLEL_RESULTS_FILE_PATH when building the file list: ${PARALLEL_RESULTS_FILE_PATH}"
2024-01-30 14:24:55 -05:00
local -a PARALLEL_COMMAND
PARALLEL_COMMAND=(parallel --will-cite --keep-order --max-procs "$(($(nproc) * 1))" --results "${PARALLEL_RESULTS_FILE_PATH}" --xargs)
if [ "${LOG_DEBUG}" == "true" ]; then
debug "LOG_DEBUG is enabled. Enable verbose ouput for parallel"
PARALLEL_COMMAND+=(--verbose)
fi
2024-01-30 14:24:55 -05:00
# Max number of files to categorize per process
PARALLEL_COMMAND+=(--max-lines 10)
2024-01-30 14:24:55 -05:00
PARALLEL_COMMAND+=("BuildFileArrays")
debug "PARALLEL_COMMAND to build the list of files and directories to lint: ${PARALLEL_COMMAND[*]}"
FILE_ARRAYS_DIRECTORY_PATH="$(mktemp -d)"
export FILE_ARRAYS_DIRECTORY_PATH
debug "Created FILE_ARRAYS_DIRECTORY_PATH: ${FILE_ARRAYS_DIRECTORY_PATH}"
info "Building the list of files and directories to check"
PARALLEL_COMMAND_OUTPUT=$(printf "%s\n" "${RAW_FILE_ARRAY[@]}" | "${PARALLEL_COMMAND[@]}" 2>&1)
PARALLEL_COMMAND_RETURN_CODE=$?
debug "PARALLEL_COMMAND_OUTPUT to build the file list (exit code: ${PARALLEL_COMMAND_RETURN_CODE}):\n${PARALLEL_COMMAND_OUTPUT}"
debug "Parallel output file (${PARALLEL_RESULTS_FILE_PATH}) contents when building the file list:\n$(cat "${PARALLEL_RESULTS_FILE_PATH}")"
local RESULTS_OBJECT
RESULTS_OBJECT=
if ! RESULTS_OBJECT=$(jq --raw-output -n '[inputs]' "${PARALLEL_RESULTS_FILE_PATH}"); then
2024-01-30 14:24:55 -05:00
fatal "Error loading results when building the file list: ${RESULTS_OBJECT}"
fi
debug "RESULTS_OBJECT for ${FILE_TYPE}:\n${RESULTS_OBJECT}"
local STDOUT_BUILD_FILE_LIST
# Get raw output so we can strip quotes from the data we load
if ! STDOUT_BUILD_FILE_LIST="$(jq --raw-output '.[].Stdout[:-1]' <<<"${RESULTS_OBJECT}")"; then
2024-01-30 14:24:55 -05:00
fatal "Error when loading stdout when building the file list: ${STDOUT_BUILD_FILE_LIST}"
fi
2024-01-30 14:24:55 -05:00
if [ -n "${STDOUT_BUILD_FILE_LIST}" ]; then
info "Command output when building the file list:\n------\n${STDOUT_BUILD_FILE_LIST}\n------"
else
2024-01-30 14:24:55 -05:00
debug "Stdout when building the file list is empty"
fi
local STDERR_BUILD_FILE_LIST
if ! STDERR_BUILD_FILE_LIST="$(jq --raw-output '.[].Stderr[:-1]' <<<"${RESULTS_OBJECT}")"; then
2024-01-30 14:24:55 -05:00
fatal "Error when loading stderr when building the file list:\n${STDERR_BUILD_FILE_LIST}"
fi
if [ -n "${STDERR_BUILD_FILE_LIST}" ]; then
info "Stderr when building the file list:\n------\n${STDERR_BUILD_FILE_LIST}\n------"
2024-01-30 14:24:55 -05:00
else
debug "Stderr when building the file list is empty"
fi
if [[ ${PARALLEL_COMMAND_RETURN_CODE} -ne 0 ]]; then
fatal "Error when building the list of files and directories to lint."
fi
2024-01-30 14:24:55 -05:00
################
# Footer print #
################
info "Successfully gathered list of files..."
}
BuildFileArrays() {
local -a RAW_FILE_ARRAY
RAW_FILE_ARRAY=("$@")
debug "Categorizing the following files: ${RAW_FILE_ARRAY[*]}"
debug "FILTER_REGEX_INCLUDE: ${FILTER_REGEX_INCLUDE}, FILTER_REGEX_EXCLUDE: ${FILTER_REGEX_EXCLUDE}"
ValidateBooleanVariable "IGNORE_GENERATED_FILES" "${IGNORE_GENERATED_FILES}"
ValidateBooleanVariable "IGNORE_GITIGNORED_FILES" "${IGNORE_GITIGNORED_FILES}"
2020-07-01 17:40:40 -04:00
for FILE in "${RAW_FILE_ARRAY[@]}"; do
# Get the file extension
2020-08-31 17:44:35 -04:00
FILE_TYPE="$(GetFileExtension "$FILE")"
# We want a lowercase value
local -l BASE_FILE
# Get the name of the file and the containing directory path
BASE_FILE=$(basename "${FILE}")
FILE_DIR_NAME="$(dirname "${FILE}")"
2020-06-29 10:55:59 -04:00
debug "FILE: ${FILE}, FILE_TYPE: ${FILE_TYPE}, BASE_FILE: ${BASE_FILE}, FILE_DIR_NAME: ${FILE_DIR_NAME}"
2020-06-29 10:55:59 -04:00
2024-01-30 14:24:55 -05:00
if [ ! -e "${FILE}" ]; then
2020-11-10 11:02:03 -05:00
# File not found in workspace
2024-01-30 14:24:55 -05:00
warn "{$FILE} exists in commit data, but not found on file system, skipping..."
2020-11-10 11:02:03 -05:00
continue
fi
2024-01-30 14:24:55 -05:00
# Handle the corner cases of linters that are expected to lint the whole codebase,
# but we don't have a variable to explicitly set the directory
# to lint.
if [[ "${FILE}" == "${GITHUB_WORKSPACE}" ]]; then
debug "${FILE} matches with ${GITHUB_WORKSPACE}. Adding it to the list of directories to lint for linters that are expected to lint the whole codebase"
if CheckovConfigurationFileContainsDirectoryOption "${CHECKOV_LINTER_RULES}"; then
debug "No need to configure the directories to check for Checkov because its configuration file contains the list of directories to analyze."
debug "Add the Checkov configuration file path to the list of items to check to consume as output later."
echo "${CHECKOV_LINTER_RULES}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-CHECKOV"
else
debug "Adding ${GITHUB_WORKSPACE} to the list of directories to analyze with Checkov."
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-CHECKOV"
fi
# JSCPD test cases are handled below because we first need to exclude non-relevant test cases
if [[ "${TEST_CASE_RUN}" == "false" ]]; then
debug "Add ${FILE} to the list of items to lint with JSCPD"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSCPD"
fi
# No need to process this item furhter
continue
fi
Ignore files marked with @generated marker (#1689) * Ignore files marked with @generated marker `@generated` marker is used by certain tools to understand that the file is generated, so it should be treated differently than a file written by a human: * these files do not need to be reformatted, * diffs in these files are less important, * and linters should not be invoked on these files. This PR proposes builtin support for `@generated` marker (and `@not-generated` marker to mark file as not generated when it contains `@generated` marker, like `README.md`). I have not found a standard for a generated file marker, but: * Facebook [uses `@generated` marker](https://tinyurl.com/fb-generated) * Phabricator tool which was spawned from Facebook internal tool [also understands `@generated` marker](https://git.io/JnVHa) * Cargo inserts `@generated` marker into [generated Cargo.lock files](https://git.io/JnVHP) Super-linter supports regex includes and excludes, but they are harder to maintain (each repository needs to be configured) than patching the tools which generate the files. My personal story is that I maintain rust-protobuf crate, which started emitting `@generated` markers [six years ago](https://git.io/JnV5h) after a request of a Phabricator user. Test Plan: Create a test file `test.sh`: ``` echo $a ``` Run: ``` docker run -e RUN_LOCAL=true -v $HOME/tmp/g:/tmp/lint super-linter-test ``` Result is: ``` In /tmp/lint/test.sh line 1: echo $a ^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. ^-- SC2154: a is referenced but not assigned. ^-- SC2086: Double quote to prevent globbing and word splitting. ... 2021-06-22 23:46:16 [ERROR] ERRORS FOUND in BASH:[1] ``` Now add `@generated` to the file and run again: ``` 2021-06-22 23:47:13 [NOTICE] All file(s) linted successfully with no errors detected ``` Additionally, add `@not-generated` in addition to `@generated`, and linter error pops up again. * cleanup * remove space * fix non utf return * fix non utf return Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
2021-06-28 08:59:11 -04:00
###############################################
# Filter files if FILTER_REGEX_INCLUDE is set #
Ignore files marked with @generated marker (#1689) * Ignore files marked with @generated marker `@generated` marker is used by certain tools to understand that the file is generated, so it should be treated differently than a file written by a human: * these files do not need to be reformatted, * diffs in these files are less important, * and linters should not be invoked on these files. This PR proposes builtin support for `@generated` marker (and `@not-generated` marker to mark file as not generated when it contains `@generated` marker, like `README.md`). I have not found a standard for a generated file marker, but: * Facebook [uses `@generated` marker](https://tinyurl.com/fb-generated) * Phabricator tool which was spawned from Facebook internal tool [also understands `@generated` marker](https://git.io/JnVHa) * Cargo inserts `@generated` marker into [generated Cargo.lock files](https://git.io/JnVHP) Super-linter supports regex includes and excludes, but they are harder to maintain (each repository needs to be configured) than patching the tools which generate the files. My personal story is that I maintain rust-protobuf crate, which started emitting `@generated` markers [six years ago](https://git.io/JnV5h) after a request of a Phabricator user. Test Plan: Create a test file `test.sh`: ``` echo $a ``` Run: ``` docker run -e RUN_LOCAL=true -v $HOME/tmp/g:/tmp/lint super-linter-test ``` Result is: ``` In /tmp/lint/test.sh line 1: echo $a ^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. ^-- SC2154: a is referenced but not assigned. ^-- SC2086: Double quote to prevent globbing and word splitting. ... 2021-06-22 23:46:16 [ERROR] ERRORS FOUND in BASH:[1] ``` Now add `@generated` to the file and run again: ``` 2021-06-22 23:47:13 [NOTICE] All file(s) linted successfully with no errors detected ``` Additionally, add `@not-generated` in addition to `@generated`, and linter error pops up again. * cleanup * remove space * fix non utf return * fix non utf return Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
2021-06-28 08:59:11 -04:00
###############################################
if [[ -n "$FILTER_REGEX_INCLUDE" ]] && [[ ! (${FILE} =~ $FILTER_REGEX_INCLUDE) ]]; then
debug "FILTER_REGEX_INCLUDE didn't match. Skipping ${FILE}"
continue
fi
Ignore files marked with @generated marker (#1689) * Ignore files marked with @generated marker `@generated` marker is used by certain tools to understand that the file is generated, so it should be treated differently than a file written by a human: * these files do not need to be reformatted, * diffs in these files are less important, * and linters should not be invoked on these files. This PR proposes builtin support for `@generated` marker (and `@not-generated` marker to mark file as not generated when it contains `@generated` marker, like `README.md`). I have not found a standard for a generated file marker, but: * Facebook [uses `@generated` marker](https://tinyurl.com/fb-generated) * Phabricator tool which was spawned from Facebook internal tool [also understands `@generated` marker](https://git.io/JnVHa) * Cargo inserts `@generated` marker into [generated Cargo.lock files](https://git.io/JnVHP) Super-linter supports regex includes and excludes, but they are harder to maintain (each repository needs to be configured) than patching the tools which generate the files. My personal story is that I maintain rust-protobuf crate, which started emitting `@generated` markers [six years ago](https://git.io/JnV5h) after a request of a Phabricator user. Test Plan: Create a test file `test.sh`: ``` echo $a ``` Run: ``` docker run -e RUN_LOCAL=true -v $HOME/tmp/g:/tmp/lint super-linter-test ``` Result is: ``` In /tmp/lint/test.sh line 1: echo $a ^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. ^-- SC2154: a is referenced but not assigned. ^-- SC2086: Double quote to prevent globbing and word splitting. ... 2021-06-22 23:46:16 [ERROR] ERRORS FOUND in BASH:[1] ``` Now add `@generated` to the file and run again: ``` 2021-06-22 23:47:13 [NOTICE] All file(s) linted successfully with no errors detected ``` Additionally, add `@not-generated` in addition to `@generated`, and linter error pops up again. * cleanup * remove space * fix non utf return * fix non utf return Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
2021-06-28 08:59:11 -04:00
###############################################
# Filter files if FILTER_REGEX_EXCLUDE is set #
Ignore files marked with @generated marker (#1689) * Ignore files marked with @generated marker `@generated` marker is used by certain tools to understand that the file is generated, so it should be treated differently than a file written by a human: * these files do not need to be reformatted, * diffs in these files are less important, * and linters should not be invoked on these files. This PR proposes builtin support for `@generated` marker (and `@not-generated` marker to mark file as not generated when it contains `@generated` marker, like `README.md`). I have not found a standard for a generated file marker, but: * Facebook [uses `@generated` marker](https://tinyurl.com/fb-generated) * Phabricator tool which was spawned from Facebook internal tool [also understands `@generated` marker](https://git.io/JnVHa) * Cargo inserts `@generated` marker into [generated Cargo.lock files](https://git.io/JnVHP) Super-linter supports regex includes and excludes, but they are harder to maintain (each repository needs to be configured) than patching the tools which generate the files. My personal story is that I maintain rust-protobuf crate, which started emitting `@generated` markers [six years ago](https://git.io/JnV5h) after a request of a Phabricator user. Test Plan: Create a test file `test.sh`: ``` echo $a ``` Run: ``` docker run -e RUN_LOCAL=true -v $HOME/tmp/g:/tmp/lint super-linter-test ``` Result is: ``` In /tmp/lint/test.sh line 1: echo $a ^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. ^-- SC2154: a is referenced but not assigned. ^-- SC2086: Double quote to prevent globbing and word splitting. ... 2021-06-22 23:46:16 [ERROR] ERRORS FOUND in BASH:[1] ``` Now add `@generated` to the file and run again: ``` 2021-06-22 23:47:13 [NOTICE] All file(s) linted successfully with no errors detected ``` Additionally, add `@not-generated` in addition to `@generated`, and linter error pops up again. * cleanup * remove space * fix non utf return * fix non utf return Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
2021-06-28 08:59:11 -04:00
###############################################
if [[ -n "$FILTER_REGEX_EXCLUDE" ]] && [[ ${FILE} =~ $FILTER_REGEX_EXCLUDE ]]; then
debug "FILTER_REGEX_EXCLUDE match. Skipping ${FILE}"
continue
fi
Ignore files marked with @generated marker (#1689) * Ignore files marked with @generated marker `@generated` marker is used by certain tools to understand that the file is generated, so it should be treated differently than a file written by a human: * these files do not need to be reformatted, * diffs in these files are less important, * and linters should not be invoked on these files. This PR proposes builtin support for `@generated` marker (and `@not-generated` marker to mark file as not generated when it contains `@generated` marker, like `README.md`). I have not found a standard for a generated file marker, but: * Facebook [uses `@generated` marker](https://tinyurl.com/fb-generated) * Phabricator tool which was spawned from Facebook internal tool [also understands `@generated` marker](https://git.io/JnVHa) * Cargo inserts `@generated` marker into [generated Cargo.lock files](https://git.io/JnVHP) Super-linter supports regex includes and excludes, but they are harder to maintain (each repository needs to be configured) than patching the tools which generate the files. My personal story is that I maintain rust-protobuf crate, which started emitting `@generated` markers [six years ago](https://git.io/JnV5h) after a request of a Phabricator user. Test Plan: Create a test file `test.sh`: ``` echo $a ``` Run: ``` docker run -e RUN_LOCAL=true -v $HOME/tmp/g:/tmp/lint super-linter-test ``` Result is: ``` In /tmp/lint/test.sh line 1: echo $a ^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. ^-- SC2154: a is referenced but not assigned. ^-- SC2086: Double quote to prevent globbing and word splitting. ... 2021-06-22 23:46:16 [ERROR] ERRORS FOUND in BASH:[1] ``` Now add `@generated` to the file and run again: ``` 2021-06-22 23:47:13 [NOTICE] All file(s) linted successfully with no errors detected ``` Additionally, add `@not-generated` in addition to `@generated`, and linter error pops up again. * cleanup * remove space * fix non utf return * fix non utf return Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
2021-06-28 08:59:11 -04:00
###################################################
# Filter files if FILTER_REGEX_EXCLUDE is not set #
###################################################
if [ "${IGNORE_GITIGNORED_FILES}" == "true" ] && git -C "${GITHUB_WORKSPACE}" check-ignore "$FILE"; then
debug "${FILE} is ignored by Git. Skipping ${FILE}"
continue
fi
Ignore files marked with @generated marker (#1689) * Ignore files marked with @generated marker `@generated` marker is used by certain tools to understand that the file is generated, so it should be treated differently than a file written by a human: * these files do not need to be reformatted, * diffs in these files are less important, * and linters should not be invoked on these files. This PR proposes builtin support for `@generated` marker (and `@not-generated` marker to mark file as not generated when it contains `@generated` marker, like `README.md`). I have not found a standard for a generated file marker, but: * Facebook [uses `@generated` marker](https://tinyurl.com/fb-generated) * Phabricator tool which was spawned from Facebook internal tool [also understands `@generated` marker](https://git.io/JnVHa) * Cargo inserts `@generated` marker into [generated Cargo.lock files](https://git.io/JnVHP) Super-linter supports regex includes and excludes, but they are harder to maintain (each repository needs to be configured) than patching the tools which generate the files. My personal story is that I maintain rust-protobuf crate, which started emitting `@generated` markers [six years ago](https://git.io/JnV5h) after a request of a Phabricator user. Test Plan: Create a test file `test.sh`: ``` echo $a ``` Run: ``` docker run -e RUN_LOCAL=true -v $HOME/tmp/g:/tmp/lint super-linter-test ``` Result is: ``` In /tmp/lint/test.sh line 1: echo $a ^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. ^-- SC2154: a is referenced but not assigned. ^-- SC2086: Double quote to prevent globbing and word splitting. ... 2021-06-22 23:46:16 [ERROR] ERRORS FOUND in BASH:[1] ``` Now add `@generated` to the file and run again: ``` 2021-06-22 23:47:13 [NOTICE] All file(s) linted successfully with no errors detected ``` Additionally, add `@not-generated` in addition to `@generated`, and linter error pops up again. * cleanup * remove space * fix non utf return * fix non utf return Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
2021-06-28 08:59:11 -04:00
#########################################
# Filter files with at-generated marker #
#########################################
if [ "${IGNORE_GENERATED_FILES}" == "true" ] && IsGenerated "$FILE"; then
debug "${FILE} is generated. Skipping ${FILE}"
continue
fi
2024-01-30 14:24:55 -05:00
# These linters check every file
local EDITORCONFIG_FILE_PATH
EDITORCONFIG_FILE_PATH="${GITHUB_WORKSPACE}/.editorconfig"
if [ -e "${EDITORCONFIG_FILE_PATH}" ]; then
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-EDITORCONFIG"
else
debug "Don't include ${FILE} in the list of files to lint with editorconfig-checker because the workspace doesn't contain an EditorConfig file: ${EDITORCONFIG_FILE_PATH}"
fi
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GITLEAKS"
if [[ ("${FILE}" =~ .*${ANSIBLE_DIRECTORY}.*) ]] && [[ -d "${FILE}" ]]; then
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-ANSIBLE"
fi
# Handle JSCPD test cases
# At this point, we already processed the options to include or exclude files, so we
# excluded test cases that are not relevant
if [[ "${TEST_CASE_RUN}" == "true" ]] && [[ "${FILE}" =~ .*${DEFAULT_JSCPD_TEST_CASE_DIRECTORY}.* ]] && [[ -d "${FILE}" ]]; then
debug "${FILE} is a test case for JSCPD. Adding it to the list of items to lint with JSCPD"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSCPD"
fi
2023-09-12 12:58:09 -04:00
# See https://docs.renovatebot.com/configuration-options/
if [[ "${BASE_FILE}" =~ renovate.json5? ]] ||
[ "${BASE_FILE}" == ".renovaterc" ] || [[ "${BASE_FILE}" =~ .renovaterc.json5? ]]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-RENOVATE"
2023-09-12 12:58:09 -04:00
fi
# See https://docs.renovatebot.com/config-presets/
IFS="," read -r -a RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES_ARRAY <<<"${RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES}"
for file_name in "${RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES_ARRAY[@]}"; do
if [ "${BASE_FILE}" == "${file_name}" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-RENOVATE"
break
fi
done
if [ "${BASE_FILE}" == "go.mod" ]; then
debug "Found ${FILE}. Checking if individual Go file linting is enabled as well."
if [ "${VALIDATE_GO}" == "true" ]; then
debug "Checking if we are running tests. TEST_CASE_RUN: ${TEST_CASE_RUN}"
if [ "${TEST_CASE_RUN}" == "true" ]; then
debug "Skipping the failure due to individual Go files and Go modules linting being enabled at the same time because we're in test mode."
else
fatal "Set VALIDATE_GO to false to avoid false positives due to analyzing Go files in the ${FILE_DIR_NAME} directory individually instead of considering them in the context of a Go module."
fi
else
debug "Considering ${FILE_DIR_NAME} as a Go module."
fi
2024-01-30 14:24:55 -05:00
echo "${FILE_DIR_NAME}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GO_MODULES"
fi
2020-08-31 17:44:35 -04:00
if IsValidShellScript "${FILE}"; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-BASH"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-BASH_EXEC"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-SHELL_SHFMT"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "clj" ] || [ "${FILE_TYPE}" == "cljs" ] ||
[ "${FILE_TYPE}" == "cljc" ] || [ "${FILE_TYPE}" == "edn" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-CLOJURE"
elif [ "${FILE_TYPE}" == "cpp" ] || [ "${FILE_TYPE}" == "h" ] ||
[ "${FILE_TYPE}" == "cc" ] || [ "${FILE_TYPE}" == "hpp" ] ||
[ "${FILE_TYPE}" == "cxx" ] || [ "${FILE_TYPE}" == "cu" ] ||
[ "${FILE_TYPE}" == "hxx" ] || [ "${FILE_TYPE}" == "c++" ] ||
[ "${FILE_TYPE}" == "hh" ] || [ "${FILE_TYPE}" == "h++" ] ||
[ "${FILE_TYPE}" == "cuh" ] || [ "${FILE_TYPE}" == "c" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-CPP"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-CLANG_FORMAT"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "coffee" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-COFFEESCRIPT"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "cs" ]; then
FILE_ARRAY_CSHARP+=("${FILE}")
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-CSHARP"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "css" ] || [ "${FILE_TYPE}" == "scss" ] ||
[ "${FILE_TYPE}" == "sass" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-CSS"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "dart" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-DART"
# Use BASE_FILE here because FILE_TYPE is not reliable when there is no file extension
elif [[ "${FILE_TYPE}" != "tap" ]] && [[ "${FILE_TYPE}" != "yml" ]] &&
[[ "${FILE_TYPE}" != "yaml" ]] && [[ "${FILE_TYPE}" != "json" ]] &&
[[ "${FILE_TYPE}" != "xml" ]] &&
[[ "${BASE_FILE}" =~ ^(.+\.)?(contain|dock)erfile$ ]]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-DOCKERFILE_HADOLINT"
2021-03-10 09:38:31 -05:00
elif [ "${FILE_TYPE}" == "env" ] || [[ "${BASE_FILE}" == *".env."* ]]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-ENV"
elif [ "${FILE_TYPE}" == "feature" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GHERKIN"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "go" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GO"
2023-01-04 21:41:19 -05:00
# Use BASE_FILE here because FILE_TYPE is not reliable when there is no file extension
2020-08-31 12:51:03 -04:00
elif [ "$FILE_TYPE" == "groovy" ] || [ "$FILE_TYPE" == "jenkinsfile" ] ||
2023-01-04 21:41:19 -05:00
[ "$FILE_TYPE" == "gradle" ] || [ "$FILE_TYPE" == "nf" ] ||
[[ "$BASE_FILE" =~ .*jenkinsfile.* ]]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GROOVY"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "html" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-HTML"
2020-08-05 14:35:14 -04:00
elif [ "${FILE_TYPE}" == "java" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JAVA"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GOOGLE_JAVA_FORMAT"
2020-07-21 13:09:07 -04:00
elif [ "${FILE_TYPE}" == "js" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JAVASCRIPT_ES"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JAVASCRIPT_STANDARD"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JAVASCRIPT_PRETTIER"
elif [ "$FILE_TYPE" == "jsonc" ] || [ "$FILE_TYPE" == "json5" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSONC"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "json" ]; then
FILE_ARRAY_JSON+=("${FILE}")
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSON"
2020-08-31 12:51:03 -04:00
if DetectOpenAPIFile "${FILE}"; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-OPENAPI"
2020-08-31 12:51:03 -04:00
fi
2024-01-30 14:24:55 -05:00
2020-08-31 12:51:03 -04:00
if DetectARMFile "${FILE}"; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-ARM"
2020-08-31 12:51:03 -04:00
fi
2024-01-30 14:24:55 -05:00
2020-08-31 12:51:03 -04:00
if DetectCloudFormationFile "${FILE}"; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-CLOUDFORMATION"
2020-08-31 12:51:03 -04:00
fi
2024-01-30 14:24:55 -05:00
2020-08-31 12:51:03 -04:00
if DetectAWSStatesFIle "${FILE}"; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-STATES"
2020-08-31 12:51:03 -04:00
fi
elif [ "${FILE_TYPE}" == "jsx" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSX"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "kt" ] || [ "${FILE_TYPE}" == "kts" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-KOTLIN"
2020-08-31 12:51:03 -04:00
elif [ "$FILE_TYPE" == "lua" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-LUA"
2020-08-18 18:54:32 -04:00
elif [ "${FILE_TYPE}" == "tex" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-LATEX"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "md" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-MARKDOWN"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-NATURAL_LANGUAGE"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "php" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PHP_BUILTIN"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PHP_PHPCS"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PHP_PHPSTAN"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PHP_PSALM"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "pl" ] || [ "${FILE_TYPE}" == "pm" ] ||
[ "${FILE_TYPE}" == "t" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PERL"
elif [ "${FILE_TYPE}" == "ps1" ] ||
2020-11-06 17:10:09 -05:00
[ "${FILE_TYPE}" == "psm1" ] ||
[ "${FILE_TYPE}" == "psd1" ] ||
[ "${FILE_TYPE}" == "ps1xml" ] ||
[ "${FILE_TYPE}" == "pssc" ] ||
[ "${FILE_TYPE}" == "psrc" ] ||
[ "${FILE_TYPE}" == "cdxml" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-POWERSHELL"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "proto" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PROTOBUF"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "py" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PYTHON_BLACK"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PYTHON_FLAKE8"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PYTHON_ISORT"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PYTHON_PYLINT"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PYTHON_MYPY"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "raku" ] || [ "${FILE_TYPE}" == "rakumod" ] ||
[ "${FILE_TYPE}" == "rakutest" ] || [ "${FILE_TYPE}" == "pm6" ] ||
[ "${FILE_TYPE}" == "pl6" ] || [ "${FILE_TYPE}" == "p6" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-RAKU"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "r" ] || [ "${FILE_TYPE}" == "rmd" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-R"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "rb" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-RUBY"
elif [ "${FILE_TYPE}" == "rs" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-RUST_2015"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-RUST_2018"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-RUST_2021"
elif [ "${BASE_FILE}" == "cargo.toml" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-RUST_CLIPPY"
elif [ "${FILE_TYPE}" == "scala" ] || [ "${FILE_TYPE}" == "sc" ] || [ "${BASE_FILE}" == "??????" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-SCALAFMT"
elif [ "${FILE_TYPE}" == "smk" ] || [ "${BASE_FILE}" == "snakefile" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-SNAKEMAKE_LINT"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-SNAKEMAKE_SNAKEFMT"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "sql" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-SQL"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-SQLFLUFF"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "tf" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-TERRAFORM_TFLINT"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-TERRAFORM_TERRASCAN"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-TERRAFORM_FMT"
elif [ "${FILE_TYPE}" == "hcl" ] &&
[[ ${FILE} != *".tflint.hcl"* ]] &&
[[ ${FILE} != *".pkr.hcl"* ]] &&
[[ ${FILE} != *"docker-bake.hcl"* ]] &&
[[ ${FILE} != *"docker-bake.override.hcl"* ]]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-TERRAGRUNT"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "ts" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-TYPESCRIPT_ES"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-TYPESCRIPT_STANDARD"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-TYPESCRIPT_PRETTIER"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "tsx" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-TSX"
elif [ "${FILE_TYPE}" == "txt" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-TXT"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "xml" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-XML"
2020-08-31 12:51:03 -04:00
elif [ "${FILE_TYPE}" == "yml" ] || [ "${FILE_TYPE}" == "yaml" ]; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-YAML"
if DetectActions "${FILE}"; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GITHUB_ACTIONS"
fi
2020-08-31 12:51:03 -04:00
if DetectCloudFormationFile "${FILE}"; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-CLOUDFORMATION"
2020-08-31 12:51:03 -04:00
fi
if DetectOpenAPIFile "${FILE}"; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-OPENAPI"
fi
2020-10-13 11:21:23 -04:00
if DetectTektonFile "${FILE}"; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-TEKTON"
2020-10-13 11:21:23 -04:00
fi
2020-09-21 18:53:30 -04:00
if DetectKubernetesFile "${FILE}"; then
2024-01-30 14:24:55 -05:00
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-KUBERNETES_KUBECONFORM"
2020-09-21 18:53:30 -04:00
fi
2020-06-29 10:55:59 -04:00
else
2020-08-24 12:11:10 -04:00
CheckFileType "${FILE}"
2020-08-24 12:16:22 -04:00
fi
2020-06-29 10:55:59 -04:00
done
}
2024-01-30 14:24:55 -05:00
# We need this for parallel
export -f BuildFileArrays