Skip to content

Commit 8242fbe

Browse files
committed
Clean up makefile
1 parent 3b27455 commit 8242fbe

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

GNUmakefile

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,45 @@ TEST_COUNT ?= 1
2323
# - docs/makefile-cheat-sheet.md
2424
# - docs/continuous-integration.md
2525

26+
# VARIABLE REFERENCE:
27+
# Service-specific variables (interchangeable for user convenience):
28+
# PKG=<service> - Service name (e.g., ses, lambda, s3) - traditional usage
29+
# K=<service> - Service name (e.g., ses, lambda, s3) - shorter alias
30+
#
31+
# Test-specific variables:
32+
# T=<pattern> - Test name pattern (e.g., TestAccLambda) - preferred
33+
# TESTS=<pattern> - Test name pattern - legacy alias for T
34+
#
35+
# Derived variables (set automatically based on above):
36+
# PKG_NAME - Full package path (e.g., internal/service/ses)
37+
# SVC_DIR - Service directory path (e.g., ./internal/service/ses)
38+
# TEST - Test path pattern (e.g., ./internal/service/ses/...)
39+
#
40+
# Examples:
41+
# make quick-fix PKG=ses # Fix code in SES service
42+
# make quick-fix K=lambda # Same as above, but shorter (both work)
43+
# make t T=TestAccRole PKG=iam # Run specific test in IAM service
44+
45+
# Variable consolidation for backward compatibility and user convenience:
46+
# - PKG and K both refer to service names (e.g., 'ses', 'lambda')
47+
# - If one is provided, automatically set the other for consistency
48+
# - This allows 'make quick-fix PKG=ses' and 'make quick-fix K=ses' to work identically
2649
ifneq ($(origin PKG), undefined)
2750
PKG_NAME = internal/service/$(PKG)
2851
SVC_DIR = ./internal/service/$(PKG)
2952
TEST = ./$(PKG_NAME)/...
53+
# Auto-set K for compatibility
54+
K = $(PKG)
3055
endif
3156

3257
ifneq ($(origin K), undefined)
3358
PKG_NAME = internal/service/$(K)
34-
SVC_DIR = ./internal/service/$(PKG)
59+
SVC_DIR = ./internal/service/$(K)
3560
TEST = ./$(PKG_NAME)/...
61+
# Auto-set PKG for compatibility (only if not already set)
62+
ifeq ($(origin PKG), undefined)
63+
PKG = $(K)
64+
endif
3665
endif
3766

3867
ifneq ($(origin TESTS), undefined)
@@ -383,9 +412,11 @@ provider-lint: ## [CI] ProviderLint Checks / providerlint
383412
-XS002=false \
384413
$(SVC_DIR)/... ./internal/provider/...
385414

386-
quick-fix: fmt testacc-lint-fix fix-imports modern-fix semgrep-fix ## Some quick fixes
415+
quick-fix-heading: ## Just a heading for quick-fix
387416
@echo "make: Quick fixes..."
388417

418+
quick-fix: quick-fix-heading fmt testacc-lint-fix fix-imports modern-fix semgrep-fix website-terrafmt-fix ## Some quick fixes
419+
389420
provider-markdown-lint: ## [CI] Provider Check / markdown-lint
390421
@echo "make: Provider Check / markdown-lint..."
391422
@docker run --rm \
@@ -838,6 +869,15 @@ website-terrafmt: ## [CI] Website Checks / terrafmt
838869
@echo "make: Website Checks / terrafmt..."
839870
@terrafmt diff ./website --check --pattern '*.markdown'
840871

872+
website-terrafmt-fix: ## [CI] Fix Website / terrafmt
873+
@echo "make: Fix Website / terrafmt..."
874+
@echo "make: terrafmt fix website/docs root files..."
875+
@find ./website/docs -maxdepth 1 -type f -name '*.markdown' -exec terrafmt fmt {} \;
876+
@for dir in $$(find ./website/docs -maxdepth 1 -type d ! -name docs ! -name cdktf | sort); do \
877+
echo "make: Fixing $$dir with terrafmt..."; \
878+
terrafmt fmt $$dir --pattern '*.markdown'; \
879+
done
880+
841881
website-tflint: tflint-init ## [CI] Website Checks / tflint
842882
@echo "make: Website Checks / tflint..."
843883
@exit_code=0 ; \
@@ -941,6 +981,7 @@ yamllint: ## [CI] YAML Linting / yamllint
941981
provider-lint \
942982
provider-markdown-lint \
943983
quick-fix \
984+
quick-fix-heading \
944985
sane \
945986
sanity \
946987
semgrep \
@@ -989,5 +1030,6 @@ yamllint: ## [CI] YAML Linting / yamllint
9891030
website-markdown-lint \
9901031
website-misspell \
9911032
website-terrafmt \
1033+
website-terrafmt-fix \
9921034
website-tflint \
9931035
yamllint

0 commit comments

Comments
 (0)