mirror of
https://github.com/super-linter/super-linter.git
synced 2024-12-22 20:52:12 -05:00
Move validation to build time
This commit is contained in:
parent
87036c3987
commit
e4b007cd40
4 changed files with 86 additions and 18 deletions
79
.automation/validate-docker.sh
Executable file
79
.automation/validate-docker.sh
Executable file
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#############################################################################
|
||||
############# Validate build docker image for possible extra errors #########
|
||||
#############################################################################
|
||||
|
||||
###########
|
||||
# Globals #
|
||||
###########
|
||||
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace
|
||||
GITHUB_SHA="${GITHUB_SHA}" # Sha used to create this branch
|
||||
BUILD_DATE="${BUILD_DATE}" # Date the container was built
|
||||
ERROR=0 # Error count
|
||||
|
||||
#########################
|
||||
# Source Function Files #
|
||||
#########################
|
||||
# shellcheck source=/dev/null
|
||||
source "${GITHUB_WORKSPACE}/lib/log.sh" # Source the function script(s)
|
||||
|
||||
################################################################################
|
||||
############################ FUNCTIONS BELOW ###################################
|
||||
################################################################################
|
||||
################################################################################
|
||||
#### Function Header ###########################################################
|
||||
Header() {
|
||||
info "-------------------------------------------"
|
||||
info "----- GitHub Actions validate docker ------"
|
||||
info "-------------------------------------------"
|
||||
}
|
||||
################################################################################
|
||||
#### Function ValidatePowershellModules ########################################
|
||||
function ValidatePowershellModules() {
|
||||
VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1)
|
||||
VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1)
|
||||
# If module found, ensure Invoke-ScriptAnalyzer command is available
|
||||
if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]] && [[ ${VALIDATE_PSSA_CMD} == "Invoke-ScriptAnalyzer" ]]; then
|
||||
# Success
|
||||
debug "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system"
|
||||
debug "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system"
|
||||
else
|
||||
# Failed
|
||||
ERROR=1
|
||||
error "Failed find module [PSScriptAnalyzer] in system!"
|
||||
error "[PSSA_MODULE: ${VALIDATE_PSSA_MODULE}] [PSSA_CMD: ${VALIDATE_PSSA_CMD}]"
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
#### Function ValidateLabel ####################################################
|
||||
ValidateLibs() {
|
||||
ValidatePowershellModules
|
||||
}
|
||||
################################################################################
|
||||
#### Function Footer ###########################################################
|
||||
Footer() {
|
||||
#####################################
|
||||
# Check if any errors were reported #
|
||||
#####################################
|
||||
if [[ ${ERROR} -gt 0 ]]; then
|
||||
fatal "There were some failed assertions. See above"
|
||||
else
|
||||
info "-------------------------------------------------------"
|
||||
info "The step has completed"
|
||||
info "-------------------------------------------------------"
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
################################## MAIN ########################################
|
||||
################################################################################
|
||||
|
||||
#################
|
||||
# Validate libs #
|
||||
#################
|
||||
ValidateLibs
|
||||
|
||||
#################
|
||||
# Report status #
|
||||
#################
|
||||
Footer
|
7
.github/workflows/deploy-DEV.yml
vendored
7
.github/workflows/deploy-DEV.yml
vendored
|
@ -63,6 +63,13 @@ jobs:
|
|||
shell: bash
|
||||
run: .automation/validate-docker-labels.sh
|
||||
|
||||
#########################################
|
||||
# Validates the docker libs/executables #
|
||||
#########################################
|
||||
- name: Run Docker libs/executables test cases
|
||||
shell: bash
|
||||
run: .automation/validate-docker.sh
|
||||
|
||||
#####################################
|
||||
# Run Linter against Test code base #
|
||||
#####################################
|
||||
|
|
|
@ -1139,7 +1139,6 @@ REPORT_OUTPUT_FOLDER="${GITHUB_WORKSPACE}/${OUTPUT_FOLDER}" # Location for
|
|||
# Validate the environment #
|
||||
############################
|
||||
GetValidationInfo
|
||||
ValidatePowershellModules
|
||||
|
||||
########################
|
||||
# Get the linter rules #
|
||||
|
|
|
@ -206,20 +206,3 @@ function GetValidationInfo() {
|
|||
debug "${PRINTENV}"
|
||||
debug "---------------------------------------------"
|
||||
}
|
||||
################################################################################
|
||||
#### Function ValidatePowershellModules ########################################
|
||||
function ValidatePowershellModules() {
|
||||
VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1)
|
||||
VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1)
|
||||
# If module found, ensure Invoke-ScriptAnalyzer command is available
|
||||
if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]] && [[ ${VALIDATE_PSSA_CMD} == "Invoke-ScriptAnalyzer" ]]; then
|
||||
# Success
|
||||
debug "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system"
|
||||
debug "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system"
|
||||
else
|
||||
# Failed
|
||||
error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!"
|
||||
fatal "[PSSA_MODULE: ${VALIDATE_PSSA_MODULE}] [PSSA_CMD: ${VALIDATE_PSSA_CMD}]"
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
|
|
Loading…
Reference in a new issue