Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (59 loc) · 2.56 KB
/
Copy pathMakefile
File metadata and controls
77 lines (59 loc) · 2.56 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
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
help:
@echo "Various utilities for managing the terragrunt repository"
fmt:
@echo "Running source files through gofmt..."
gofmt -w $(GOFMT_FILES)
fmtcheck:
pre-commit run goimports --all-files
install-pre-commit-hook:
pre-commit install
# This build target just for convenience for those building directly from
# source. See also: .github/workflows/build.yml
build: terragrunt
terragrunt: $(shell find . \( -type d -name 'vendor' -prune \) \
-o \( -type f -name '*.go' -print \) )
set -xe ;\
vtag_maybe_extra=$$(git describe --tags --abbrev=12 --dirty --broken) ;\
CGO_ENABLED=0 go build -o $@ -ldflags "-s -w -X github.com/gruntwork-io/terragrunt/internal/version.Version=$${vtag_maybe_extra}" .
clean:
rm -f terragrunt
IGNORE_TAGS := windows|linux|darwin|freebsd|openbsd|netbsd|dragonfly|solaris|plan9|js|wasip1|aix|android|illumos|ios|386|amd64|arm|arm64|mips|mips64|mips64le|mipsle|ppc64|ppc64le|riscv64|s390x|wasm
LINT_TAGS := $(shell grep -rh --include='*.go' 'go:build' . | \
sed 's/.*go:build\s*//' | \
tr -cs '[:alnum:]_' '\n' | \
grep -vE '^($(IGNORE_TAGS))$$' | \
sed '/^$$/d' | \
sort -u | \
paste -sd, -)
print-lint-tags:
@echo '$(LINT_TAGS)'
run-lint:
@echo "Linting with feature flags: [$(LINT_TAGS)]"
GOFLAGS="-tags=$(LINT_TAGS)" mise x golangci-lint -- golangci-lint run -v --timeout=30m ./...
run-lint-incremental:
@echo "Incremental lint (new issues only) with feature flags: [$(LINT_TAGS)]"
GOFLAGS="-tags=$(LINT_TAGS)" mise x golangci-lint -- golangci-lint run -v --timeout=30m --new-from-merge-base=main ./...
run-lint-fix:
@echo "Linting with feature flags: [$(LINT_TAGS)]"
GOFLAGS="-tags=$(LINT_TAGS)" mise x golangci-lint -- golangci-lint run -v --timeout=30m --fix ./...
# go fix only analyzes files whose build tags are satisfied, so a bare `go fix ./...`
# skips every tagged package without reporting it.
run-go-fix:
@echo "Running go fix with feature flags: [$(LINT_TAGS)]"
mise x go -- go fix -tags=$(LINT_TAGS) ./...
@echo "Reformatting, since go fix does not gofmt the code it rewrites..."
mise x go -- gofmt -w $(GOFMT_FILES)
run-go-fix-check:
@echo "Checking go fix with feature flags: [$(LINT_TAGS)]"
mise x go -- go fix -diff -tags=$(LINT_TAGS) ./...
generate-mocks:
go generate ./...
license-check:
go mod vendor
licensei cache --debug
licensei check --debug
licensei header --debug
fuzz:
./.github/scripts/ci/run-fuzz.sh
.PHONY: help fmt fmtcheck install-pre-commit-hook clean run-lint run-lint-fix run-go-fix run-go-fix-check fuzz print-lint-tags