Use git ls-tree to build file list (#1192)

* Ignore files that are ignored by Git (#1185)

* Ignore files that are ignored by Git

* Add missing continue statement

* Fix linting errors

* Fix linting errors

* like it

* like it

* Add the IGNORE_GITIGNORED_FILES variable

* Fix setting the Ansible directory when running tests

* Fix var export

* Update linter.sh

Co-authored-by: Admiral Awkbar <admiralawkbar@github.com>

* Remove RenameTestFolder

* Update action.yml

* removing the dockignore from our test...

* fixed it

Co-authored-by: Marco Ferrari <ferrari.marco@gmail.com>
Co-authored-by: Admiral Awkbar <admiralawkbar@github.com>
This commit is contained in:
Eric Nemchik 2021-02-23 11:51:34 -06:00 committed by GitHub
parent 623657398b
commit 389fe11f9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 47 deletions

View file

@ -9,8 +9,6 @@
###########
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace
GITHUB_SHA="${GITHUB_SHA}" # Sha used to create this branch
TEST_FOLDER='.automation/test' # Folder where test are stored
CLEAN_FOLDER='.automation/automation' # Folder to rename to prevent skip
((LOG_TRACE = LOG_DEBUG = LOG_VERBOSE = LOG_NOTICE = LOG_WARN = LOG_ERROR = "true")) # Enable all loging
export LOG_TRACE LOG_DEBUG LOG_VERBOSE LOG_NOTICE LOG_WARN LOG_ERROR
@ -98,7 +96,7 @@ CleanTestDockerFiles() {
##################
mapfile -t FIND_CMD < <(
cd "${GITHUB_WORKSPACE}" || exit 1
find "${GITHUB_WORKSPACE}" -type f -name "*Dockerfile" 2>&1
find "${GITHUB_WORKSPACE}" -type f -name "*Dockerfile" -o -name "*.dockerignore" 2>&1
)
CheckShellErrors "ERROR! failed to get list of all file for Docker!" "ERROR:[${FIND_CMD[*]}]"
@ -145,22 +143,6 @@ CleanSHAFolder() {
CheckShellErrors "ERROR! Failed to remove folder:[${GITHUB_SHA}]!" "ERROR:[${REMOVE_CMD}]"
}
################################################################################
#### Function RenameTestFolder #################################################
RenameTestFolder() {
info "-------------------------------------------------------"
info "Need to rename [tests] folder as it will be ignored..."
#####################
# Rename the folder #
#####################
RENAME_FOLDER_CMD=$(
cd "${GITHUB_WORKSPACE}" || exit 1
mv "${TEST_FOLDER}" "${CLEAN_FOLDER}" 2>&1
)
CheckShellErrors "ERROR! failed to move test folder!" "ERROR:[${RENAME_FOLDER_CMD[*]}]"
}
################################################################################
#### Function CleanPowershell ##################################################
CleanPowershell() {
# Need to remove the .psd1 templates as they are formally parsed,
@ -228,11 +210,6 @@ CleanTestDockerFiles
###############################
CleanSHAFolder
##################
# Re Name folder #
##################
RenameTestFolder
##############################
# Clean Powershell templates #
##############################

View file

@ -1,3 +1,4 @@
---
name: 'Super-Linter'
author: 'GitHub'
description: 'It is a simple combination of various linters, written in bash, to help validate your source code.'

View file

@ -115,29 +115,8 @@ function BuildFileList() {
# print header #
################
debug "----------------------------------------------"
debug "Populating the file list with all the files in the ${WORKSPACE_PATH} workspace"
mapfile -t RAW_FILE_ARRAY < <(find "${WORKSPACE_PATH}" \
-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)
debug "Populating the file list with:[git -C \"${WORKSPACE_PATH}\" ls-tree -r --name-only HEAD | xargs -I % sh -c \"echo ${WORKSPACE_PATH}/%\"]"
mapfile -t RAW_FILE_ARRAY < <(git -C "${WORKSPACE_PATH}" ls-tree -r --name-only HEAD | xargs -I % sh -c "echo ${WORKSPACE_PATH}/%" 2>&1)
debug "RAW_FILE_ARRAY contents: ${RAW_FILE_ARRAY[*]}"
fi