chore: format super-linter summaries (#6063)

Run Prettier to format the Super-linter summary file to produce
summaries with consistent formatting.
This commit is contained in:
Marco Ferrari 2024-08-25 19:43:33 +02:00 committed by GitHub
parent a5c0cf27db
commit 11d4aac68c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 553 additions and 508 deletions

View file

@ -1,35 +1,2 @@
---
###########################
###########################
## Markdown Linter rules ##
###########################
###########################
# Linter rules doc:
# - https://github.com/DavidAnson/markdownlint
#
# Note:
# To comment out a single error:
# <!-- markdownlint-disable -->
# any violations you want
# <!-- markdownlint-restore -->
#
###############
# Rules by id #
###############
MD004: false # Unordered list style
MD007:
indent: 2 # Unordered list indentation
MD013:
line_length: 808 # Line length
MD026:
punctuation: ".,;:!。,;:" # List of not allowed
MD029: false # Ordered list item prefix
MD033: false # Allow inline HTML
MD036: false # Emphasis used instead of a heading
#################
# Rules by tags #
#################
blank_lines: false # Error on blank lines
extends: "markdownlint/style/prettier"

View file

@ -1,4 +0,0 @@
# Don't format Markdown files to verify tests
# because we don't yet generate formatted Markdown
# tables when creating the summary file
test/data/super-linter-summary/markdown/table/**/*.md

View file

@ -145,6 +145,7 @@ open-shell-super-linter-container: ## Open a shell in the Super-linter container
docker run $(DOCKER_FLAGS) \
--interactive \
--entrypoint /bin/bash \
--rm \
-v "$(CURDIR)":/tmp/lint \
$(SUPER_LINTER_TEST_CONTAINER_URL)
@ -167,6 +168,7 @@ test-actions-runner-debug: ## Run super-linter with ACTIONS_RUNNER_DEBUG=true
-e DEFAULT_BRANCH=main \
-e USE_FIND_ALGORITHM=true \
-v "$(CURDIR)/.github":/tmp/lint/.github \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-actions-steps-debug
@ -178,6 +180,7 @@ test-actions-steps-debug: ## Run super-linter with ACTIONS_STEPS_DEBUG=true
-e DEFAULT_BRANCH=main \
-e USE_FIND_ALGORITHM=true \
-v "$(CURDIR)/.github":/tmp/lint/.github \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-runner-debug
@ -189,6 +192,7 @@ test-runner-debug: ## Run super-linter with RUNNER_DEBUG=1
-e DEFAULT_BRANCH=main \
-e USE_FIND_ALGORITHM=true \
-v "$(CURDIR)/.github":/tmp/lint/.github \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-find
@ -200,6 +204,7 @@ test-find: ## Run super-linter on a subdirectory with USE_FIND_ALGORITHM=true
-e DEFAULT_BRANCH=main \
-e USE_FIND_ALGORITHM=true \
-v "$(CURDIR)/.github":/tmp/lint/.github \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
# We need to set USE_FIND_ALGORITHM=true because the DEFALUT_WORKSPACE is not
@ -215,6 +220,7 @@ test-non-default-workdir: ## Run super-linter with DEFAULT_WORKSPACE set
-e USE_FIND_ALGORITHM=true \
-e VALIDATE_ALL_CODEBASE=true \
-v $(CURDIR)/.github:/tmp/not-default-workspace/.github \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-git-flags
@ -229,6 +235,7 @@ test-git-flags: ## Run super-linter with different git-related flags
-e IGNORE_GITIGNORED_FILES=true \
-e VALIDATE_ALL_CODEBASE=true \
-v "$(CURDIR)":/tmp/lint \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: lint-codebase
@ -246,6 +253,7 @@ lint-codebase: ## Lint the entire codebase
-e SAVE_SUPER_LINTER_SUMMARY=true \
-e VALIDATE_ALL_CODEBASE=true \
-v "$(CURDIR):/tmp/lint" \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
# Return an error if there are changes to commit
@ -273,6 +281,7 @@ fix-codebase: ## Fix and format the entire codebase
-e SAVE_SUPER_LINTER_SUMMARY=true \
-e VALIDATE_ALL_CODEBASE=true \
-v "$(CURDIR):/tmp/lint" \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
&& /bin/bash -c "source test/testUtils.sh; if ! CheckUnexpectedGitChanges ${CURDIR}; then exit 1; fi"
@ -293,6 +302,7 @@ lint-subset-files-enable-only-one-type: ## Lint a small subset of files in the c
-e VALIDATE_ALL_CODEBASE=true \
-e VALIDATE_MARKDOWN=true \
-v "$(CURDIR):/tmp/lint" \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: lint-subset-files-enable-expensive-io-checks
@ -312,6 +322,7 @@ lint-subset-files-enable-expensive-io-checks: ## Lint a small subset of files in
-e VALIDATE_STATES=true \
-e VALIDATE_TEKTON=true \
-v "$(CURDIR):/tmp/lint" \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-lib
@ -323,6 +334,7 @@ test-globals-languages: ## Test globals/languages.sh
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/globalsLanguagesTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-globals-linter-command-options
@ -331,6 +343,7 @@ test-globals-linter-command-options: ## Test globals/LinterCommandsOptions.sh
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/globalsLinterCommandsOptionsTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-linter-rules
@ -339,6 +352,7 @@ test-linter-rules: ## Test linterRules.sh
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/linterRulesTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-build-file-list
@ -347,6 +361,7 @@ test-build-file-list: ## Test buildFileList
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/buildFileListTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-detect-files
@ -355,6 +370,7 @@ test-detect-files: ## Test detectFiles
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/detectFilesTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-github-event
@ -363,6 +379,7 @@ test-github-event: ## Test githubEvent
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/githubEventTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-setup-ssh
@ -372,6 +389,7 @@ test-setup-ssh: ## Test setupSSH
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/setupSSHTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-validation
@ -380,6 +398,7 @@ test-validation: ## Test validation
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/validationTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-output
@ -388,6 +407,7 @@ test-output: ## Test output
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/outputTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-linter-commands
@ -396,6 +416,7 @@ test-linter-commands: ## Test linterCommands
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/linterCommandsTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
# Run this test against a small directory because we're only interested in
@ -410,6 +431,7 @@ test-default-config-files: ## Test default configuration files loading
-e DEFAULT_BRANCH=main \
-e USE_FIND_ALGORITHM=true \
-v "$(CURDIR)/docs":/tmp/lint \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-custom-ssl-cert
@ -422,6 +444,7 @@ test-custom-ssl-cert: ## Test the configuration of a custom SSL/TLS certificate
-e USE_FIND_ALGORITHM=true \
-e SSL_CERT_SECRET="$(shell cat test/data/ssl-certificate/rootCA-test.crt)" \
-v "$(CURDIR)/docs":/tmp/lint \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-non-default-home-directory
@ -562,6 +585,7 @@ build-dev-container-image: docker-dev-container-build-check ## Build commit lint
lint-commits: build-dev-container-image ## Lint commits
docker run \
-v "$(CURDIR):/source-repository" \
--rm \
${DEV_CONTAINER_URL} \
commitlint \
--config .github/linters/commitlint.config.js \
@ -575,6 +599,7 @@ release-please-dry-run: build-dev-container-image check-github-token ## Run rele
@echo "Running release-please against branch: ${RELEASE_PLEASE_TARGET_BRANCH}"; \
docker run \
-v "$(CURDIR):/source-repository" \
--rm \
${DEV_CONTAINER_URL} \
release-please \
release-pr \

View file

@ -7,7 +7,7 @@ WriteSummaryHeader() {
echo "# Super-linter summary"
echo ""
echo "| Language | Validation result |"
echo "| -----------------------|-------------------|"
echo "| -------- | ----------------- |"
} >>"${SUPER_LINTER_SUMMARY_OUTPUT_PATH}"
}
@ -38,3 +38,20 @@ WriteSummaryFooterFailure() {
echo "Super-linter detected linting errors"
} >>"${SUPER_LINTER_SUMMARY_OUTPUT_PATH}"
}
FormatSuperLinterSummaryFile() {
local SUPER_LINTER_SUMMARY_OUTPUT_PATH="${1}"
local SUPER_LINTER_SUMMARY_FORMAT_COMMAND=(prettier --write)
# Override the default prettier ignore paths (.gitignore, .prettierignore) to
# avoid considering their defaults because prettier will skip formatting
# the summary report file if the summary report file is ignored in those
# ignore files, which is usually the case for generated files.
# Ref: https://prettier.io/docs/en/cli#--ignore-path
SUPER_LINTER_SUMMARY_FORMAT_COMMAND+=(--ignore-path /dev/null)
SUPER_LINTER_SUMMARY_FORMAT_COMMAND+=("${SUPER_LINTER_SUMMARY_OUTPUT_PATH}")
debug "Formatting the Super-linter summary file by running: ${SUPER_LINTER_SUMMARY_FORMAT_COMMAND[*]}"
if ! "${SUPER_LINTER_SUMMARY_FORMAT_COMMAND[@]}"; then
error "Error while formatting the Super-linter summary file."
return 1
fi
}

View file

@ -561,6 +561,9 @@ Footer() {
fi
if [[ "${SAVE_SUPER_LINTER_SUMMARY}" == "true" ]]; then
if ! FormatSuperLinterSummaryFile "${SUPER_LINTER_SUMMARY_OUTPUT_PATH}"; then
fatal "Error while formatting the Super-linter summary file."
fi
debug "Super-linter summary file (${SUPER_LINTER_SUMMARY_OUTPUT_PATH}) contents:\n$(cat "${SUPER_LINTER_SUMMARY_OUTPUT_PATH}")"
fi

View file

@ -1,3 +0,0 @@
<!-- markdownlint-disable -->
Super-linter detected linting errors

View file

@ -1,3 +0,0 @@
<!-- markdownlint-disable -->
All files and directories linted successfully

View file

@ -1,4 +0,0 @@
# Super-linter summary
| Language | Validation result |
| -----------------------|-------------------|

View file

@ -1,2 +0,0 @@
<!-- markdownlint-disable -->
| Test Language | Fail ❌ |

View file

@ -1,2 +0,0 @@
<!-- markdownlint-disable -->
| Test Language | Pass ✅ |

View file

@ -1,8 +1,9 @@
# Super-linter summary
<!-- textlint-disable terminology -->
| Language | Validation result |
| -----------------------|-------------------|
| ---------------------- | ----------------- |
| ANSIBLE | Fail ❌ |
| BASH | Fail ❌ |
| BASH_EXEC | Fail ❌ |
@ -83,6 +84,7 @@
| XML | Fail ❌ |
| YAML | Fail ❌ |
| YAML_PRETTIER | Fail ❌ |
<!-- textlint-enable terminology -->
Super-linter detected linting errors

View file

@ -1,8 +1,9 @@
# Super-linter summary
<!-- textlint-disable terminology -->
| Language | Validation result |
| -----------------------|-------------------|
| ---------------------------- | ----------------- |
| ANSIBLE | Fail ❌ |
| ARM | Fail ❌ |
| BASH | Fail ❌ |
@ -93,6 +94,7 @@
| XML | Fail ❌ |
| YAML | Fail ❌ |
| YAML_PRETTIER | Fail ❌ |
<!-- textlint-enable terminology -->
Super-linter detected linting errors

View file

@ -1,8 +1,9 @@
# Super-linter summary
<!-- textlint-disable terminology -->
| Language | Validation result |
| -----------------------|-------------------|
| ---------------------- | ----------------- |
| ANSIBLE | Pass ✅ |
| BASH | Pass ✅ |
| BASH_EXEC | Pass ✅ |
@ -83,6 +84,7 @@
| XML | Pass ✅ |
| YAML | Pass ✅ |
| YAML_PRETTIER | Pass ✅ |
<!-- textlint-enable terminology -->
All files and directories linted successfully

View file

@ -1,8 +1,9 @@
# Super-linter summary
<!-- textlint-disable terminology -->
| Language | Validation result |
| -----------------------|-------------------|
| ---------------------------- | ----------------- |
| ANSIBLE | Pass ✅ |
| ARM | Pass ✅ |
| BASH | Pass ✅ |
@ -93,6 +94,7 @@
| XML | Pass ✅ |
| YAML | Pass ✅ |
| YAML_PRETTIER | Pass ✅ |
<!-- textlint-enable terminology -->
All files and directories linted successfully

View file

@ -1,8 +1,9 @@
# Super-linter summary
<!-- textlint-disable terminology -->
| Language | Validation result |
| -----------------------|-------------------|
| ------------------- | ----------------- |
| ANSIBLE | Pass ✅ |
| CLANG_FORMAT | Pass ✅ |
| CSS | Pass ✅ |
@ -42,6 +43,7 @@
| TYPESCRIPT_STANDARD | Pass ✅ |
| VUE_PRETTIER | Pass ✅ |
| YAML_PRETTIER | Pass ✅ |
<!-- textlint-enable terminology -->
Super-linter detected linting errors

View file

@ -1,8 +1,9 @@
# Super-linter summary
<!-- textlint-disable terminology -->
| Language | Validation result |
| -----------------------|-------------------|
| ---------------------------- | ----------------- |
| ANSIBLE | Pass ✅ |
| CLANG_FORMAT | Pass ✅ |
| CSHARP | Pass ✅ |
@ -51,6 +52,7 @@
| TYPESCRIPT_STANDARD | Pass ✅ |
| VUE_PRETTIER | Pass ✅ |
| YAML_PRETTIER | Pass ✅ |
<!-- textlint-enable terminology -->
Super-linter detected linting errors

View file

@ -10,6 +10,9 @@ LOG_LEVEL="DEBUG"
# shellcheck source=/dev/null
source "lib/functions/log.sh"
# shellcheck source=/dev/null
source "test/testUtils.sh"
# shellcheck source=/dev/null
source "lib/functions/output.sh"
@ -24,14 +27,14 @@ function CleanupWorkspace() {
rm -rf "${TEMP_WORKSPACE}"
}
function CheckIfFileDiff() {
local INPUT_FILE="${1}"
local EXPECTED_FILE="${2}"
# Remove eventual HTML comments from the expected file because we use them to disable certain linter rules
if ! diff "${INPUT_FILE}" <(grep -vE '^\s*<!--' "${EXPECTED_FILE}"); then
fatal "${INPUT_FILE} contents don't match with the expected contents (${EXPECTED_FILE})"
CheckIfContentsDiff() {
local INPUT_FILE_CONTENT
INPUT_FILE_CONTENT="$(cat "${1}")"
local EXPECTED_CONTENT="${2}"
if [[ "${INPUT_FILE_CONTENT}" != "${EXPECTED_CONTENT}" ]]; then
fatal "\n${INPUT_FILE_CONTENT}\ncontents don't match the expected contents:\n${EXPECTED_CONTENT}"
else
echo "${INPUT_FILE} contents match with the expected contents (${EXPECTED_FILE})"
debug "\n${INPUT_FILE_CONTENT}\ncontents match the expected contents\n${EXPECTED_CONTENT}"
fi
}
@ -43,7 +46,16 @@ function WriteSummaryMarkdownTableHeaderTest() {
local RESULTS_FILE="${TEMP_WORKSPACE}/${FUNCTION_NAME}-output.md"
InitWorkspace
WriteSummaryHeader "${RESULTS_FILE}"
CheckIfFileDiff "${RESULTS_FILE}" "test/data/super-linter-summary/markdown/table/expected-summary-heading.md"
local EXPECTED_CONTENT
EXPECTED_CONTENT=$(
cat <<EOF
# Super-linter summary
| Language | Validation result |
| -------- | ----------------- |
EOF
)
CheckIfContentsDiff "${RESULTS_FILE}" "${EXPECTED_CONTENT}"
CleanupWorkspace
notice "${FUNCTION_NAME} PASS"
@ -57,7 +69,7 @@ function WriteSummaryMarkdownTableLineSuccessTest() {
local RESULTS_FILE="${TEMP_WORKSPACE}/${FUNCTION_NAME}-output-${FUNCTION_NAME}.md"
InitWorkspace
WriteSummaryLineSuccess "${RESULTS_FILE}" "Test Language"
CheckIfFileDiff "${RESULTS_FILE}" "test/data/super-linter-summary/markdown/table/expected-summary-line-success.md"
CheckIfContentsDiff "${RESULTS_FILE}" "| Test Language | Pass ✅ |"
CleanupWorkspace
notice "${FUNCTION_NAME} PASS"
@ -71,7 +83,7 @@ function WriteSummaryMarkdownTableLineFailureTest() {
local RESULTS_FILE="${TEMP_WORKSPACE}/${FUNCTION_NAME}-output-${FUNCTION_NAME}.md"
InitWorkspace
WriteSummaryLineFailure "${RESULTS_FILE}" "Test Language"
CheckIfFileDiff "${RESULTS_FILE}" "test/data/super-linter-summary/markdown/table/expected-summary-line-failure.md"
CheckIfContentsDiff "${RESULTS_FILE}" "| Test Language | Fail ❌ |"
CleanupWorkspace
notice "${FUNCTION_NAME} PASS"
@ -85,7 +97,14 @@ function WriteSummaryMarkdownTableFooterSuccessTest() {
local RESULTS_FILE="${TEMP_WORKSPACE}/${FUNCTION_NAME}-output-${FUNCTION_NAME}.md"
InitWorkspace
WriteSummaryFooterSuccess "${RESULTS_FILE}"
CheckIfFileDiff "${RESULTS_FILE}" "test/data/super-linter-summary/markdown/table/expected-summary-footer-success.md"
local EXPECTED_CONTENT
EXPECTED_CONTENT=$(
cat <<EOF
All files and directories linted successfully
EOF
)
CheckIfContentsDiff "${RESULTS_FILE}" "${EXPECTED_CONTENT}"
CleanupWorkspace
notice "${FUNCTION_NAME} PASS"
@ -99,7 +118,14 @@ function WriteSummaryMarkdownTableFooterFailureTest() {
local RESULTS_FILE="${TEMP_WORKSPACE}/${FUNCTION_NAME}-output-${FUNCTION_NAME}.md"
InitWorkspace
WriteSummaryFooterFailure "${RESULTS_FILE}"
CheckIfFileDiff "${RESULTS_FILE}" "test/data/super-linter-summary/markdown/table/expected-summary-footer-failure.md"
local EXPECTED_CONTENT
EXPECTED_CONTENT=$(
cat <<EOF
Super-linter detected linting errors
EOF
)
CheckIfContentsDiff "${RESULTS_FILE}" "${EXPECTED_CONTENT}"
CleanupWorkspace
notice "${FUNCTION_NAME} PASS"

View file

@ -359,15 +359,14 @@ else
fi
if [ -n "${EXPECTED_SUPER_LINTER_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_SUMMARY_FILE_PATH}" <(grep -vE '^\s*<!--' "${EXPECTED_SUPER_LINTER_SUMMARY_FILE_PATH}"); then
if ! AssertFileContentsMatchIgnoreHtmlComments "${SUPER_LINTER_SUMMARY_FILE_PATH}" "${EXPECTED_SUPER_LINTER_SUMMARY_FILE_PATH}"; then
debug "Super-linter summary (${SUPER_LINTER_SUMMARY_FILE_PATH}) contents don't match with the expected contents (${EXPECTED_SUPER_LINTER_SUMMARY_FILE_PATH})"
exit 1
else
debug "Super-linter summary (${SUPER_LINTER_SUMMARY_FILE_PATH}) contents match with the expected contents (${EXPECTED_SUPER_LINTER_SUMMARY_FILE_PATH})"
fi
if ! diff "${SUPER_LINTER_GITHUB_STEP_SUMMARY_FILE_PATH}" <(grep -vE '^\s*<!--' "${EXPECTED_SUPER_LINTER_SUMMARY_FILE_PATH}"); then
if ! AssertFileContentsMatchIgnoreHtmlComments "${SUPER_LINTER_GITHUB_STEP_SUMMARY_FILE_PATH}" "${EXPECTED_SUPER_LINTER_SUMMARY_FILE_PATH}"; then
debug "Super-linter GitHub step summary (${SUPER_LINTER_SUMMARY_FILE_PATH}) contents don't match with the expected contents (${EXPECTED_SUPER_LINTER_SUMMARY_FILE_PATH})"
exit 1
else
@ -450,7 +449,7 @@ if [[ "${VERIFY_FIX_MODE:-}" == "true" ]]; then
"${BAD_TEST_CASE_DESTINATION_PATH}"/*/target
fi
if AssertFileContentsMatch "${BAD_TEST_CASE_DESTINATION_PATH}" "${BAD_TEST_CASE_SOURCE_PATH}"; then
if AssertFileAndDirContentsMatch "${BAD_TEST_CASE_DESTINATION_PATH}" "${BAD_TEST_CASE_SOURCE_PATH}"; then
fatal "${BAD_TEST_CASE_DESTINATION_PATH} contents match ${BAD_TEST_CASE_SOURCE_PATH} contents and they should differ because fix mode for ${LANGUAGE} should have fixed linting and formatting issues."
fi
done

View file

@ -120,7 +120,7 @@ function CheckUnexpectedGitChanges() {
fi
}
AssertFileContentsMatch() {
AssertFileAndDirContentsMatch() {
local FILE_1_PATH="${1}"
local FILE_2_PATH="${2}"
if diff -r "${FILE_1_PATH}" "${FILE_2_PATH}"; then
@ -132,6 +132,20 @@ AssertFileContentsMatch() {
fi
}
AssertFileContentsMatchIgnoreHtmlComments() {
local FILE_1_PATH="${1}"
local FILE_2_PATH="${2}"
# Use cat -s to remove duplicate blank lines because Prettier adds blank
# lines after HTML comments in Markdown files
if diff "${FILE_1_PATH}" <(grep -vE '^\s*<!--' "${FILE_2_PATH}" | cat -s); then
echo "${FILE_1_PATH} contents match with ${FILE_2_PATH} contents"
return 0
else
echo "${FILE_1_PATH} contents don't match with ${FILE_2_PATH} contents"
return 1
fi
}
IsLanguageInSlimImage() {
local LANGUAGE="${1}"
if [[ " ${LANGUAGES_NOT_IN_SLIM_IMAGE[*]} " =~ [[:space:]]${LANGUAGE}[[:space:]] ]]; then