4
4
export DOCKER_BUILDKIT ?= 1
5
5
export COMPOSE_DOCKER_CLI_BUILD ?= 1
6
6
7
+ # Docker binary to use, when executing docker tasks
8
+ DOCKER ?= docker
9
+
7
10
IMAGE_NAMESPACE ?= wayofdev/nginx
8
11
IMAGE_TEMPLATE ?= k8s-alpine
9
12
IMAGE_TAG ?= $(IMAGE_NAMESPACE ) :$(IMAGE_TEMPLATE ) -latest
@@ -13,6 +16,34 @@ CACHE_FROM ?= $(IMAGE_TAG)
13
16
OS ?= $(shell uname)
14
17
CURRENT_DIR ?= $(dir $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
15
18
19
+ YAML_CONFIG_PATH ?= .github/.yamllint.yaml
20
+
21
+ YAML_LINT_RUNNER ?= $(DOCKER ) run --rm $$(tty -s && echo "-it" || echo ) \
22
+ -v $(PWD ) :/data \
23
+ cytopia/yamllint:latest \
24
+ -c $(YAML_CONFIG_PATH ) \
25
+ -f colored .
26
+
27
+ ACTION_LINT_RUNNER ?= $(DOCKER ) run --rm $$(tty -s && echo "-it" || echo ) \
28
+ -v $(shell pwd) :/repo \
29
+ --workdir /repo \
30
+ rhysd/actionlint:latest \
31
+ -color
32
+
33
+ MARKDOWN_LINT_RUNNER ?= $(DOCKER ) run --rm $$(tty -s && echo "-it" || echo ) \
34
+ -v $(shell pwd) :/app \
35
+ --workdir /app \
36
+ davidanson/markdownlint-cli2-rules:latest \
37
+ --config ".github/.markdownlint.json"
38
+
39
+ ANSIBLE_LINT_RUNNER ?= $(DOCKER ) run --rm $$(tty -s && echo "-it" || echo ) \
40
+ -v $(shell pwd) :/code \
41
+ -e YAMLLINT_CONFIG_FILE=$(YAML_CONFIG_PATH ) \
42
+ --workdir /code \
43
+ pipelinecomponents/ansible-lint:latest \
44
+ ansible-lint --show-relpath --config-file ".github/.ansible-lint.yml"
45
+
46
+ #
16
47
# Self documenting Makefile code
17
48
# ------------------------------------------------------------------------------------
18
49
ifneq ($(TERM ) ,)
36
67
WHITE := ""
37
68
RST := ""
38
69
endif
39
- MAKE_LOGFILE = /tmp/docker-nginx.log
70
+ MAKE_LOGFILE = /tmp/wayofdev- docker-nginx.log
40
71
MAKE_CMD_COLOR := $(BLUE )
41
72
42
73
default : all
@@ -45,29 +76,31 @@ help: ## Show this menu
45
76
@echo ' Management commands for package:'
46
77
@echo ' Usage:'
47
78
@echo ' ${MAKE_CMD_COLOR}make${RST} Builds default image and then runs dgoss tests'
48
- @grep -E ' ^[a-zA-Z_0-9%-]+:.*?## .*$$' $( MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}'
79
+ @grep -E ' ^[a-zA-Z_0-9%-]+:.*?## .*$$' Makefile | awk ' BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}'
49
80
@echo
50
81
@echo ' 📑 Logs are stored in $(MAKE_LOGFILE)'
51
82
@echo
52
83
@echo ' 📦 Package docker-nginx (github.com/wayofdev/docker-nginx)'
53
- @echo ' 🤠 Author Andrij Orlenko (github.com/lotyp)'
84
+ @echo ' 🤠 Author the dev (github.com/lotyp)'
54
85
@echo ' 🏢 ${YELLOW}Org wayofdev (github.com/wayofdev)${RST}'
86
+ @echo
55
87
.PHONY : help
56
88
57
89
.EXPORT_ALL_VARIABLES :
58
90
91
+ #
59
92
# Default action
60
93
# Defines default command when `make` is executed without additional parameters
61
94
# ------------------------------------------------------------------------------------
62
- all : hooks generate build test
95
+ all : generate build test
63
96
PHONY : all
64
97
65
-
98
+ #
66
99
# Docker Actions
67
100
# ------------------------------------------------------------------------------------
68
101
build : # # Build default docker image
69
102
cd $(CURRENT_DIR )$(DOCKERFILE_DIR ) ; \
70
- docker build -t $(IMAGE_TAG ) .
103
+ $( DOCKER ) build -t $(IMAGE_TAG ) .
71
104
PHONY : build
72
105
73
106
analyze : # # Analyze docker image
@@ -80,11 +113,6 @@ build-from-cache: ## Build default docker image using cached layers
80
113
docker build --cache-from $(CACHE_FROM ) . -t $(IMAGE_TAG )
81
114
PHONY : build-from-cache
82
115
83
- test : # # Run dgoss tests over docker images
84
- set -eux
85
- GOSS_FILES_STRATEGY=cp GOSS_FILES_PATH=$(DOCKERFILE_DIR ) dgoss run --add-host app:127.0.0.1 -t $(IMAGE_TAG )
86
- .PHONY : test
87
-
88
116
pull : # # Pulls docker image from upstream
89
117
docker pull $(IMAGE_TAG )
90
118
.PHONY : pull
@@ -97,7 +125,7 @@ ssh: ## Login into built image
97
125
docker run --rm -it -v $(PWD ) /:/opt/docker-nginx $(IMAGE_TAG ) sh
98
126
.PHONY : ssh
99
127
100
-
128
+ #
101
129
# Ansible Actions
102
130
# ------------------------------------------------------------------------------------
103
131
generate : # # Generates dockerfiles from ansible templates
@@ -108,23 +136,49 @@ clean: ## Cleans up generated files
108
136
rm -rf ./dist/*
109
137
PHONY : clean
110
138
139
+ #
140
+ # Testing
141
+ # ------------------------------------------------------------------------------------
142
+ test : # # Run dgoss tests over docker images
143
+ set -eux
144
+ GOSS_SLEEP=" 0.4" GOSS_WAIT_OPTS=" -r 40s -s 2s > /dev/stdout" GOSS_FILES_STRATEGY=cp GOSS_FILES_PATH=$(DOCKERFILE_DIR ) dgoss run --add-host app:127.0.0.1 -t $(IMAGE_TAG )
145
+ .PHONY : test
111
146
112
- # Code Quality, Git, Linting, Testing
147
+ #
148
+ # Code Quality, Git, Linting
113
149
# ------------------------------------------------------------------------------------
114
150
hooks : # # Install git hooks from pre-commit-config
115
151
pre-commit install
152
+ pre-commit install --hook-type commit-msg
116
153
pre-commit autoupdate
117
154
.PHONY : hooks
118
155
156
+ lint : lint-yaml lint-actions lint-md lint-ansible # # Runs all linting commands
157
+ .PHONY : lint
158
+
119
159
lint-yaml : # # Lints yaml files inside project
120
- yamllint .
160
+ @ $( YAML_LINT_RUNNER ) | tee -a $( MAKE_LOGFILE )
121
161
.PHONY : lint-yaml
122
162
163
+ lint-actions : # # Lint all github actions
164
+ @$(ACTION_LINT_RUNNER ) | tee -a $(MAKE_LOGFILE )
165
+ .PHONY : lint-actions
166
+
167
+ lint-md : # # Lint all markdown files using markdownlint-cli2
168
+ @$(MARKDOWN_LINT_RUNNER ) --fix " **/*.md" " !CHANGELOG.md" " !app/vendor" " !app/node_modules" | tee -a $(MAKE_LOGFILE )
169
+ .PHONY : lint-md
170
+
171
+ lint-md-dry : # # Lint all markdown files using markdownlint-cli2 in dry-run mode
172
+ @$(MARKDOWN_LINT_RUNNER ) " **/*.md" " !CHANGELOG.md" " !app/vendor" " !app/node_modules" | tee -a $(MAKE_LOGFILE )
173
+ .PHONY : lint-md-dry
174
+
123
175
lint-ansible : # # Lint ansible files inside project
124
- ansible-lint .
176
+ @ $( ANSIBLE_LINT_RUNNER ) . | tee -a $( MAKE_LOGFILE )
125
177
.PHONY : lint-ansible
126
178
127
- lint-docker : # # Run hadolint linter over dist Dockerfiles
128
- hadolint -V ./dist/dev-alpine/Dockerfile
129
- hadolint -V ./dist/k8s-alpine/Dockerfile
130
- .PHONY : lint-docker
179
+ #
180
+ # Release
181
+ # ------------------------------------------------------------------------------------
182
+ commit : # # Run commitizen to create commit message
183
+ czg commit --config=" ./.github/.cz.config.js"
184
+ .PHONY : commit
0 commit comments