mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 16:51:05 -05:00
so dank
This commit is contained in:
parent
fc9654924f
commit
6701372154
2 changed files with 199 additions and 3 deletions
182
.automation/clean-code-base-for-tests.sh
Executable file
182
.automation/clean-code-base-for-tests.sh
Executable file
|
@ -0,0 +1,182 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
################################################################################
|
||||
############# Clean all code base for additonal testing @admiralawkbar #########
|
||||
################################################################################
|
||||
|
||||
###########
|
||||
# Globals #
|
||||
###########
|
||||
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace
|
||||
|
||||
################################################################################
|
||||
############################ FUNCTIONS BELOW ###################################
|
||||
################################################################################
|
||||
################################################################################
|
||||
#### Function Header ###########################################################
|
||||
Header() {
|
||||
info "-------------------------------------------------------"
|
||||
info "------- GitHub Clean code base of error tests ---------"
|
||||
info "-------------------------------------------------------"
|
||||
}
|
||||
################################################################################
|
||||
#### Function CleanTestFiles ###################################################
|
||||
CleanTestFiles() {
|
||||
info "-------------------------------------------------------"
|
||||
info "Finding all tests that are supposed to fail... and removing them..."
|
||||
|
||||
##################
|
||||
# Find the files #
|
||||
##################
|
||||
FIND_CMD=($(cd "${GITHUB_WORKSPACE}" ; find . -type f -name "*_bad_*" 2>&1))
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
error "ERROR! failed to get list of all files!"
|
||||
fatal "ERROR:[${FIND_CMD[*]}]"
|
||||
fi
|
||||
|
||||
############################################################
|
||||
# Get the directory and validate it came from tests folder #
|
||||
############################################################
|
||||
for FILE in "${FIND_CMD[@]}"; do
|
||||
#####################
|
||||
# Get the directory #
|
||||
#####################
|
||||
FILE_DIR=$(dirname "$FILE" 2>&1)
|
||||
|
||||
##################################
|
||||
# Check if from the tests folder #
|
||||
##################################
|
||||
if [[ $FILE_DIR == **".automation/test"** ]]; then
|
||||
################################
|
||||
# Its a test, we can delete it #
|
||||
################################
|
||||
REMOVE_FILE_CMD=$(cd "${GITHUB_WORKSPACE}" || exit 1; rm -f "$FILE" 2>&1)
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
error "ERROR! failed to remove file:[${FILE}]!"
|
||||
fatal "ERROR:[${REMOVE_FILE_CMD[*]}]"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
################################################################################
|
||||
#### Function CleanTestDockerFiles #############################################
|
||||
CleanTestDockerFiles() {
|
||||
info "-------------------------------------------------------"
|
||||
info "Finding all tests that are supposed to fail for Docker... and removing them..."
|
||||
|
||||
##################
|
||||
# Find the files #
|
||||
##################
|
||||
FIND_CMD=($(cd "${GITHUB_WORKSPACE}" ; find . -type f -name "*Dockerfile" 2>&1))
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
error "ERROR! failed to get list of all file for Docker!"
|
||||
fatal "ERROR:[${FIND_CMD[*]}]"
|
||||
fi
|
||||
|
||||
############################################################
|
||||
# Get the directory and validate it came from tests folder #
|
||||
############################################################
|
||||
for FILE in "${FIND_CMD[@]}"; do
|
||||
#####################
|
||||
# Get the directory #
|
||||
#####################
|
||||
FILE_DIR=$(dirname "$FILE" 2>&1)
|
||||
|
||||
##################################
|
||||
# Check if from the tests folder #
|
||||
##################################
|
||||
if [[ $FILE_DIR == **".automation/test/docker/bad"** ]]; then
|
||||
################################
|
||||
# Its a test, we can delete it #
|
||||
################################
|
||||
REMOVE_FILE_CMD=$(cd "${GITHUB_WORKSPACE}" || exit 1; rm -f "$FILE" 2>&1)
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
error "ERROR! failed to remove file:[${FILE}]!"
|
||||
fatal "ERROR:[${REMOVE_FILE_CMD[*]}]"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
################################################################################
|
||||
#### 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)
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
error "ERROR! failed to move test folder!"
|
||||
fatal "ERROR:[${RENAME_FOLDER_CMD[*]}]"
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
################################## MAIN ########################################
|
||||
################################################################################
|
||||
|
||||
##########
|
||||
# Header #
|
||||
##########
|
||||
Header
|
||||
|
||||
####################
|
||||
# Clean test files #
|
||||
####################
|
||||
CleanTestFiles
|
||||
|
||||
###############################
|
||||
# Clean the test docker files #
|
||||
###############################
|
||||
CleanTestDockerFiles
|
||||
|
||||
##################
|
||||
# Re Name folder #
|
||||
##################
|
||||
RenameTestFolder
|
20
.github/workflows/deploy-DEV.yml
vendored
20
.github/workflows/deploy-DEV.yml
vendored
|
@ -50,9 +50,23 @@ jobs:
|
|||
shell: bash
|
||||
run: docker build --no-cache -t github/super-linter:${GITHUB_SHA} .
|
||||
|
||||
################################
|
||||
# Run Linter against code base #
|
||||
################################
|
||||
#####################################
|
||||
# Run Linter against Test code base #
|
||||
#####################################
|
||||
- name: Run Test Cases
|
||||
shell: bash
|
||||
run: docker run -e RUN_LOCAL=true -e TEST_CASE_RUN=true -e OUTPUT_FORMAT=tap -e OUTPUT_FOLDER=${GITHUB_SHA} -e OUTPUT_DETAILS=detailed -v ${GITHUB_WORKSPACE}:/tmp/lint github/super-linter:${GITHUB_SHA}
|
||||
|
||||
#########################################
|
||||
# Clean code base to run agaisnt it all #
|
||||
#########################################
|
||||
- name: Clean Test code base for additional testing
|
||||
shell: bash
|
||||
run: .automation/clean-code-base-for-tests.sh
|
||||
|
||||
############################################
|
||||
# Run Linter against ALL cleaned code base #
|
||||
############################################
|
||||
- name: Run against all code base
|
||||
shell: bash
|
||||
run: docker run -e RUN_LOCAL=true -e OUTPUT_FORMAT=tap -e OUTPUT_FOLDER=${GITHUB_SHA} -e OUTPUT_DETAILS=detailed -v ${GITHUB_WORKSPACE}:/tmp/lint github/super-linter:${GITHUB_SHA}
|
||||
|
|
Loading…
Reference in a new issue