Skip to content

Commit 11d4aac

Browse files
authored
chore: format super-linter summaries (#6063)
Run Prettier to format the Super-linter summary file to produce summaries with consistent formatting.
1 parent a5c0cf2 commit 11d4aac

19 files changed

Lines changed: 553 additions & 508 deletions

.github/linters/.markdown-lint.yml

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,2 @@
11
---
2-
###########################
3-
###########################
4-
## Markdown Linter rules ##
5-
###########################
6-
###########################
7-
8-
# Linter rules doc:
9-
# - https://github.com/DavidAnson/markdownlint
10-
#
11-
# Note:
12-
# To comment out a single error:
13-
# <!-- markdownlint-disable -->
14-
# any violations you want
15-
# <!-- markdownlint-restore -->
16-
#
17-
18-
###############
19-
# Rules by id #
20-
###############
21-
MD004: false # Unordered list style
22-
MD007:
23-
indent: 2 # Unordered list indentation
24-
MD013:
25-
line_length: 808 # Line length
26-
MD026:
27-
punctuation: ".,;:!。,;:" # List of not allowed
28-
MD029: false # Ordered list item prefix
29-
MD033: false # Allow inline HTML
30-
MD036: false # Emphasis used instead of a heading
31-
32-
#################
33-
# Rules by tags #
34-
#################
35-
blank_lines: false # Error on blank lines
2+
extends: "markdownlint/style/prettier"

.prettierignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ open-shell-super-linter-container: ## Open a shell in the Super-linter container
145145
docker run $(DOCKER_FLAGS) \
146146
--interactive \
147147
--entrypoint /bin/bash \
148+
--rm \
148149
-v "$(CURDIR)":/tmp/lint \
149150
$(SUPER_LINTER_TEST_CONTAINER_URL)
150151

@@ -167,6 +168,7 @@ test-actions-runner-debug: ## Run super-linter with ACTIONS_RUNNER_DEBUG=true
167168
-e DEFAULT_BRANCH=main \
168169
-e USE_FIND_ALGORITHM=true \
169170
-v "$(CURDIR)/.github":/tmp/lint/.github \
171+
--rm \
170172
$(SUPER_LINTER_TEST_CONTAINER_URL)
171173

172174
.PHONY: test-actions-steps-debug
@@ -178,6 +180,7 @@ test-actions-steps-debug: ## Run super-linter with ACTIONS_STEPS_DEBUG=true
178180
-e DEFAULT_BRANCH=main \
179181
-e USE_FIND_ALGORITHM=true \
180182
-v "$(CURDIR)/.github":/tmp/lint/.github \
183+
--rm \
181184
$(SUPER_LINTER_TEST_CONTAINER_URL)
182185

183186
.PHONY: test-runner-debug
@@ -189,6 +192,7 @@ test-runner-debug: ## Run super-linter with RUNNER_DEBUG=1
189192
-e DEFAULT_BRANCH=main \
190193
-e USE_FIND_ALGORITHM=true \
191194
-v "$(CURDIR)/.github":/tmp/lint/.github \
195+
--rm \
192196
$(SUPER_LINTER_TEST_CONTAINER_URL)
193197

194198
.PHONY: test-find
@@ -200,6 +204,7 @@ test-find: ## Run super-linter on a subdirectory with USE_FIND_ALGORITHM=true
200204
-e DEFAULT_BRANCH=main \
201205
-e USE_FIND_ALGORITHM=true \
202206
-v "$(CURDIR)/.github":/tmp/lint/.github \
207+
--rm \
203208
$(SUPER_LINTER_TEST_CONTAINER_URL)
204209

205210
# 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
215220
-e USE_FIND_ALGORITHM=true \
216221
-e VALIDATE_ALL_CODEBASE=true \
217222
-v $(CURDIR)/.github:/tmp/not-default-workspace/.github \
223+
--rm \
218224
$(SUPER_LINTER_TEST_CONTAINER_URL)
219225

220226
.PHONY: test-git-flags
@@ -229,6 +235,7 @@ test-git-flags: ## Run super-linter with different git-related flags
229235
-e IGNORE_GITIGNORED_FILES=true \
230236
-e VALIDATE_ALL_CODEBASE=true \
231237
-v "$(CURDIR)":/tmp/lint \
238+
--rm \
232239
$(SUPER_LINTER_TEST_CONTAINER_URL)
233240

234241
.PHONY: lint-codebase
@@ -246,6 +253,7 @@ lint-codebase: ## Lint the entire codebase
246253
-e SAVE_SUPER_LINTER_SUMMARY=true \
247254
-e VALIDATE_ALL_CODEBASE=true \
248255
-v "$(CURDIR):/tmp/lint" \
256+
--rm \
249257
$(SUPER_LINTER_TEST_CONTAINER_URL)
250258

251259
# Return an error if there are changes to commit
@@ -273,6 +281,7 @@ fix-codebase: ## Fix and format the entire codebase
273281
-e SAVE_SUPER_LINTER_SUMMARY=true \
274282
-e VALIDATE_ALL_CODEBASE=true \
275283
-v "$(CURDIR):/tmp/lint" \
284+
--rm \
276285
$(SUPER_LINTER_TEST_CONTAINER_URL) \
277286
&& /bin/bash -c "source test/testUtils.sh; if ! CheckUnexpectedGitChanges ${CURDIR}; then exit 1; fi"
278287

@@ -293,6 +302,7 @@ lint-subset-files-enable-only-one-type: ## Lint a small subset of files in the c
293302
-e VALIDATE_ALL_CODEBASE=true \
294303
-e VALIDATE_MARKDOWN=true \
295304
-v "$(CURDIR):/tmp/lint" \
305+
--rm \
296306
$(SUPER_LINTER_TEST_CONTAINER_URL)
297307

298308
.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
312322
-e VALIDATE_STATES=true \
313323
-e VALIDATE_TEKTON=true \
314324
-v "$(CURDIR):/tmp/lint" \
325+
--rm \
315326
$(SUPER_LINTER_TEST_CONTAINER_URL)
316327

317328
.PHONY: test-lib
@@ -323,6 +334,7 @@ test-globals-languages: ## Test globals/languages.sh
323334
-v "$(CURDIR):/tmp/lint" \
324335
-w /tmp/lint \
325336
--entrypoint /tmp/lint/test/lib/globalsLanguagesTest.sh \
337+
--rm \
326338
$(SUPER_LINTER_TEST_CONTAINER_URL)
327339

328340
.PHONY: test-globals-linter-command-options
@@ -331,6 +343,7 @@ test-globals-linter-command-options: ## Test globals/LinterCommandsOptions.sh
331343
-v "$(CURDIR):/tmp/lint" \
332344
-w /tmp/lint \
333345
--entrypoint /tmp/lint/test/lib/globalsLinterCommandsOptionsTest.sh \
346+
--rm \
334347
$(SUPER_LINTER_TEST_CONTAINER_URL)
335348

336349
.PHONY: test-linter-rules
@@ -339,6 +352,7 @@ test-linter-rules: ## Test linterRules.sh
339352
-v "$(CURDIR):/tmp/lint" \
340353
-w /tmp/lint \
341354
--entrypoint /tmp/lint/test/lib/linterRulesTest.sh \
355+
--rm \
342356
$(SUPER_LINTER_TEST_CONTAINER_URL)
343357

344358
.PHONY: test-build-file-list
@@ -347,6 +361,7 @@ test-build-file-list: ## Test buildFileList
347361
-v "$(CURDIR):/tmp/lint" \
348362
-w /tmp/lint \
349363
--entrypoint /tmp/lint/test/lib/buildFileListTest.sh \
364+
--rm \
350365
$(SUPER_LINTER_TEST_CONTAINER_URL)
351366

352367
.PHONY: test-detect-files
@@ -355,6 +370,7 @@ test-detect-files: ## Test detectFiles
355370
-v "$(CURDIR):/tmp/lint" \
356371
-w /tmp/lint \
357372
--entrypoint /tmp/lint/test/lib/detectFilesTest.sh \
373+
--rm \
358374
$(SUPER_LINTER_TEST_CONTAINER_URL)
359375

360376
.PHONY: test-github-event
@@ -363,6 +379,7 @@ test-github-event: ## Test githubEvent
363379
-v "$(CURDIR):/tmp/lint" \
364380
-w /tmp/lint \
365381
--entrypoint /tmp/lint/test/lib/githubEventTest.sh \
382+
--rm \
366383
$(SUPER_LINTER_TEST_CONTAINER_URL)
367384

368385
.PHONY: test-setup-ssh
@@ -372,6 +389,7 @@ test-setup-ssh: ## Test setupSSH
372389
-v "$(CURDIR):/tmp/lint" \
373390
-w /tmp/lint \
374391
--entrypoint /tmp/lint/test/lib/setupSSHTest.sh \
392+
--rm \
375393
$(SUPER_LINTER_TEST_CONTAINER_URL)
376394

377395
.PHONY: test-validation
@@ -380,6 +398,7 @@ test-validation: ## Test validation
380398
-v "$(CURDIR):/tmp/lint" \
381399
-w /tmp/lint \
382400
--entrypoint /tmp/lint/test/lib/validationTest.sh \
401+
--rm \
383402
$(SUPER_LINTER_TEST_CONTAINER_URL)
384403

385404
.PHONY: test-output
@@ -388,6 +407,7 @@ test-output: ## Test output
388407
-v "$(CURDIR):/tmp/lint" \
389408
-w /tmp/lint \
390409
--entrypoint /tmp/lint/test/lib/outputTest.sh \
410+
--rm \
391411
$(SUPER_LINTER_TEST_CONTAINER_URL)
392412

393413
.PHONY: test-linter-commands
@@ -396,6 +416,7 @@ test-linter-commands: ## Test linterCommands
396416
-v "$(CURDIR):/tmp/lint" \
397417
-w /tmp/lint \
398418
--entrypoint /tmp/lint/test/lib/linterCommandsTest.sh \
419+
--rm \
399420
$(SUPER_LINTER_TEST_CONTAINER_URL)
400421

401422
# 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
410431
-e DEFAULT_BRANCH=main \
411432
-e USE_FIND_ALGORITHM=true \
412433
-v "$(CURDIR)/docs":/tmp/lint \
434+
--rm \
413435
$(SUPER_LINTER_TEST_CONTAINER_URL)
414436

415437
.PHONY: test-custom-ssl-cert
@@ -422,6 +444,7 @@ test-custom-ssl-cert: ## Test the configuration of a custom SSL/TLS certificate
422444
-e USE_FIND_ALGORITHM=true \
423445
-e SSL_CERT_SECRET="$(shell cat test/data/ssl-certificate/rootCA-test.crt)" \
424446
-v "$(CURDIR)/docs":/tmp/lint \
447+
--rm \
425448
$(SUPER_LINTER_TEST_CONTAINER_URL)
426449

427450
.PHONY: test-non-default-home-directory
@@ -562,6 +585,7 @@ build-dev-container-image: docker-dev-container-build-check ## Build commit lint
562585
lint-commits: build-dev-container-image ## Lint commits
563586
docker run \
564587
-v "$(CURDIR):/source-repository" \
588+
--rm \
565589
${DEV_CONTAINER_URL} \
566590
commitlint \
567591
--config .github/linters/commitlint.config.js \
@@ -575,6 +599,7 @@ release-please-dry-run: build-dev-container-image check-github-token ## Run rele
575599
@echo "Running release-please against branch: ${RELEASE_PLEASE_TARGET_BRANCH}"; \
576600
docker run \
577601
-v "$(CURDIR):/source-repository" \
602+
--rm \
578603
${DEV_CONTAINER_URL} \
579604
release-please \
580605
release-pr \

lib/functions/output.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ WriteSummaryHeader() {
66
{
77
echo "# Super-linter summary"
88
echo ""
9-
echo "| Language | Validation result |"
10-
echo "| -----------------------|-------------------|"
9+
echo "| Language | Validation result |"
10+
echo "| -------- | ----------------- |"
1111
} >>"${SUPER_LINTER_SUMMARY_OUTPUT_PATH}"
1212
}
1313

@@ -38,3 +38,20 @@ WriteSummaryFooterFailure() {
3838
echo "Super-linter detected linting errors"
3939
} >>"${SUPER_LINTER_SUMMARY_OUTPUT_PATH}"
4040
}
41+
42+
FormatSuperLinterSummaryFile() {
43+
local SUPER_LINTER_SUMMARY_OUTPUT_PATH="${1}"
44+
local SUPER_LINTER_SUMMARY_FORMAT_COMMAND=(prettier --write)
45+
# Override the default prettier ignore paths (.gitignore, .prettierignore) to
46+
# avoid considering their defaults because prettier will skip formatting
47+
# the summary report file if the summary report file is ignored in those
48+
# ignore files, which is usually the case for generated files.
49+
# Ref: https://prettier.io/docs/en/cli#--ignore-path
50+
SUPER_LINTER_SUMMARY_FORMAT_COMMAND+=(--ignore-path /dev/null)
51+
SUPER_LINTER_SUMMARY_FORMAT_COMMAND+=("${SUPER_LINTER_SUMMARY_OUTPUT_PATH}")
52+
debug "Formatting the Super-linter summary file by running: ${SUPER_LINTER_SUMMARY_FORMAT_COMMAND[*]}"
53+
if ! "${SUPER_LINTER_SUMMARY_FORMAT_COMMAND[@]}"; then
54+
error "Error while formatting the Super-linter summary file."
55+
return 1
56+
fi
57+
}

lib/linter.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,9 @@ Footer() {
561561
fi
562562

563563
if [[ "${SAVE_SUPER_LINTER_SUMMARY}" == "true" ]]; then
564+
if ! FormatSuperLinterSummaryFile "${SUPER_LINTER_SUMMARY_OUTPUT_PATH}"; then
565+
fatal "Error while formatting the Super-linter summary file."
566+
fi
564567
debug "Super-linter summary file (${SUPER_LINTER_SUMMARY_OUTPUT_PATH}) contents:\n$(cat "${SUPER_LINTER_SUMMARY_OUTPUT_PATH}")"
565568
fi
566569

test/data/super-linter-summary/markdown/table/expected-summary-footer-failure.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/data/super-linter-summary/markdown/table/expected-summary-footer-success.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/data/super-linter-summary/markdown/table/expected-summary-heading.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/data/super-linter-summary/markdown/table/expected-summary-line-failure.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/data/super-linter-summary/markdown/table/expected-summary-line-success.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)