mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-06 01:05:54 -05:00
Inspec additional Tests (#1497)
* adding tests * adding more * cleanup vars * dumb * dumb * fix r lib * adding test * quotes * quotes * more test * adding brackets * typos * dumb * slashes
This commit is contained in:
parent
1482ca9ffc
commit
72cbbfc4e5
6 changed files with 227 additions and 106 deletions
|
@ -7,8 +7,6 @@
|
||||||
###########
|
###########
|
||||||
# Globals #
|
# Globals #
|
||||||
###########
|
###########
|
||||||
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace
|
|
||||||
GITHUB_SHA="${GITHUB_SHA}" # Sha used to create this branch
|
|
||||||
((LOG_TRACE = LOG_DEBUG = LOG_VERBOSE = LOG_NOTICE = LOG_WARN = LOG_ERROR = "true")) # Enable all loging
|
((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
|
export LOG_TRACE LOG_DEBUG LOG_VERBOSE LOG_NOTICE LOG_WARN LOG_ERROR
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,6 @@
|
||||||
###########
|
###########
|
||||||
# Globals #
|
# Globals #
|
||||||
###########
|
###########
|
||||||
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace
|
|
||||||
DOCKER_USERNAME="${DOCKER_USERNAME}" # Username to login to DockerHub
|
|
||||||
DOCKER_PASSWORD="${DOCKER_PASSWORD}" # Password to login to DockerHub
|
|
||||||
IMAGE_REPO="${IMAGE_REPO}" # Image repo to upload the image
|
|
||||||
IMAGE_VERSION="${IMAGE_VERSION}" # Version to tag the image
|
|
||||||
DOCKERFILE_PATH="${DOCKERFILE_PATH}" # Path to the Dockerfile to be uploaded
|
|
||||||
((LOG_TRACE = LOG_DEBUG = LOG_VERBOSE = LOG_NOTICE = LOG_WARN = LOG_ERROR = "true")) # Enable all loging
|
((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
|
export LOG_TRACE LOG_DEBUG LOG_VERBOSE LOG_NOTICE LOG_WARN LOG_ERROR
|
||||||
|
|
||||||
|
|
|
@ -4,16 +4,6 @@
|
||||||
############# Update the actions.yml with version @admiralawkbar ###############
|
############# Update the actions.yml with version @admiralawkbar ###############
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
###########
|
|
||||||
# Globals #
|
|
||||||
###########
|
|
||||||
GITHUB_TOKEN="${GITHUB_TOKEN}" # Token for API CALLS
|
|
||||||
DEPLOY_KEY="${DEPLOY_KEY}" # Deploy key with write access
|
|
||||||
ORG_REPO="${ORG_REPO}" # Name of ther GitHub Organization and repository
|
|
||||||
ISSUE_NUMBER="${ISSUE_NUMBER}" # Number of the issue that kicked the automation
|
|
||||||
ISSUE_TITLE="${ISSUE_TITLE}" # Title of the issue
|
|
||||||
ISSUE_BODY="${ISSUE_BODY}" # Body of the issue
|
|
||||||
|
|
||||||
############
|
############
|
||||||
# Defaults #
|
# Defaults #
|
||||||
############\
|
############\
|
||||||
|
|
|
@ -214,7 +214,7 @@ COPY --from=dockerfile-lint /bin/hadolint /usr/bin/hadolint
|
||||||
#################
|
#################
|
||||||
# Install lintr #
|
# Install lintr #
|
||||||
#################
|
#################
|
||||||
COPY --from=lintr-lib /usr/lib/R/library/ /home/r-library
|
COPY --from=lintr-lib /usr/lib/R/library/ /home/r-library/
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# Install chktex #
|
# Install chktex #
|
||||||
|
@ -370,12 +370,13 @@ COPY --from=base_image /usr/bin/ /usr/bin/
|
||||||
COPY --from=base_image /usr/local/bin/ /usr/local/bin/
|
COPY --from=base_image /usr/local/bin/ /usr/local/bin/
|
||||||
COPY --from=base_image /usr/local/lib/ /usr/local/lib/
|
COPY --from=base_image /usr/local/lib/ /usr/local/lib/
|
||||||
COPY --from=base_image /usr/local/share/ /usr/local/share/
|
COPY --from=base_image /usr/local/share/ /usr/local/share/
|
||||||
COPY --from=base_image /usr/lib /usr/lib/
|
COPY --from=base_image /usr/lib/ /usr/lib/
|
||||||
COPY --from=base_image /usr/share/ /usr/share/
|
COPY --from=base_image /usr/share/ /usr/share/
|
||||||
COPY --from=base_image /usr/include/ /usr/include/
|
COPY --from=base_image /usr/include/ /usr/include/
|
||||||
COPY --from=base_image /lib/ /lib/
|
COPY --from=base_image /lib/ /lib/
|
||||||
COPY --from=base_image /bin/ /bin/
|
COPY --from=base_image /bin/ /bin/
|
||||||
COPY --from=base_image /node_modules/ /node_modules/
|
COPY --from=base_image /node_modules/ /node_modules/
|
||||||
|
COPY --from=base_image /home/r-library/ /home/r-library/
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
# Add node packages to path and dotnet #
|
# Add node packages to path and dotnet #
|
||||||
|
@ -396,8 +397,7 @@ COPY TEMPLATES /action/lib/.automation
|
||||||
################################################
|
################################################
|
||||||
# Run to build version file and validate image #
|
# Run to build version file and validate image #
|
||||||
################################################
|
################################################
|
||||||
RUN ACTIONS_RUNNER_DEBUG=true WRITE_LINTER_VERSIONS_FILE=true /action/lib/linter.sh \
|
RUN ACTIONS_RUNNER_DEBUG=true WRITE_LINTER_VERSIONS_FILE=true /action/lib/linter.sh
|
||||||
&& /action/lib/functions/validateDocker.sh
|
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# Set the entrypoint #
|
# Set the entrypoint #
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
############# Validate build docker image for possible extra errors #########
|
|
||||||
#############################################################################
|
|
||||||
|
|
||||||
###########
|
|
||||||
# Globals #
|
|
||||||
###########
|
|
||||||
((LOG_TRACE = LOG_DEBUG = LOG_VERBOSE = LOG_NOTICE = LOG_WARN = LOG_ERROR = "true")) # Enable all loging
|
|
||||||
ERROR=0 # Error count
|
|
||||||
|
|
||||||
export LOG_TRACE LOG_DEBUG LOG_VERBOSE LOG_NOTICE LOG_WARN LOG_ERROR
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# Source Function Files #
|
|
||||||
#########################
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source /action/lib/functions/log.sh
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
############################ FUNCTIONS BELOW ###################################
|
|
||||||
################################################################################
|
|
||||||
################################################################################
|
|
||||||
#### Function Header ###########################################################
|
|
||||||
Header() {
|
|
||||||
info "---------------------------------------"
|
|
||||||
info "----- Post-build 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 ########################################
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Header #
|
|
||||||
##########
|
|
||||||
Header
|
|
||||||
|
|
||||||
#################
|
|
||||||
# Validate libs #
|
|
||||||
#################
|
|
||||||
ValidateLibs
|
|
||||||
|
|
||||||
#################
|
|
||||||
# Report status #
|
|
||||||
#################
|
|
||||||
Footer
|
|
|
@ -196,3 +196,226 @@ end
|
||||||
# protolint editorconfig-checker #
|
# protolint editorconfig-checker #
|
||||||
# bash-exec gherkin-lint #
|
# bash-exec gherkin-lint #
|
||||||
###################################
|
###################################
|
||||||
|
|
||||||
|
############################################
|
||||||
|
# Check to see all Ruby Gems are installed #
|
||||||
|
############################################
|
||||||
|
control "super-linter-installed-ruby-gems" do
|
||||||
|
impact 1
|
||||||
|
title "Super-Linter installed Ruby gems check"
|
||||||
|
desc "Check that Ruby gems that Super-Linter needs are installed."
|
||||||
|
|
||||||
|
gems = [
|
||||||
|
"rubocop",
|
||||||
|
"rubocop-github",
|
||||||
|
"rubocop-performance",
|
||||||
|
"rubocop-rails",
|
||||||
|
"rubocop-rspec"
|
||||||
|
]
|
||||||
|
|
||||||
|
gems.each do |item|
|
||||||
|
describe gem(item) do
|
||||||
|
it { should be_installed }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
# Check to see all PIP packages are installed #
|
||||||
|
###############################################
|
||||||
|
control "super-linter-installed-pip-packages" do
|
||||||
|
impact 1
|
||||||
|
title "Super-Linter installed PIP packages check"
|
||||||
|
desc "Check that PIP packages that Super-Linter needs are installed."
|
||||||
|
|
||||||
|
packages = [
|
||||||
|
"ansible-lint",
|
||||||
|
"black",
|
||||||
|
"cfn-lint",
|
||||||
|
"cython",
|
||||||
|
"flake8",
|
||||||
|
"isort",
|
||||||
|
"mypy",
|
||||||
|
"pylint",
|
||||||
|
"snakefmt",
|
||||||
|
"snakemake",
|
||||||
|
"typing_extensions",
|
||||||
|
"yamllint",
|
||||||
|
"yq"
|
||||||
|
]
|
||||||
|
|
||||||
|
packages.each do |item|
|
||||||
|
describe pip(item) do
|
||||||
|
it { should be_installed }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
# Check to see all NPM packages are installed #
|
||||||
|
###############################################
|
||||||
|
control "super-linter-installed-npm-packages" do
|
||||||
|
impact 1
|
||||||
|
title "Super-Linter installed NPM packages check"
|
||||||
|
desc "Check that NPM packages that Super-Linter needs are installed."
|
||||||
|
|
||||||
|
packages = [
|
||||||
|
"@coffeelint/cli",
|
||||||
|
"@stoplight/spectral",
|
||||||
|
"@typescript-eslint/eslint-plugin",
|
||||||
|
"@typescript-eslint/parser",
|
||||||
|
"asl-validator",
|
||||||
|
#"axios",
|
||||||
|
"babel-eslint",
|
||||||
|
"dockerfilelint",
|
||||||
|
#"eslint",
|
||||||
|
"eslint-config-airbnb",
|
||||||
|
"eslint-config-prettier",
|
||||||
|
"eslint-plugin-jest",
|
||||||
|
"eslint-plugin-jsx-a11y",
|
||||||
|
"eslint-plugin-prettier",
|
||||||
|
"gherkin-lint",
|
||||||
|
"htmlhint",
|
||||||
|
#"immer",
|
||||||
|
#"ini",
|
||||||
|
"jscpd",
|
||||||
|
"jsonlint",
|
||||||
|
#"lodash",
|
||||||
|
"markdownlint-cli",
|
||||||
|
#"node-fetch",
|
||||||
|
"npm-groovy-lint",
|
||||||
|
"prettier",
|
||||||
|
"prettyjson",
|
||||||
|
#"pug",
|
||||||
|
"sql-lint",
|
||||||
|
"standard",
|
||||||
|
"stylelint",
|
||||||
|
"stylelint-config-sass-guidelines",
|
||||||
|
"stylelint-config-standard",
|
||||||
|
#"stylelint-scss",
|
||||||
|
"tekton-lint",
|
||||||
|
"typescript"
|
||||||
|
]
|
||||||
|
|
||||||
|
packages.each do |item|
|
||||||
|
describe npm(item, path: "/") do
|
||||||
|
it { should be_installed }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
# Check to see if directories exist #
|
||||||
|
#####################################
|
||||||
|
control "super-linter-validate-directories" do
|
||||||
|
impact 1
|
||||||
|
title "Super-Linter check for directories"
|
||||||
|
desc "Check that directories that Super-Linter needs are installed."
|
||||||
|
|
||||||
|
dirs = [
|
||||||
|
"/home/r-library",
|
||||||
|
"/node_modules",
|
||||||
|
"/action/lib",
|
||||||
|
"/action/lib/functions",
|
||||||
|
"/action/lib/.automation",
|
||||||
|
"/usr/local/lib/",
|
||||||
|
"/usr/local/share/"
|
||||||
|
]
|
||||||
|
|
||||||
|
dirs.each do |item|
|
||||||
|
describe directory(item) do
|
||||||
|
it { should exist }
|
||||||
|
it { should be_directory }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
###############################
|
||||||
|
# Check to see if files exist #
|
||||||
|
###############################
|
||||||
|
control "super-linter-validate-files" do
|
||||||
|
impact 1
|
||||||
|
title "Super-Linter check for files"
|
||||||
|
desc "Check that files that Super-Linter needs are installed."
|
||||||
|
|
||||||
|
files = [
|
||||||
|
"/action/lib/linter.sh",
|
||||||
|
"/action/lib/functions/buildFileList.sh",
|
||||||
|
"/action/lib/functions/detectFiles.sh",
|
||||||
|
"/action/lib/functions/linterRules.sh",
|
||||||
|
"/action/lib/functions/linterVersions.sh",
|
||||||
|
"/action/lib/functions/linterVersions.txt",
|
||||||
|
"/action/lib/functions/log.sh",
|
||||||
|
"/action/lib/functions/possum.sh",
|
||||||
|
"/action/lib/functions/updateSSL.sh",
|
||||||
|
"/action/lib/functions/validation.sh",
|
||||||
|
"/action/lib/functions/worker.sh",
|
||||||
|
"/action/lib/.automation/.ansible-lint.yml",
|
||||||
|
"/action/lib/.automation/.arm-ttk.psd1",
|
||||||
|
"/action/lib/.automation/.cfnlintrc.yml",
|
||||||
|
"/action/lib/.automation/.chktexrc",
|
||||||
|
"/action/lib/.automation/.clj-kondo",
|
||||||
|
"/action/lib/.automation/.coffee-lint.json",
|
||||||
|
"/action/lib/.automation/.dockerfilelintrc",
|
||||||
|
"/action/lib/.automation/.ecrc",
|
||||||
|
"/action/lib/.automation/.eslintrc.yml",
|
||||||
|
"/action/lib/.automation/.flake8",
|
||||||
|
"/action/lib/.automation/.gherkin-lintrc",
|
||||||
|
"/action/lib/.automation/.golangci.yml",
|
||||||
|
"/action/lib/.automation/.groovylintrc.json",
|
||||||
|
"/action/lib/.automation/.hadolint.yaml",
|
||||||
|
"/action/lib/.automation/.htmlhintrc",
|
||||||
|
"/action/lib/.automation/.isort.cfg",
|
||||||
|
"/action/lib/.automation/.jscpd.json",
|
||||||
|
"/action/lib/.automation/.lintr",
|
||||||
|
"/action/lib/.automation/.luacheckrc",
|
||||||
|
"/action/lib/.automation/.markdown-lint.yml",
|
||||||
|
"/action/lib/.automation/.mypy.ini",
|
||||||
|
"/action/lib/.automation/.openapirc.yml",
|
||||||
|
"/action/lib/.automation/.perlcriticrc",
|
||||||
|
"/action/lib/.automation/.powershell-psscriptanalyzer.psd1",
|
||||||
|
"/action/lib/.automation/.protolintrc.yml",
|
||||||
|
"/action/lib/.automation/.python-black",
|
||||||
|
"/action/lib/.automation/.python-lint",
|
||||||
|
"/action/lib/.automation/.ruby-lint.yml",
|
||||||
|
"/action/lib/.automation/.snakefmt.toml",
|
||||||
|
"/action/lib/.automation/.sql-config.json",
|
||||||
|
"/action/lib/.automation/.stylelintrc.json",
|
||||||
|
"/action/lib/.automation/.tflint.hcl",
|
||||||
|
"/action/lib/.automation/.yaml-lint.yml",
|
||||||
|
"/action/lib/.automation/analysis_options.yml",
|
||||||
|
"/action/lib/.automation/linter.yml",
|
||||||
|
"/action/lib/.automation/phpcs.xml",
|
||||||
|
"/action/lib/.automation/phpstan.neon",
|
||||||
|
"/action/lib/.automation/psalm.xml",
|
||||||
|
"/action/lib/.automation/sun_checks.xml"
|
||||||
|
]
|
||||||
|
|
||||||
|
files.each do |item|
|
||||||
|
describe file(item) do
|
||||||
|
it { should exist }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
###############################
|
||||||
|
# Validate powershell modules #
|
||||||
|
###############################
|
||||||
|
control "super-linter-validate-powershell-modules" do
|
||||||
|
impact 1
|
||||||
|
title "Super-Linter validate Powershell Modules"
|
||||||
|
desc "Check that Powershell modules that Super-Linter needs are installed."
|
||||||
|
|
||||||
|
describe command("pwsh -c \"(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name\" 2>&1") do
|
||||||
|
its("exit_status") { should eq 0 }
|
||||||
|
its("stdout") { should eq "PSScriptAnalyzer\n" }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe command("pwsh -c \"(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name\" 2>&1") do
|
||||||
|
its("exit_status") { should eq 0 }
|
||||||
|
its("stdout") { should eq "Invoke-ScriptAnalyzer\n" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue