-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
93 lines (76 loc) · 3.57 KB
/
Makefile
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
ifneq (,)
.error This Makefile requires GNU Make.
endif
# -------------------------------------------------------------------------------------------------
# Default configuration
# -------------------------------------------------------------------------------------------------
CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
# shellcheck
SC_IMAGE = koalaman/shellcheck
SC_VERSION = stable
# file lint
FL_IMAGE = cytopia/file-lint
FL_VERSION = 0.4
FL_IGNORES = .git/,.github/
BIN_DIR = /usr/local/bin
# -------------------------------------------------------------------------------------------------
# Default target
# -------------------------------------------------------------------------------------------------
.PHONY: help
help:
@echo "lint Lint files"
@echo "install Install aws-export-assume-profile to $(BIN_DIR)"
@echo "uninstall Remove aws-export-assume-profile from $(BIN_DIR)"
# -------------------------------------------------------------------------------------------------
# Install target
# -------------------------------------------------------------------------------------------------
.PHONY: install
install:
install -m 755 aws-export-assume-profile $(BIN_DIR)/aws-export-assume-profile
.PHONY: uninstall
uninstall:
rm $(BIN_DIR)/aws-export-assume-profile
# -------------------------------------------------------------------------------------------------
# Lint target
# -------------------------------------------------------------------------------------------------
.PHONY: lint
lint: lint-files
lint: lint-shell
.PHONY: lint-files
lint-files: _pull-fl
@# Lint all files
@echo "################################################################################"
@echo "# File lint"
@echo "################################################################################"
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data $(FL_IMAGE):$(FL_VERSION) file-cr --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data $(FL_IMAGE):$(FL_VERSION) file-crlf --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data $(FL_IMAGE):$(FL_VERSION) file-trailing-single-newline --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data $(FL_IMAGE):$(FL_VERSION) file-trailing-space --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data $(FL_IMAGE):$(FL_VERSION) file-utf8 --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data $(FL_IMAGE):$(FL_VERSION) file-utf8-bom --text --ignore '$(FL_IGNORES)' --path .
@echo
.PHONY: lint-shell
lint-shell: _pull-sc
@# Lint all Shell files
@echo "################################################################################"
@echo "# Shellcheck"
@echo "################################################################################"
@if docker run --rm $$(tty -s && echo "-it" || echo) \
-v "${CURRENT_DIR}:/mnt" \
-w /mnt \
$(SC_IMAGE):$(SC_VERSION) --shell=bash aws-export-assume-profile; then \
echo "OK"; \
else \
echo "Failed"; \
exit 1; \
fi;
@echo
# -------------------------------------------------------------------------------------------------
# Helper Targets
# -------------------------------------------------------------------------------------------------
.PHONY: _pull-fl
_pull-fl:
docker pull $(FL_IMAGE):$(FL_VERSION)
.PHONY: _pull-sc
_pull-sc:
docker pull $(SC_IMAGE):$(SC_VERSION)