feat: write github actions step summary (#5867)

This also removes an unneeded textlint configuration file because it
matches with the default one.

Close #5650
This commit is contained in:
Marco Ferrari 2024-07-11 10:01:11 +02:00 committed by GitHub
parent dd4313c9b3
commit 57c86588c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 497 additions and 19 deletions

View file

@ -1,8 +0,0 @@
{
"filters": {
"comments": true
},
"rules": {
"terminology": true
}
}

1
.gitignore vendored
View file

@ -94,3 +94,4 @@ test/linters/rust_clippy/**/target/**
# Super-linter ouputs # Super-linter ouputs
super-linter-output/ super-linter-output/
custom-super-linter-output-directory-name/ custom-super-linter-output-directory-name/
super-linter-github-actions-step-summary-output*

View file

@ -353,7 +353,8 @@ test-custom-ssl-cert: ## Test the configuration of a custom SSL/TLS certificate
test-non-default-home-directory: ## Test a non-default HOME directory test-non-default-home-directory: ## Test a non-default HOME directory
$(CURDIR)/test/run-super-linter-tests.sh \ $(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \ $(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_non_default_home" "run_test_cases_non_default_home" \
"$(IMAGE)"
.PHONY: test-linters .PHONY: test-linters
test-linters: test-linters-expect-success test-linters-expect-failure ## Run the linters test suite test-linters: test-linters-expect-success test-linters-expect-failure ## Run the linters test suite
@ -362,61 +363,71 @@ test-linters: test-linters-expect-success test-linters-expect-failure ## Run the
test-linters-expect-success: ## Run the linters test suite expecting successes test-linters-expect-success: ## Run the linters test suite expecting successes
$(CURDIR)/test/run-super-linter-tests.sh \ $(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \ $(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_expect_success" "run_test_cases_expect_success" \
"$(IMAGE)"
.PHONY: test-linters-expect-failure .PHONY: test-linters-expect-failure
test-linters-expect-failure: ## Run the linters test suite expecting failures test-linters-expect-failure: ## Run the linters test suite expecting failures
$(CURDIR)/test/run-super-linter-tests.sh \ $(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \ $(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_expect_failure" "run_test_cases_expect_failure" \
"$(IMAGE)"
.PHONY: test-log-level .PHONY: test-log-level
test-log-level: ## Run a test to check if there are conflicts with the LOG_LEVEL variable test-log-level: ## Run a test to check if there are conflicts with the LOG_LEVEL variable
$(CURDIR)/test/run-super-linter-tests.sh \ $(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \ $(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_log_level" "run_test_cases_log_level" \
"$(IMAGE)"
.PHONY: test-linters-expect-failure-log-level-notice .PHONY: test-linters-expect-failure-log-level-notice
test-linters-expect-failure-log-level-notice: ## Run the linters test suite expecting failures with a LOG_LEVEL set to NOTICE test-linters-expect-failure-log-level-notice: ## Run the linters test suite expecting failures with a LOG_LEVEL set to NOTICE
$(CURDIR)/test/run-super-linter-tests.sh \ $(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \ $(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_expect_failure_notice_log" "run_test_cases_expect_failure_notice_log" \
"$(IMAGE)"
.PHONY: test-bash-exec-library-expect-success .PHONY: test-bash-exec-library-expect-success
test-bash-exec-library-expect-success: ## Run the linters test cases for BASH_EXEC expecting successes with BASH_EXEC_IGNORE_LIBRARIES set to true test-bash-exec-library-expect-success: ## Run the linters test cases for BASH_EXEC expecting successes with BASH_EXEC_IGNORE_LIBRARIES set to true
$(CURDIR)/test/run-super-linter-tests.sh \ $(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \ $(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_bash_exec_library_expect_success" "run_test_case_bash_exec_library_expect_success" \
"$(IMAGE)"
.PHONY: test-bash-exec-library-expect-failure .PHONY: test-bash-exec-library-expect-failure
test-bash-exec-library-expect-failure: ## Run the linters test cases for BASH_EXEC expecting failures with BASH_EXEC_IGNORE_LIBRARIES set to true test-bash-exec-library-expect-failure: ## Run the linters test cases for BASH_EXEC expecting failures with BASH_EXEC_IGNORE_LIBRARIES set to true
$(CURDIR)/test/run-super-linter-tests.sh \ $(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \ $(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_bash_exec_library_expect_failure" "run_test_case_bash_exec_library_expect_failure" \
"$(IMAGE)"
.PHONY: test-git-initial-commit .PHONY: test-git-initial-commit
test-git-initial-commit: ## Run super-linter against a repository that only has one commit test-git-initial-commit: ## Run super-linter against a repository that only has one commit
$(CURDIR)/test/run-super-linter-tests.sh \ $(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \ $(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_git_initial_commit" "run_test_case_git_initial_commit" \
"$(IMAGE)"
.PHONY: test-use-find-and-ignore-gitignored-files .PHONY: test-use-find-and-ignore-gitignored-files
test-use-find-and-ignore-gitignored-files: ## Run super-linter with USE_FIND_ALGORITHM=true and IGNORE_GITIGNORED_FILES=true test-use-find-and-ignore-gitignored-files: ## Run super-linter with USE_FIND_ALGORITHM=true and IGNORE_GITIGNORED_FILES=true
$(CURDIR)/test/run-super-linter-tests.sh \ $(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \ $(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_use_find_and_ignore_gitignored_files" "run_test_case_use_find_and_ignore_gitignored_files" \
"$(IMAGE)"
.PHONY: test-save-super-linter-output .PHONY: test-save-super-linter-output
test-save-super-linter-output: ## Run super-linter with SAVE_SUPER_LINTER_OUTPUT=true test-save-super-linter-output: ## Run super-linter with SAVE_SUPER_LINTER_OUTPUT=true
$(CURDIR)/test/run-super-linter-tests.sh \ $(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \ $(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_save_super_linter_output" "run_test_cases_save_super_linter_output" \
"$(IMAGE)"
.PHONY: test-save-super-linter-output-custom-path .PHONY: test-save-super-linter-output-custom-path
test-save-super-linter-output-custom-path: ## Run super-linter with SAVE_SUPER_LINTER_OUTPUT=true and save output in a custom directory test-save-super-linter-output-custom-path: ## Run super-linter with SAVE_SUPER_LINTER_OUTPUT=true and save output in a custom directory
$(CURDIR)/test/run-super-linter-tests.sh \ $(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \ $(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_save_super_linter_output_custom_path" "run_test_cases_save_super_linter_output_custom_path" \
"$(IMAGE)"
.PHONY: docker-dev-container-build-check ## Run Docker build checks against the dev-container image .PHONY: docker-dev-container-build-check ## Run Docker build checks against the dev-container image
docker-dev-container-build-check: docker-dev-container-build-check:

View file

@ -204,6 +204,7 @@ You can configure super-linter using the following environment variables:
| **DOCKERFILE_HADOLINT_FILE_NAME** | `.hadolint.yaml` | Filename for [hadolint configuration](https://github.com/hadolint/hadolint) (ex: `.hadolintlintrc.yaml`) | | **DOCKERFILE_HADOLINT_FILE_NAME** | `.hadolint.yaml` | Filename for [hadolint configuration](https://github.com/hadolint/hadolint) (ex: `.hadolintlintrc.yaml`) |
| **EDITORCONFIG_FILE_NAME** | `.ecrc` | Filename for [editorconfig-checker configuration](https://github.com/editorconfig-checker/editorconfig-checker) | | **EDITORCONFIG_FILE_NAME** | `.ecrc` | Filename for [editorconfig-checker configuration](https://github.com/editorconfig-checker/editorconfig-checker) |
| **ENABLE_GITHUB_ACTIONS_GROUP_TITLE** | `false` if `RUN_LOCAL=true`, `true` otherwise | Flag to enable [GitHub Actions log grouping](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines). | | **ENABLE_GITHUB_ACTIONS_GROUP_TITLE** | `false` if `RUN_LOCAL=true`, `true` otherwise | Flag to enable [GitHub Actions log grouping](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines). |
| **ENABLE_GITHUB_ACTIONS_STEP_SUMMARY** | `false` if `RUN_LOCAL=true`, `true` otherwise | Flag to enable [GitHub Actions job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary) for the Super-linter action. |
| **FILTER_REGEX_EXCLUDE** | not set | Regular expression defining which files will be excluded from linting (ex: `.*src/test.*`). Not setting this variable means to process all files. | | **FILTER_REGEX_EXCLUDE** | not set | Regular expression defining which files will be excluded from linting (ex: `.*src/test.*`). Not setting this variable means to process all files. |
| **FILTER_REGEX_INCLUDE** | not set | Regular expression defining which files will be processed by linters (ex: `.*src/.*`). Not setting this variable means to process all files. `FILTER_REGEX_INCLUDE` is evaluated before `FILTER_REGEX_EXCLUDE`. | | **FILTER_REGEX_INCLUDE** | not set | Regular expression defining which files will be processed by linters (ex: `.*src/.*`). Not setting this variable means to process all files. `FILTER_REGEX_INCLUDE` is evaluated before `FILTER_REGEX_EXCLUDE`. |
| **GITHUB_ACTIONS_CONFIG_FILE** | `actionlint.yml` | Filename for [Actionlint configuration](https://github.com/rhysd/actionlint/blob/main/docs/config.md) (ex: `actionlint.yml`) | | **GITHUB_ACTIONS_CONFIG_FILE** | `actionlint.yml` | Filename for [Actionlint configuration](https://github.com/rhysd/actionlint/blob/main/docs/config.md) (ex: `actionlint.yml`) |

View file

@ -6,6 +6,7 @@ function ValidateBooleanConfigurationVariables() {
ValidateBooleanVariable "CREATE_LOG_FILE" "${CREATE_LOG_FILE}" ValidateBooleanVariable "CREATE_LOG_FILE" "${CREATE_LOG_FILE}"
ValidateBooleanVariable "DISABLE_ERRORS" "${DISABLE_ERRORS}" ValidateBooleanVariable "DISABLE_ERRORS" "${DISABLE_ERRORS}"
ValidateBooleanVariable "ENABLE_GITHUB_ACTIONS_GROUP_TITLE" "${ENABLE_GITHUB_ACTIONS_GROUP_TITLE}" ValidateBooleanVariable "ENABLE_GITHUB_ACTIONS_GROUP_TITLE" "${ENABLE_GITHUB_ACTIONS_GROUP_TITLE}"
ValidateBooleanVariable "ENABLE_GITHUB_ACTIONS_STEP_SUMMARY" "${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}"
ValidateBooleanVariable "IGNORE_GENERATED_FILES" "${IGNORE_GENERATED_FILES}" ValidateBooleanVariable "IGNORE_GENERATED_FILES" "${IGNORE_GENERATED_FILES}"
ValidateBooleanVariable "IGNORE_GITIGNORED_FILES" "${IGNORE_GITIGNORED_FILES}" ValidateBooleanVariable "IGNORE_GITIGNORED_FILES" "${IGNORE_GITIGNORED_FILES}"
ValidateBooleanVariable "LOG_DEBUG" "${LOG_DEBUG}" ValidateBooleanVariable "LOG_DEBUG" "${LOG_DEBUG}"
@ -293,6 +294,27 @@ function ValidateGitHubUrls() {
fi fi
} }
function ValidateGitHubActionsStepSummary() {
if [[ "${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY:-}" == "true" ]]; then
debug "GitHub Actions step summary is enabled. ENABLE_GITHUB_ACTIONS_STEP_SUMMARY: ${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}"
if [[ -z "${GITHUB_STEP_SUMMARY:-}" ]]; then
error "GITHUB_STEP_SUMMARY is not set."
return 1
fi
debug "GITHUB_STEP_SUMMARY is set to: ${GITHUB_STEP_SUMMARY}"
if [[ ! -e "${GITHUB_STEP_SUMMARY}" ]]; then
error "GITHUB_STEP_SUMMARY (${GITHUB_STEP_SUMMARY}) doesn't exist."
return 1
fi
if [[ ! -f "${GITHUB_STEP_SUMMARY}" ]]; then
error "GITHUB_STEP_SUMMARY (${GITHUB_STEP_SUMMARY}) is not a file."
return 1
fi
else
debug "GitHub Actions step summary is disabled because ENABLE_GITHUB_ACTIONS_STEP_SUMMARY is set to: ${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}). No need to validate its configuration."
fi
}
function WarnIfVariableIsSet() { function WarnIfVariableIsSet() {
local INPUT_VARIABLE="${1}" local INPUT_VARIABLE="${1}"
shift shift

View file

@ -47,8 +47,10 @@ RUN_LOCAL="${RUN_LOCAL:-"false"}"
# configure it. # configure it.
if [[ "${RUN_LOCAL}" == "true" ]]; then if [[ "${RUN_LOCAL}" == "true" ]]; then
DEFAULT_ENABLE_GITHUB_ACTIONS_GROUP_TITLE="false" DEFAULT_ENABLE_GITHUB_ACTIONS_GROUP_TITLE="false"
DEFAULT_ENABLE_GITHUB_ACTIONS_STEP_SUMMARY="false"
else else
DEFAULT_ENABLE_GITHUB_ACTIONS_GROUP_TITLE="true" DEFAULT_ENABLE_GITHUB_ACTIONS_GROUP_TITLE="true"
DEFAULT_ENABLE_GITHUB_ACTIONS_STEP_SUMMARY="true"
fi fi
# Let users configure GitHub Actions log markers regardless of running locally or not # Let users configure GitHub Actions log markers regardless of running locally or not
ENABLE_GITHUB_ACTIONS_GROUP_TITLE="${ENABLE_GITHUB_ACTIONS_GROUP_TITLE:-"${DEFAULT_ENABLE_GITHUB_ACTIONS_GROUP_TITLE}"}" ENABLE_GITHUB_ACTIONS_GROUP_TITLE="${ENABLE_GITHUB_ACTIONS_GROUP_TITLE:-"${DEFAULT_ENABLE_GITHUB_ACTIONS_GROUP_TITLE}"}"
@ -56,6 +58,13 @@ export ENABLE_GITHUB_ACTIONS_GROUP_TITLE
startGitHubActionsLogGroup "${SUPER_LINTER_INITIALIZATION_LOG_GROUP_TITLE}" startGitHubActionsLogGroup "${SUPER_LINTER_INITIALIZATION_LOG_GROUP_TITLE}"
# Let users configure GitHub Actions step summary regardless of running locally or not
ENABLE_GITHUB_ACTIONS_STEP_SUMMARY="${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY:-"${DEFAULT_ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}"}"
export ENABLE_GITHUB_ACTIONS_STEP_SUMMARY
if ! ValidateGitHubActionsStepSummary; then
fatal "GitHub Actions job summary configuration failed validation"
fi
# We want a lowercase value # We want a lowercase value
declare -l BASH_EXEC_IGNORE_LIBRARIES declare -l BASH_EXEC_IGNORE_LIBRARIES
BASH_EXEC_IGNORE_LIBRARIES="${BASH_EXEC_IGNORE_LIBRARIES:-false}" BASH_EXEC_IGNORE_LIBRARIES="${BASH_EXEC_IGNORE_LIBRARIES:-false}"
@ -591,6 +600,16 @@ Footer() {
local SUPER_LINTER_EXIT_CODE local SUPER_LINTER_EXIT_CODE
SUPER_LINTER_EXIT_CODE=0 SUPER_LINTER_EXIT_CODE=0
if [[ "${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}" == "true" ]]; then
debug "Saving GitHub Actions step summary to ${GITHUB_STEP_SUMMARY}"
{
echo "# Super-linter summary"
echo ""
echo "| Language | Validation result |"
echo "| -----------------------|-------------------|"
} >>"${GITHUB_STEP_SUMMARY}"
fi
for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do
# This used to be the count of errors found for a given LANGUAGE, but since # This used to be the count of errors found for a given LANGUAGE, but since
# after we switched to running linters against a batch of files, it may not # after we switched to running linters against a batch of files, it may not
@ -607,6 +626,11 @@ Footer() {
if [[ ${ERROR_COUNTER} -ne 0 ]]; then if [[ ${ERROR_COUNTER} -ne 0 ]]; then
error "Errors found in ${LANGUAGE}" error "Errors found in ${LANGUAGE}"
if [[ "${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}" == "true" ]]; then
echo "| ${LANGUAGE} | Fail ❌ |" >>"${GITHUB_STEP_SUMMARY}"
fi
# Print output as error in case users disabled the INFO level so they # Print output as error in case users disabled the INFO level so they
# get feedback # get feedback
if [[ "${LOG_VERBOSE}" != "true" ]]; then if [[ "${LOG_VERBOSE}" != "true" ]]; then
@ -631,6 +655,9 @@ Footer() {
debug "Setting super-linter exit code to ${SUPER_LINTER_EXIT_CODE} because there were errors for ${LANGUAGE}" debug "Setting super-linter exit code to ${SUPER_LINTER_EXIT_CODE} because there were errors for ${LANGUAGE}"
elif [[ ${ERROR_COUNTER} -eq 0 ]]; then elif [[ ${ERROR_COUNTER} -eq 0 ]]; then
notice "Successfully linted ${LANGUAGE}" notice "Successfully linted ${LANGUAGE}"
if [[ "${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}" == "true" ]]; then
echo "| ${LANGUAGE} | Pass ✅ |" >>"${GITHUB_STEP_SUMMARY}"
fi
CallStatusAPI "${LANGUAGE}" "success" CallStatusAPI "${LANGUAGE}" "success"
ANY_LINTER_SUCCESS="true" ANY_LINTER_SUCCESS="true"
debug "Set ANY_LINTER_SUCCESS to ${ANY_LINTER_SUCCESS} because ${LANGUAGE} reported a success" debug "Set ANY_LINTER_SUCCESS to ${ANY_LINTER_SUCCESS} because ${LANGUAGE} reported a success"
@ -650,8 +677,24 @@ Footer() {
if [[ ${SUPER_LINTER_EXIT_CODE} -eq 0 ]]; then if [[ ${SUPER_LINTER_EXIT_CODE} -eq 0 ]]; then
notice "All files and directories linted successfully" notice "All files and directories linted successfully"
if [[ "${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}" == "true" ]]; then
{
echo ""
echo "All files and directories linted successfully"
} >>"${GITHUB_STEP_SUMMARY}"
fi
else else
error "Super-linter detected linting errors" error "Super-linter detected linting errors"
if [[ "${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}" == "true" ]]; then
{
echo ""
echo "Super-linter detected linting errors"
} >>"${GITHUB_STEP_SUMMARY}"
fi
fi
if [[ "${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}" == "true" ]]; then
debug "GitHub Actions step summary file (${GITHUB_STEP_SUMMARY}) contents:\n$(cat "${GITHUB_STEP_SUMMARY}")"
fi fi
exit ${SUPER_LINTER_EXIT_CODE} exit ${SUPER_LINTER_EXIT_CODE}

View file

@ -0,0 +1,78 @@
# Super-linter summary
<!-- textlint-disable terminology -->
| Language | Validation result |
| -----------------------|-------------------|
| ANSIBLE | Fail ❌ |
| BASH | Fail ❌ |
| BASH_EXEC | Fail ❌ |
| CHECKOV | Fail ❌ |
| CLANG_FORMAT | Fail ❌ |
| CLOUDFORMATION | Fail ❌ |
| CLOJURE | Fail ❌ |
| COFFEESCRIPT | Fail ❌ |
| CPP | Fail ❌ |
| CSS | Fail ❌ |
| DART | Fail ❌ |
| DOCKERFILE_HADOLINT | Fail ❌ |
| EDITORCONFIG | Fail ❌ |
| ENV | Fail ❌ |
| GITHUB_ACTIONS | Fail ❌ |
| GITLEAKS | Fail ❌ |
| GHERKIN | Fail ❌ |
| GO | Fail ❌ |
| GO_MODULES | Fail ❌ |
| GO_RELEASER | Fail ❌ |
| GOOGLE_JAVA_FORMAT | Fail ❌ |
| GROOVY | Fail ❌ |
| HTML | Fail ❌ |
| JAVA | Fail ❌ |
| JAVASCRIPT_ES | Fail ❌ |
| JAVASCRIPT_STANDARD | Fail ❌ |
| JSCPD | Fail ❌ |
| JSON | Fail ❌ |
| JSONC | Fail ❌ |
| JSX | Fail ❌ |
| KUBERNETES_KUBECONFORM | Fail ❌ |
| KOTLIN | Fail ❌ |
| LATEX | Fail ❌ |
| LUA | Fail ❌ |
| MARKDOWN | Fail ❌ |
| NATURAL_LANGUAGE | Fail ❌ |
| OPENAPI | Fail ❌ |
| PERL | Fail ❌ |
| PHP_BUILTIN | Fail ❌ |
| PHP_PHPCS | Fail ❌ |
| PHP_PHPSTAN | Fail ❌ |
| PHP_PSALM | Fail ❌ |
| PROTOBUF | Fail ❌ |
| PYTHON_BLACK | Fail ❌ |
| PYTHON_PYLINT | Fail ❌ |
| PYTHON_FLAKE8 | Fail ❌ |
| PYTHON_ISORT | Fail ❌ |
| PYTHON_MYPY | Fail ❌ |
| PYTHON_RUFF | Fail ❌ |
| R | Fail ❌ |
| RAKU | Fail ❌ |
| RENOVATE | Fail ❌ |
| RUBY | Fail ❌ |
| SCALAFMT | Fail ❌ |
| SHELL_SHFMT | Fail ❌ |
| SNAKEMAKE_LINT | Fail ❌ |
| SNAKEMAKE_SNAKEFMT | Fail ❌ |
| STATES | Fail ❌ |
| SQL | Fail ❌ |
| SQLFLUFF | Fail ❌ |
| TEKTON | Fail ❌ |
| TERRAFORM_FMT | Fail ❌ |
| TERRAFORM_TFLINT | Fail ❌ |
| TERRAFORM_TERRASCAN | Fail ❌ |
| TERRAGRUNT | Fail ❌ |
| TSX | Fail ❌ |
| TYPESCRIPT_ES | Fail ❌ |
| TYPESCRIPT_STANDARD | Fail ❌ |
| XML | Fail ❌ |
| YAML | Fail ❌ |
<!-- textlint-enable terminology -->
Super-linter detected linting errors

View file

@ -0,0 +1,85 @@
# Super-linter summary
<!-- textlint-disable terminology -->
| Language | Validation result |
| -----------------------|-------------------|
| ANSIBLE | Fail ❌ |
| ARM | Fail ❌ |
| BASH | Fail ❌ |
| BASH_EXEC | Fail ❌ |
| CHECKOV | Fail ❌ |
| CLANG_FORMAT | Fail ❌ |
| CLOUDFORMATION | Fail ❌ |
| CLOJURE | Fail ❌ |
| COFFEESCRIPT | Fail ❌ |
| CPP | Fail ❌ |
| CSHARP | Fail ❌ |
| CSS | Fail ❌ |
| DART | Fail ❌ |
| DOCKERFILE_HADOLINT | Fail ❌ |
| EDITORCONFIG | Fail ❌ |
| ENV | Fail ❌ |
| GITHUB_ACTIONS | Fail ❌ |
| GITLEAKS | Fail ❌ |
| GHERKIN | Fail ❌ |
| GO | Fail ❌ |
| GO_MODULES | Fail ❌ |
| GO_RELEASER | Fail ❌ |
| GOOGLE_JAVA_FORMAT | Fail ❌ |
| GROOVY | Fail ❌ |
| HTML | Fail ❌ |
| JAVA | Fail ❌ |
| JAVASCRIPT_ES | Fail ❌ |
| JAVASCRIPT_STANDARD | Fail ❌ |
| JSCPD | Fail ❌ |
| JSON | Fail ❌ |
| JSONC | Fail ❌ |
| JSX | Fail ❌ |
| KUBERNETES_KUBECONFORM | Fail ❌ |
| KOTLIN | Fail ❌ |
| LATEX | Fail ❌ |
| LUA | Fail ❌ |
| MARKDOWN | Fail ❌ |
| NATURAL_LANGUAGE | Fail ❌ |
| OPENAPI | Fail ❌ |
| PERL | Fail ❌ |
| PHP_BUILTIN | Fail ❌ |
| PHP_PHPCS | Fail ❌ |
| PHP_PHPSTAN | Fail ❌ |
| PHP_PSALM | Fail ❌ |
| POWERSHELL | Fail ❌ |
| PROTOBUF | Fail ❌ |
| PYTHON_BLACK | Fail ❌ |
| PYTHON_PYLINT | Fail ❌ |
| PYTHON_FLAKE8 | Fail ❌ |
| PYTHON_ISORT | Fail ❌ |
| PYTHON_MYPY | Fail ❌ |
| PYTHON_RUFF | Fail ❌ |
| R | Fail ❌ |
| RAKU | Fail ❌ |
| RENOVATE | Fail ❌ |
| RUBY | Fail ❌ |
| RUST_2015 | Fail ❌ |
| RUST_2018 | Fail ❌ |
| RUST_2021 | Fail ❌ |
| RUST_CLIPPY | Fail ❌ |
| SCALAFMT | Fail ❌ |
| SHELL_SHFMT | Fail ❌ |
| SNAKEMAKE_LINT | Fail ❌ |
| SNAKEMAKE_SNAKEFMT | Fail ❌ |
| STATES | Fail ❌ |
| SQL | Fail ❌ |
| SQLFLUFF | Fail ❌ |
| TEKTON | Fail ❌ |
| TERRAFORM_FMT | Fail ❌ |
| TERRAFORM_TFLINT | Fail ❌ |
| TERRAFORM_TERRASCAN | Fail ❌ |
| TERRAGRUNT | Fail ❌ |
| TSX | Fail ❌ |
| TYPESCRIPT_ES | Fail ❌ |
| TYPESCRIPT_STANDARD | Fail ❌ |
| XML | Fail ❌ |
| YAML | Fail ❌ |
<!-- textlint-enable terminology -->
Super-linter detected linting errors

View file

@ -0,0 +1,78 @@
# Super-linter summary
<!-- textlint-disable terminology -->
| Language | Validation result |
| -----------------------|-------------------|
| ANSIBLE | Pass ✅ |
| BASH | Pass ✅ |
| BASH_EXEC | Pass ✅ |
| CHECKOV | Pass ✅ |
| CLANG_FORMAT | Pass ✅ |
| CLOUDFORMATION | Pass ✅ |
| CLOJURE | Pass ✅ |
| COFFEESCRIPT | Pass ✅ |
| CPP | Pass ✅ |
| CSS | Pass ✅ |
| DART | Pass ✅ |
| DOCKERFILE_HADOLINT | Pass ✅ |
| EDITORCONFIG | Pass ✅ |
| ENV | Pass ✅ |
| GITHUB_ACTIONS | Pass ✅ |
| GITLEAKS | Pass ✅ |
| GHERKIN | Pass ✅ |
| GO | Pass ✅ |
| GO_MODULES | Pass ✅ |
| GO_RELEASER | Pass ✅ |
| GOOGLE_JAVA_FORMAT | Pass ✅ |
| GROOVY | Pass ✅ |
| HTML | Pass ✅ |
| JAVA | Pass ✅ |
| JAVASCRIPT_ES | Pass ✅ |
| JAVASCRIPT_STANDARD | Pass ✅ |
| JSCPD | Pass ✅ |
| JSON | Pass ✅ |
| JSONC | Pass ✅ |
| JSX | Pass ✅ |
| KUBERNETES_KUBECONFORM | Pass ✅ |
| KOTLIN | Pass ✅ |
| LATEX | Pass ✅ |
| LUA | Pass ✅ |
| MARKDOWN | Pass ✅ |
| NATURAL_LANGUAGE | Pass ✅ |
| OPENAPI | Pass ✅ |
| PERL | Pass ✅ |
| PHP_BUILTIN | Pass ✅ |
| PHP_PHPCS | Pass ✅ |
| PHP_PHPSTAN | Pass ✅ |
| PHP_PSALM | Pass ✅ |
| PROTOBUF | Pass ✅ |
| PYTHON_BLACK | Pass ✅ |
| PYTHON_PYLINT | Pass ✅ |
| PYTHON_FLAKE8 | Pass ✅ |
| PYTHON_ISORT | Pass ✅ |
| PYTHON_MYPY | Pass ✅ |
| PYTHON_RUFF | Pass ✅ |
| R | Pass ✅ |
| RAKU | Pass ✅ |
| RENOVATE | Pass ✅ |
| RUBY | Pass ✅ |
| SCALAFMT | Pass ✅ |
| SHELL_SHFMT | Pass ✅ |
| SNAKEMAKE_LINT | Pass ✅ |
| SNAKEMAKE_SNAKEFMT | Pass ✅ |
| STATES | Pass ✅ |
| SQL | Pass ✅ |
| SQLFLUFF | Pass ✅ |
| TEKTON | Pass ✅ |
| TERRAFORM_FMT | Pass ✅ |
| TERRAFORM_TFLINT | Pass ✅ |
| TERRAFORM_TERRASCAN | Pass ✅ |
| TERRAGRUNT | Pass ✅ |
| TSX | Pass ✅ |
| TYPESCRIPT_ES | Pass ✅ |
| TYPESCRIPT_STANDARD | Pass ✅ |
| XML | Pass ✅ |
| YAML | Pass ✅ |
<!-- textlint-enable terminology -->
All files and directories linted successfully

View file

@ -0,0 +1,85 @@
# Super-linter summary
<!-- textlint-disable terminology -->
| Language | Validation result |
| -----------------------|-------------------|
| ANSIBLE | Pass ✅ |
| ARM | Pass ✅ |
| BASH | Pass ✅ |
| BASH_EXEC | Pass ✅ |
| CHECKOV | Pass ✅ |
| CLANG_FORMAT | Pass ✅ |
| CLOUDFORMATION | Pass ✅ |
| CLOJURE | Pass ✅ |
| COFFEESCRIPT | Pass ✅ |
| CPP | Pass ✅ |
| CSHARP | Pass ✅ |
| CSS | Pass ✅ |
| DART | Pass ✅ |
| DOCKERFILE_HADOLINT | Pass ✅ |
| EDITORCONFIG | Pass ✅ |
| ENV | Pass ✅ |
| GITHUB_ACTIONS | Pass ✅ |
| GITLEAKS | Pass ✅ |
| GHERKIN | Pass ✅ |
| GO | Pass ✅ |
| GO_MODULES | Pass ✅ |
| GO_RELEASER | Pass ✅ |
| GOOGLE_JAVA_FORMAT | Pass ✅ |
| GROOVY | Pass ✅ |
| HTML | Pass ✅ |
| JAVA | Pass ✅ |
| JAVASCRIPT_ES | Pass ✅ |
| JAVASCRIPT_STANDARD | Pass ✅ |
| JSCPD | Pass ✅ |
| JSON | Pass ✅ |
| JSONC | Pass ✅ |
| JSX | Pass ✅ |
| KUBERNETES_KUBECONFORM | Pass ✅ |
| KOTLIN | Pass ✅ |
| LATEX | Pass ✅ |
| LUA | Pass ✅ |
| MARKDOWN | Pass ✅ |
| NATURAL_LANGUAGE | Pass ✅ |
| OPENAPI | Pass ✅ |
| PERL | Pass ✅ |
| PHP_BUILTIN | Pass ✅ |
| PHP_PHPCS | Pass ✅ |
| PHP_PHPSTAN | Pass ✅ |
| PHP_PSALM | Pass ✅ |
| POWERSHELL | Pass ✅ |
| PROTOBUF | Pass ✅ |
| PYTHON_BLACK | Pass ✅ |
| PYTHON_PYLINT | Pass ✅ |
| PYTHON_FLAKE8 | Pass ✅ |
| PYTHON_ISORT | Pass ✅ |
| PYTHON_MYPY | Pass ✅ |
| PYTHON_RUFF | Pass ✅ |
| R | Pass ✅ |
| RAKU | Pass ✅ |
| RENOVATE | Pass ✅ |
| RUBY | Pass ✅ |
| RUST_2015 | Pass ✅ |
| RUST_2018 | Pass ✅ |
| RUST_2021 | Pass ✅ |
| RUST_CLIPPY | Pass ✅ |
| SCALAFMT | Pass ✅ |
| SHELL_SHFMT | Pass ✅ |
| SNAKEMAKE_LINT | Pass ✅ |
| SNAKEMAKE_SNAKEFMT | Pass ✅ |
| STATES | Pass ✅ |
| SQL | Pass ✅ |
| SQLFLUFF | Pass ✅ |
| TEKTON | Pass ✅ |
| TERRAFORM_FMT | Pass ✅ |
| TERRAFORM_TFLINT | Pass ✅ |
| TERRAFORM_TERRASCAN | Pass ✅ |
| TERRAGRUNT | Pass ✅ |
| TSX | Pass ✅ |
| TYPESCRIPT_ES | Pass ✅ |
| TYPESCRIPT_STANDARD | Pass ✅ |
| XML | Pass ✅ |
| YAML | Pass ✅ |
<!-- textlint-enable terminology -->
All files and directories linted successfully

View file

@ -148,7 +148,59 @@ function ValidateGitHubUrlsTest() {
notice "${FUNCTION_NAME} PASS" notice "${FUNCTION_NAME} PASS"
} }
function ValidateGitHubActionsStepSummaryTest() {
FUNCTION_NAME="${FUNCNAME[0]}"
ENABLE_GITHUB_ACTIONS_STEP_SUMMARY="false"
if ! ValidateGitHubActionsStepSummary; then
fatal "ValidateGitHubActionsStepSummary shouldn't fail when ENABLE_GITHUB_ACTIONS_STEP_SUMMARY is ${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}"
else
info "ENABLE_GITHUB_ACTIONS_STEP_SUMMARY=${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY} passed validation as expected"
fi
ENABLE_GITHUB_ACTIONS_STEP_SUMMARY="true"
if ValidateGitHubActionsStepSummary; then
fatal "ENABLE_GITHUB_ACTIONS_STEP_SUMMARY=${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY} should have failed validation when GITHUB_STEP_SUMMARY is not set"
else
info "ENABLE_GITHUB_ACTIONS_STEP_SUMMARY=${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY} failed validation as expected"
fi
unset ENABLE_GITHUB_ACTIONS_STEP_SUMMARY
ENABLE_GITHUB_ACTIONS_STEP_SUMMARY="true"
GITHUB_STEP_SUMMARY="/non/existing/file"
if ValidateGitHubActionsStepSummary; then
fatal "ENABLE_GITHUB_ACTIONS_STEP_SUMMARY=${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}, GITHUB_STEP_SUMMARY=${GITHUB_STEP_SUMMARY} should have failed validation when GITHUB_STEP_SUMMARY is set to a non-existing file"
else
info "ENABLE_GITHUB_ACTIONS_STEP_SUMMARY=${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}, GITHUB_STEP_SUMMARY=${GITHUB_STEP_SUMMARY} failed validation as expected"
fi
unset ENABLE_GITHUB_ACTIONS_STEP_SUMMARY
unset GITHUB_STEP_SUMMARY
ENABLE_GITHUB_ACTIONS_STEP_SUMMARY="true"
GITHUB_STEP_SUMMARY="$(pwd)"
if ValidateGitHubActionsStepSummary; then
fatal "ENABLE_GITHUB_ACTIONS_STEP_SUMMARY=${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}, GITHUB_STEP_SUMMARY=${GITHUB_STEP_SUMMARY} should have failed validation when GITHUB_STEP_SUMMARY is set to a directory"
else
info "ENABLE_GITHUB_ACTIONS_STEP_SUMMARY=${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}, GITHUB_STEP_SUMMARY=${GITHUB_STEP_SUMMARY} failed validation as expected"
fi
unset ENABLE_GITHUB_ACTIONS_STEP_SUMMARY
unset GITHUB_STEP_SUMMARY
ENABLE_GITHUB_ACTIONS_STEP_SUMMARY="true"
GITHUB_STEP_SUMMARY="${0}"
if ! ValidateGitHubActionsStepSummary; then
fatal "ENABLE_GITHUB_ACTIONS_STEP_SUMMARY=${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}, GITHUB_STEP_SUMMARY=${GITHUB_STEP_SUMMARY} should have passed validation when GITHUB_STEP_SUMMARY is set to a file"
else
info "ENABLE_GITHUB_ACTIONS_STEP_SUMMARY=${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}, GITHUB_STEP_SUMMARY=${GITHUB_STEP_SUMMARY} passed validation as expected"
fi
unset ENABLE_GITHUB_ACTIONS_STEP_SUMMARY
unset GITHUB_STEP_SUMMARY
notice "${FUNCTION_NAME} PASS"
}
IsUnsignedIntegerSuccessTest IsUnsignedIntegerSuccessTest
IsUnsignedIntegerFailureTest IsUnsignedIntegerFailureTest
ValidateDeprecatedVariablesTest ValidateDeprecatedVariablesTest
ValidateGitHubUrlsTest ValidateGitHubUrlsTest
ValidateGitHubActionsStepSummaryTest

View file

@ -6,6 +6,8 @@ set -o pipefail
SUPER_LINTER_TEST_CONTAINER_URL="${1}" SUPER_LINTER_TEST_CONTAINER_URL="${1}"
TEST_FUNCTION_NAME="${2}" TEST_FUNCTION_NAME="${2}"
SUPER_LINTER_CONTAINER_IMAGE_TYPE="${3}"
echo "Super-linter container image type: ${SUPER_LINTER_CONTAINER_IMAGE_TYPE}"
DEFAULT_BRANCH="main" DEFAULT_BRANCH="main"
@ -23,11 +25,13 @@ run_test_cases_expect_failure() {
configure_linters_for_test_cases configure_linters_for_test_cases
COMMAND_TO_RUN+=(-e ANSIBLE_DIRECTORY="/test/linters/ansible/bad" -e CHECKOV_FILE_NAME=".checkov-test-linters-failure.yaml" -e FILTER_REGEX_INCLUDE=".*bad.*") COMMAND_TO_RUN+=(-e ANSIBLE_DIRECTORY="/test/linters/ansible/bad" -e CHECKOV_FILE_NAME=".checkov-test-linters-failure.yaml" -e FILTER_REGEX_INCLUDE=".*bad.*")
EXPECTED_EXIT_CODE=1 EXPECTED_EXIT_CODE=1
EXPECTED_SUPER_LINTER_STEP_SUMMARY_FILE_PATH="test/data/github-actions-step-summary/expected-step-summary-test-linters-expect-failure-${SUPER_LINTER_CONTAINER_IMAGE_TYPE}.md"
} }
run_test_cases_expect_success() { run_test_cases_expect_success() {
configure_linters_for_test_cases configure_linters_for_test_cases
COMMAND_TO_RUN+=(-e ANSIBLE_DIRECTORY="/test/linters/ansible/good" -e CHECKOV_FILE_NAME=".checkov-test-linters-success.yaml" -e FILTER_REGEX_INCLUDE=".*good.*") COMMAND_TO_RUN+=(-e ANSIBLE_DIRECTORY="/test/linters/ansible/good" -e CHECKOV_FILE_NAME=".checkov-test-linters-success.yaml" -e FILTER_REGEX_INCLUDE=".*good.*")
EXPECTED_SUPER_LINTER_STEP_SUMMARY_FILE_PATH="test/data/github-actions-step-summary/expected-step-summary-test-linters-expect-success-${SUPER_LINTER_CONTAINER_IMAGE_TYPE}.md"
} }
run_test_cases_log_level() { run_test_cases_log_level() {
@ -114,6 +118,20 @@ COMMAND_TO_RUN+=(-e LOG_LEVEL="${LOG_LEVEL:-"DEBUG"}")
COMMAND_TO_RUN+=(-e RUN_LOCAL="${RUN_LOCAL:-true}") COMMAND_TO_RUN+=(-e RUN_LOCAL="${RUN_LOCAL:-true}")
COMMAND_TO_RUN+=(-e SAVE_SUPER_LINTER_OUTPUT="${SAVE_SUPER_LINTER_OUTPUT}") COMMAND_TO_RUN+=(-e SAVE_SUPER_LINTER_OUTPUT="${SAVE_SUPER_LINTER_OUTPUT}")
COMMAND_TO_RUN+=(-v "${SUPER_LINTER_WORKSPACE:-$(pwd)}:/tmp/lint") COMMAND_TO_RUN+=(-v "${SUPER_LINTER_WORKSPACE:-$(pwd)}:/tmp/lint")
if [ -n "${EXPECTED_SUPER_LINTER_STEP_SUMMARY_FILE_PATH:-}" ]; then
echo "Expected Super-linter step summary file path: ${EXPECTED_SUPER_LINTER_STEP_SUMMARY_FILE_PATH}"
SUPER_LINTER_STEP_SUMMARY_FILE="$(pwd)/super-linter-github-actions-step-summary-output.md"
echo "Create Super-linter step summary file: ${SUPER_LINTER_STEP_SUMMARY_FILE}"
# Remove eventual leftovers from previous tests
rm --force "${SUPER_LINTER_STEP_SUMMARY_FILE}"
touch "${SUPER_LINTER_STEP_SUMMARY_FILE}"
SUPER_LINTER_STEP_SUMMARY_FILE_INSIDE_CONTAINER="/tmp/lint/$(basename "${SUPER_LINTER_STEP_SUMMARY_FILE}")"
COMMAND_TO_RUN+=(-e GITHUB_STEP_SUMMARY="${SUPER_LINTER_STEP_SUMMARY_FILE_INSIDE_CONTAINER}")
ENABLE_GITHUB_ACTIONS_STEP_SUMMARY="true"
fi
COMMAND_TO_RUN+=(-e ENABLE_GITHUB_ACTIONS_STEP_SUMMARY="${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY:-"false"}")
COMMAND_TO_RUN+=("${SUPER_LINTER_TEST_CONTAINER_URL}") COMMAND_TO_RUN+=("${SUPER_LINTER_TEST_CONTAINER_URL}")
declare -i EXPECTED_EXIT_CODE declare -i EXPECTED_EXIT_CODE
@ -164,6 +182,18 @@ else
echo "Super-linter output was not requested. SAVE_SUPER_LINTER_OUTPUT: ${SAVE_SUPER_LINTER_OUTPUT}" echo "Super-linter output was not requested. SAVE_SUPER_LINTER_OUTPUT: ${SAVE_SUPER_LINTER_OUTPUT}"
fi fi
if [ -n "${EXPECTED_SUPER_LINTER_STEP_SUMMARY_FILE_PATH:-}" ]; then
# Remove eventual HTML comments from the expected file because we use them to disable certain linter rules
if ! diff "${SUPER_LINTER_STEP_SUMMARY_FILE}" <(grep -vE '^\s*<!--' "${EXPECTED_SUPER_LINTER_STEP_SUMMARY_FILE_PATH}"); then
echo "Super-linter step summary (${SUPER_LINTER_STEP_SUMMARY_FILE}) contents don't match with the expected contents (${EXPECTED_SUPER_LINTER_STEP_SUMMARY_FILE_PATH})"
exit 1
else
echo "Super-linter step summary (${SUPER_LINTER_STEP_SUMMARY_FILE}) contents match with the expected contents (${EXPECTED_SUPER_LINTER_STEP_SUMMARY_FILE_PATH})"
fi
else
echo "Super-linter step summary output was not requested."
fi
if [ ${SUPER_LINTER_EXIT_CODE} -ne ${EXPECTED_EXIT_CODE} ]; then if [ ${SUPER_LINTER_EXIT_CODE} -ne ${EXPECTED_EXIT_CODE} ]; then
echo "Super-linter exited with an unexpected code: ${SUPER_LINTER_EXIT_CODE}" echo "Super-linter exited with an unexpected code: ${SUPER_LINTER_EXIT_CODE}"
exit 1 exit 1