forked from super-linter/super-linter
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
725 lines (642 loc) · 27 KB
/
Makefile
File metadata and controls
725 lines (642 loc) · 27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
# Inspired by https://github.com/jessfraz/dotfiles
.PHONY: all
all: info docker test ## Run all targets.
.PHONY: test ## Run the test suite
test: \
info \
validate-container-image-labels \
docker-build-check \
docker-dev-container-build-check \
composer-audit \
npm-audit \
pip-audit \
test-lib \
inspec \
lint-codebase \
fix-codebase \
lint-subset-files \
test-non-default-home-directory \
test-save-super-linter-output \
test-save-super-linter-output-custom-path \
test-save-super-linter-custom-summary \
test-dont-save-super-linter-log-file \
test-dont-save-super-linter-output \
test-git-invalid-worktree \
test-git-valid-worktree \
test-github-event-initial-commit \
test-github-event-merge-commit-push-default-branch \
test-github-event-merge-commit-push-tag \
test-github-event-merge-group \
test-github-event-repository-dispatch \
test-github-event-pr-event-multiple-commits \
test-github-event-push-event-multiple-commits-default-branch \
test-github-event-push-event-multiple-commits-use-find-algorithm-and-ignore-gitignored-files-default-branch \
test-github-event-push-event-multiple-commits-use-find-algorithm-default-branch \
test-github-event-push-initial-commit-multiple-commits \
test-github-event-push-force-push \
test-github-event-push-force-push-multiple-commits \
test-runtime-dependencies-installation \
test-linters-bash-exec-ignore-libraries-expect-failure \
test-linters-bash-exec-ignore-libraries-expect-success \
test-linters-expect-failure \
test-linters-expect-failure-log-level-notice \
test-linters-expect-failure-suppress-output-on-success \
test-linters-expect-failure-suppress-output-on-success-log-level-notice \
test-linters-expect-success \
test-linters-expect-success-log-level-notice \
test-linters-expect-success-suppress-output-on-success \
test-linters-expect-success-suppress-output-on-success-log-level-notice \
test-linters-fix-mode
SHELL := /bin/bash
# if this session isn't interactive, then we don't want to allocate a
# TTY, which would fail, but if it is interactive, we do want to attach
# so that the user can send e.g. ^C through.
INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0)
ifeq ($(INTERACTIVE), 1)
DOCKER_FLAGS += -t
endif
.PHONY: help
help: ## Show help
@grep -E ':.*?##(.*)$$' $(MAKEFILE_LIST) | grep -v 'MAKEFILE_LIST' | sed -E 's/^\.PHONY: *([a-zA-Z_-]+) */\1:/' | sort | awk 'BEGIN {FS = ":.*?## "; max_len = 0}; { f1[NR] = $$1; f2[NR] = $$2; if (length($$1) > max_len) { max_len = length($$1) } } END { padding = max_len + 1; for (i = 1; i <= NR; i++) { printf("\033[36m%-" padding "s\033[0m %s\n", f1[i], f2[i]) } }'
.PHONY: inspec-check
inspec-check: ## Validate inspec profiles
docker run $(DOCKER_FLAGS) \
--rm \
-v "$(CURDIR)":/workspace \
-w="/workspace" \
chef/inspec check \
--chef-license=accept \
test/inspec/super-linter
SUPER_LINTER_TEST_CONTAINER_NAME := "super-linter-test"
SUPER_LINTER_TEST_CONTAINER_URL := $(CONTAINER_IMAGE_ID)
DOCKERFILE := ''
IMAGE := $(CONTAINER_IMAGE_TARGET)
# Default to stadard
ifeq ($(IMAGE),)
IMAGE := standard
IMAGE_PREFIX :=
endif
ifeq ($(IMAGE),slim)
IMAGE_PREFIX := slim-
endif
ifeq ($(SUPER_LINTER_TEST_CONTAINER_URL),)
# Default to the latest tag
SUPER_LINTER_TEST_CONTAINER_URL := "ghcr.io/super-linter/super-linter:${IMAGE_PREFIX}latest"
else
SUPER_LINTER_TEST_CONTAINER_URL := ${CONTAINER_IMAGE_ID}
endif
GITHUB_TOKEN_PATH := "$(CURDIR)/.github-personal-access-token"
ifeq ($(GITHUB_TOKEN),)
GITHUB_TOKEN="$(shell cat "${GITHUB_TOKEN_PATH}")"
endif
DEV_CONTAINER_URL := "super-linter/dev-container:latest"
ifeq ($(GITHUB_HEAD_REF),)
RELEASE_PLEASE_TARGET_BRANCH := "$(shell git branch --show-current)"
else
RELEASE_PLEASE_TARGET_BRANCH := "${GITHUB_HEAD_REF}"
endif
.PHONY: info
info: ## Gather information about the runtime environment
set -o errexit; \
. scripts/build-metadata.sh; \
echo "whoami: $$(whoami)"; \
echo "pwd: $$(pwd)"; \
echo "IMAGE:" $(IMAGE); \
echo "IMAGE_PREFIX: $(IMAGE_PREFIX)"; \
echo "Container image ID: ${CONTAINER_IMAGE_ID}"; \
echo "SUPER_LINTER_TEST_CONTAINER_URL: $(SUPER_LINTER_TEST_CONTAINER_URL)"; \
echo "ls -ahl:\n$$(ls -ahl)"; \
docker images; \
docker ps; \
echo "Container image layers size:"; \
docker history \
--human \
--no-trunc \
--format "{{.Size}} {{.CreatedSince}} {{.CreatedBy}}" \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
| sort --human
.PHONY: check-github-token-file
check-github-token-file:
@if [ ! -f "${GITHUB_TOKEN_PATH}" ]; then echo "Cannot find the file to load the GitHub access token: $(GITHUB_TOKEN_PATH). Create a readable file there, and populate it with a GitHub personal access token."; exit 1; fi
.PHONY: check-github-token
check-github-token: check-github-token-file
@if ! curl \
--fail \
-o /dev/null \
--silent \
-H "Authorization: Bearer $(shell cat "${GITHUB_TOKEN_PATH}")" \
https://api.github.com/rate_limit; then \
echo "GitHub token not valid or might be expired"; \
exit 1; \
else \
echo "GitHub token successfully validated"; \
fi
.PHONY: inspec
inspec: inspec-check ## Run InSpec tests
DOCKER_CONTAINER_STATE="$$(docker inspect --format "{{.State.Running}}" $(SUPER_LINTER_TEST_CONTAINER_NAME) 2>/dev/null || echo "")"; \
if [ "$$DOCKER_CONTAINER_STATE" = "true" ]; then docker kill $(SUPER_LINTER_TEST_CONTAINER_NAME); fi && \
docker tag $(SUPER_LINTER_TEST_CONTAINER_URL) $(SUPER_LINTER_TEST_CONTAINER_NAME) && \
SUPER_LINTER_TEST_CONTAINER_ID="$$(docker run -d --name $(SUPER_LINTER_TEST_CONTAINER_NAME) --rm -it --entrypoint /bin/ash $(SUPER_LINTER_TEST_CONTAINER_NAME) -c "while true; do sleep 1; done")" \
&& docker run $(DOCKER_FLAGS) \
--rm \
-v "$(CURDIR)":/workspace \
-v /var/run/docker.sock:/var/run/docker.sock \
-e IMAGE=$(IMAGE) \
-w="/workspace" \
chef/inspec exec test/inspec/super-linter \
--chef-license=accept \
--diagnose \
--log-level=debug \
-t "docker://$${SUPER_LINTER_TEST_CONTAINER_ID}" \
&& docker ps \
&& docker kill $(SUPER_LINTER_TEST_CONTAINER_NAME)
.PHONY: docker
docker: docker-build-check check-github-token ## Build the container image
set -o errexit; \
. scripts/build-metadata.sh; \
DOCKER_BUILDKIT=1 docker buildx build --load \
--build-arg BUILD_DATE=$${BUILD_DATE} \
--build-arg BUILD_REVISION=$${BUILD_REVISION} \
--build-arg BUILD_VERSION=$${BUILD_VERSION} \
--cache-from type=registry,ref=ghcr.io/super-linter/super-linter:${IMAGE_PREFIX}latest-buildcache \
--cache-from type=registry,ref=ghcr.io/super-linter/super-linter:latest-buildcache-base_image \
--cache-from type=registry,ref=ghcr.io/super-linter/super-linter:latest-buildcache-clang-format \
--cache-from type=registry,ref=ghcr.io/super-linter/super-linter:latest-buildcache-python-builder \
--cache-from type=registry,ref=ghcr.io/super-linter/super-linter:latest-buildcache-npm-builder \
--cache-from type=registry,ref=ghcr.io/super-linter/super-linter:latest-buildcache-tflint-plugins \
--cache-from type=registry,ref=ghcr.io/super-linter/super-linter:latest-buildcache-lintr-installer \
--cache-from type=registry,ref=ghcr.io/super-linter/super-linter:latest-buildcache-powershell-installer \
--cache-from type=registry,ref=ghcr.io/super-linter/super-linter:latest-buildcache-php-linters \
--cache-from type=registry,ref=ghcr.io/super-linter/super-linter:latest-buildcache-ruby-installer \
--secret id=GITHUB_TOKEN,src=$(GITHUB_TOKEN_PATH) \
--target $(IMAGE) \
-t $(SUPER_LINTER_TEST_CONTAINER_URL) .
.PHONY: docker-build-check ## Run Docker build checks against the Super-linter image
docker-build-check:
DOCKER_BUILDKIT=1 docker buildx build --check \
.
.PHONY: docker-pull
docker-pull: ## Pull the container image from registry
docker pull $(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: open-shell-super-linter-container
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 \
-v "$(CURDIR)/dependencies/Gemfile.lock":/Gemfile.lock \
-v "$(CURDIR)/dependencies/Gemfile":/Gemfile \
-v "$(CURDIR)/dependencies/package-lock.json":/package-lock.json \
-v "$(CURDIR)/dependencies/package.json":/package.json \
-v "$(CURDIR)/dependencies/composer/composer.json":/php-composer/composer.json \
-v "$(CURDIR)/dependencies/composer/composer.lock":/php-composer/composer.lock \
-v "$(CURDIR)/scripts/bash-exec.sh":/usr/bin/bash-exec \
-v "$(CURDIR)/scripts/git-merge-conflict-markers.sh":/usr/bin/git-merge-conflict-markers \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: validate-container-image-labels
validate-container-image-labels: ## Validate container image labels
set -o errexit; \
. scripts/build-metadata.sh; \
$(CURDIR)/test/validate-docker-labels.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
$${BUILD_DATE} \
$${BUILD_REVISION} \
$${BUILD_VERSION}
.PHONY: composer-audit
composer-audit: ## Run composer audit to check for known vulnerable dependencies
docker run $(DOCKER_FLAGS) \
--entrypoint /bin/bash \
--rm \
-v "$(CURDIR)/dependencies/composer/composer.json":/php-composer/composer.json \
-v "$(CURDIR)/dependencies/composer/composer.lock":/php-composer/composer.lock \
--workdir /php-composer \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
-c "composer audit"
.PHONY: npm-audit
npm-audit: ## Run npm audit to check for known vulnerable dependencies
docker run $(DOCKER_FLAGS) \
--entrypoint /bin/bash \
--rm \
-v "$(CURDIR)/dependencies/package-lock.json":/package-lock.json \
-v "$(CURDIR)/dependencies/package.json":/package.json \
--workdir / \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
-c "npm audit"
.PHONY: pip-audit
pip-audit: ## Run pip-audit to check for known vulnerable dependencies
docker run $(DOCKER_FLAGS) \
--entrypoint /run-pip-audit.sh \
--rm \
-v "$(CURDIR)/scripts/run-pip-audit.sh":/run-pip-audit.sh \
--workdir / \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: lint-codebase
lint-codebase: ## Lint the entire codebase
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"lint_codebase" \
"$(IMAGE)"
# Return an error if there are changes to commit
.PHONY: fix-codebase
fix-codebase: ## Fix and format the entire codebase
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"fix_codebase" \
"$(IMAGE)"
# This is a smoke test to check how much time it takes to lint only a small
# subset of files, compared to linting the whole codebase.
.PHONY: lint-subset-files
lint-subset-files: lint-subset-files-enable-only-one-type lint-subset-files-enable-expensive-io-checks
.PHONY: lint-subset-files-enable-only-one-type
lint-subset-files-enable-only-one-type: ## Lint a small subset of files in the codebase by enabling only one linter
time docker run \
-e RUN_LOCAL=true \
-e LOG_LEVEL=DEBUG \
-e DEFAULT_BRANCH=main \
-e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \
-e FILTER_REGEX_EXCLUDE=".*(/test/linters/|CHANGELOG.md|/test/data/test-repository-contents/).*" \
-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
lint-subset-files-enable-expensive-io-checks: ## Lint a small subset of files in the codebase and keep expensive I/O operations to check file types enabled
time docker run \
-e RUN_LOCAL=true \
-e LOG_LEVEL=DEBUG \
-e DEFAULT_BRANCH=main \
-e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \
-e FILTER_REGEX_EXCLUDE=".*(/test/linters/|CHANGELOG.md|/test/data/test-repository-contents/).*" \
-e VALIDATE_ALL_CODEBASE=true \
-e VALIDATE_ARM=true \
-e VALIDATE_CLOUDFORMATION=true \
-e VALIDATE_KUBERNETES_KUBECONFORM=true \
-e VALIDATE_MARKDOWN=true \
-e VALIDATE_OPENAPI=true \
-e VALIDATE_STATES=true \
-v "$(CURDIR):/tmp/lint" \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-lib ## Test super-linter libs and globals
test-lib: \
test-log \
test-globals-languages \
test-linter-rules \
test-build-file-list \
test-detect-files \
test-github-event \
test-setup-ssh \
test-validation \
test-output \
test-linter-commands \
test-linter-versions \
test-update-ssl \
test-bash-exec
.PHONY: test-log
test-log: ## Test log initialization and functions
docker run \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/logTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-globals-languages
test-globals-languages: ## Test globals/languages.sh
docker run \
-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
test-globals-linter-command-options: ## Test globals/LinterCommandsOptions.sh
docker run \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/globalsLinterCommandsOptionsTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-linter-rules
test-linter-rules: ## Test linterRules.sh
docker run \
-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
test-build-file-list: ## Test buildFileList
docker run \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/buildFileListTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-detect-files
test-detect-files: ## Test detectFiles
docker run \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/detectFilesTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-github-event
test-github-event: ## Test githubEvent
docker run \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/githubEventTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-setup-ssh
test-setup-ssh: ## Test setupSSH
@docker run \
-e GITHUB_TOKEN=${GITHUB_TOKEN} \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/setupSSHTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-validation
test-validation: ## Test validation
docker run \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/validationTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-output
test-output: ## Test output
docker run \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/outputTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-linter-commands
test-linter-commands: ## Test linterCommands
docker run \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/linterCommandsTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-linter-versions
test-linter-versions: ## Test linterVersions
docker run \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/linterVersionsTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-update-ssl
test-update-ssl: ## Test updateSSL
docker run \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/updateSSLTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-bash-exec
test-bash-exec: ## Test bash-exec
docker run \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/bashExecTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-runtime-dependencies-installation ## Test runtime dependencies installation
test-runtime-dependencies-installation: \
test-os-packages-installation
.PHONY: test-os-packages-installation
test-os-packages-installation: ## Test installing OS packages
docker run \
-v "$(CURDIR):/tmp/lint" \
-w /tmp/lint \
--entrypoint /tmp/lint/test/lib/osPackagesInstallationTest.sh \
--rm \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.PHONY: test-non-default-home-directory
test-non-default-home-directory: ## Test a non-default HOME directory
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_non_default_home" \
"$(IMAGE)"
.PHONY: test-linters-fix-mode
test-linters-fix-mode: ## Run the linters test suite (fix mode)
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_fix_mode" \
"$(IMAGE)"
.PHONY: test-linters-expect-success
test-linters-expect-success: ## Run the linters test suite expecting successes
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_expect_success" \
"$(IMAGE)"
.PHONY: test-linters-bash-exec-ignore-libraries-expect-failure
test-linters-bash-exec-ignore-libraries-expect-failure: ## Run the bash-exec linter test expecting failures
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_bash_exec_ignore_libraries_expect_failure" \
"$(IMAGE)"
.PHONY: test-linters-bash-exec-ignore-libraries-expect-success
test-linters-bash-exec-ignore-libraries-expect-success: ## Run the bash-exec linter test expecting successes
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_bash_exec_ignore_libraries_expect_success" \
"$(IMAGE)"
.PHONY: test-linters-expect-failure
test-linters-expect-failure: ## Run the linters test suite expecting failures
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_expect_failure" \
"$(IMAGE)"
# Useful to check if any tool is using the LOG_LEVEL variable, besides Super-linter
.PHONY: test-linters-expect-success-log-level-notice
test-linters-expect-success-log-level-notice: ## Run the linters test suite expecting success with a LOG_LEVEL set to NOTICE
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_expect_success_notice_log" \
"$(IMAGE)"
.PHONY: test-linters-expect-success-suppress-output-on-success
test-linters-expect-success-suppress-output-on-success: ## Run the linters test suite expecting successes but suppressing output
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_expect_success_suppress_output_on_success" \
"$(IMAGE)"
.PHONY: test-linters-expect-failure-suppress-output-on-success-log-level-notice
test-linters-expect-failure-suppress-output-on-success-log-level-notice: ## Run the linters test suite expecting failures but suppressing output, with a LOG_LEVEL set to NOTICE
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_expect_failure_suppress_output_on_success_notice_log" \
"$(IMAGE)"
.PHONY: test-linters-expect-success-suppress-output-on-success-log-level-notice
test-linters-expect-success-suppress-output-on-success-log-level-notice: ## Run the linters test suite expecting successes but suppressing output, with a LOG_LEVEL set to NOTICE
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_expect_success_suppress_output_on_success_notice_log" \
"$(IMAGE)"
.PHONY: test-linters-expect-failure-suppress-output-on-success
test-linters-expect-failure-suppress-output-on-success: ## Run the linters test suite expecting falires but suppressing output
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_expect_failure_suppress_output_on_success" \
"$(IMAGE)"
.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
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_expect_failure_notice_log" \
"$(IMAGE)"
.PHONY: test-github-event-initial-commit
test-github-event-initial-commit: ## Run super-linter against a repository that only has one commit
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_git_initial_commit" \
"$(IMAGE)"
.PHONY: test-github-event-merge-commit-push-default-branch
test-github-event-merge-commit-push-default-branch: ## Run super-linter against a repository that has merge commits on a push event
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_merge_commit_push_default_branch" \
"$(IMAGE)"
.PHONY: test-github-event-merge-commit-push-tag
test-github-event-merge-commit-push-tag: ## Run super-linter against a repository that has merge commits and pushed a tag
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_merge_commit_push_tag" \
"$(IMAGE)"
.PHONY: test-github-event-pr-event-multiple-commits
test-github-event-pr-event-multiple-commits: ## Run super-linter against a repository that simulates a pull request event with multiple commits
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_github_pr_event_multiple_commits" \
"$(IMAGE)"
.PHONY: test-github-event-push-event-multiple-commits-default-branch
test-github-event-push-event-multiple-commits-default-branch: ## Run super-linter against a repository that simulates a push event with multiple commits
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_github_push_event_multiple_commits_default_branch" \
"$(IMAGE)"
.PHONY: test-github-event-push-event-multiple-commits-use-find-algorithm-default-branch
test-github-event-push-event-multiple-commits-use-find-algorithm-default-branch: ## Run super-linter setting USE_FIND_ALGORITHM=true on a GitHub event
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_github_push_event_multiple_commits_use_find_algorithm_default_branch" \
"$(IMAGE)"
.PHONY: test-github-event-push-initial-commit-multiple-commits
test-github-event-push-initial-commit-multiple-commits: ## Run super-linter on a push event pushing the initial commit plus other commits
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_github_push_initial_commit_multiple_commits" \
"$(IMAGE)"
.PHONY: test-github-event-push-force-push
test-github-event-push-force-push: ## Run super-linter on a force push event
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_github_push_force_push" \
"$(IMAGE)"
.PHONY: test-github-event-push-force-push-multiple-commits
test-github-event-push-force-push-multiple-commits: ## Run super-linter on a force push event with multiple commits
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_github_push_force_push_multiple_commits" \
"$(IMAGE)"
.PHONY: test-github-event-merge-group
test-github-event-merge-group: ## Run super-linter against a repository that simulates a merge_group event
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_github_merge_group_event" \
"$(IMAGE)"
.PHONY: test-github-event-repository-dispatch
test-github-event-repository-dispatch: ## Run super-linter against a repository that simulates a repository_dispatch event
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_github_repository_dispatch" \
"$(IMAGE)"
.PHONY: test-github-event-push-event-multiple-commits-use-find-algorithm-and-ignore-gitignored-files-default-branch
test-github-event-push-event-multiple-commits-use-find-algorithm-and-ignore-gitignored-files-default-branch: ## Run super-linter with USE_FIND_ALGORITHM=true and IGNORE_GITIGNORED_FILES=true on a push event
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_github_push_event_multiple_commits_use_find_and_ignore_gitignored_files" \
"$(IMAGE)"
.PHONY: test-save-super-linter-output
test-save-super-linter-output: ## Run super-linter with SAVE_SUPER_LINTER_OUTPUT=true
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_save_super_linter_output" \
"$(IMAGE)"
.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
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_cases_save_super_linter_output_custom_path" \
"$(IMAGE)"
.PHONY: test-save-super-linter-custom-summary
test-save-super-linter-custom-summary: ## Run super-linter with a custom SUPER_LINTER_SUMMARY_FILE_NAME
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_custom_summary" \
"$(IMAGE)"
.PHONY: test-dont-save-super-linter-log-file
test-dont-save-super-linter-log-file: ## Run super-linter without saving the Super-linter log file
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_dont_save_super_linter_log_file" \
"$(IMAGE)"
.PHONY: test-dont-save-super-linter-output
test-dont-save-super-linter-output: ## Run super-linter without saving Super-linter output files
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_dont_save_super_linter_output" \
"$(IMAGE)"
.PHONY: test-git-invalid-worktree
test-git-invalid-worktree: ## Run super-linter against a Git repository with worktrees
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_git_invalid_worktree" \
"$(IMAGE)"
.PHONY: test-git-valid-worktree
test-git-valid-worktree: ## Run super-linter against a Git repository with worktrees
$(CURDIR)/test/run-super-linter-tests.sh \
$(SUPER_LINTER_TEST_CONTAINER_URL) \
"run_test_case_git_valid_worktree" \
"$(IMAGE)"
.PHONY: docker-dev-container-build-check ## Run Docker build checks against the dev-container image
docker-dev-container-build-check:
DOCKER_BUILDKIT=1 docker buildx build --check \
"${CURDIR}/dev-dependencies"
.PHONY: build-dev-container-image
build-dev-container-image: docker-dev-container-build-check ## Build commit linter container image
DOCKER_BUILDKIT=1 docker buildx build --load \
--build-arg GID=$(shell id -g) \
--build-arg UID=$(shell id -u) \
-t ${DEV_CONTAINER_URL} "${CURDIR}/dev-dependencies"
.PHONY: release-please-dry-run
release-please-dry-run: build-dev-container-image check-github-token ## Run release-please in dry-run mode to preview the release pull request
@echo "Running release-please against branch: ${RELEASE_PLEASE_TARGET_BRANCH}"; \
docker run \
-v "$(CURDIR):/source-repository" \
--rm \
${DEV_CONTAINER_URL} \
release-please \
release-pr \
--config-file .github/release-please/release-please-config.json \
--dry-run \
--manifest-file .github/release-please/.release-please-manifest.json \
--repo-url super-linter/super-linter \
--target-branch ${RELEASE_PLEASE_TARGET_BRANCH} \
--token "${GITHUB_TOKEN}" \
--trace
.PHONY: open-shell-dev-container
open-shell-dev-container: build-dev-container-image ## Open a shell in the dev tools container
docker run $(DOCKER_FLAGS) \
--interactive \
--entrypoint /bin/bash \
--rm \
-v "$(CURDIR)/dev-dependencies/package-lock.json":/app/package-lock.json \
-v "$(CURDIR)/dev-dependencies/package.json":/app/package.json \
$(DEV_CONTAINER_URL)