-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
200 lines (151 loc) · 7.68 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
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
##
# DO NOT EDIT THIS FILE MANUALLY!
#
# Instead, update the template file and re-run the appropriate dev-unify task.
##
#-------------------------------------------------------------------------------
# Global variables.
PHP_LAST=7.2
PHP_CURR=7.3
PHP_NEXT=7.4
PHP_LAST_EXT_DATE=20170718
PHP_CURR_EXT_DATE=20180731
PHP_NEXT_EXT_DATE=20190902
BUILD_DOCKER=docker build --compress --force-rm --squash
BUILD_COMPOSE=docker-compose build --pull --compress --parallel
COMPOSE_72=tests-72 coverage-72
COMPOSE_73=tests-73 coverage-73
COMPOSE_74=tests-74 coverage-74
TEST_QUICK=tests-72 tests-73 tests-74
TEST_COVER=coverage-72 coverage-73 coverage-74
IMAGES_72=simplepieng/base:$(PHP_LAST) simplepieng/test-coverage:$(PHP_LAST) simplepieng/test-runner:$(PHP_LAST)
IMAGES_73=simplepieng/base:$(PHP_CURR) simplepieng/test-coverage:$(PHP_CURR) simplepieng/test-runner:$(PHP_CURR)
IMAGES_74=simplepieng/base:$(PHP_NEXT) simplepieng/test-coverage:$(PHP_NEXT) simplepieng/test-runner:$(PHP_NEXT)
#-------------------------------------------------------------------------------
# Running `make` will show the list of subcommands that will run.
all:
@cat Makefile | grep "^[a-z]" | sed 's/://' | awk '{print $$1}'
#-------------------------------------------------------------------------------
# Base Docker images so that we have some repeatability
.PHONY: base-72
base-72:
$(BUILD_DOCKER) --tag simplepieng/base:$(PHP_LAST) --file build/base/Dockerfile-$(PHP_LAST) --build-arg BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") --build-arg VCS_URL=$$(git config --get remote.origin.url) --build-arg VCS_REF=$$(git rev-parse --short HEAD) .
.PHONY: base-73
base-73:
$(BUILD_DOCKER) --tag simplepieng/base:$(PHP_CURR) --file build/base/Dockerfile-$(PHP_CURR) --build-arg BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") --build-arg VCS_URL=$$(git config --get remote.origin.url) --build-arg VCS_REF=$$(git rev-parse --short HEAD) .
.PHONY: base-74
base-74:
$(BUILD_DOCKER) --tag simplepieng/base:$(PHP_NEXT) --file build/base/Dockerfile-$(PHP_NEXT) --build-arg BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") --build-arg VCS_URL=$$(git config --get remote.origin.url) --build-arg VCS_REF=$$(git rev-parse --short HEAD) .
.PHONY: base-all
base-all: base-72 base-73 base-74
#-------------------------------------------------------------------------------
# Build all development focused containers.
.PHONY: build-all
build-all:
$(BUILD_COMPOSE)
.PHONY: build-72
build-72:
$(BUILD_COMPOSE) $(COMPOSE_72)
.PHONY: build-73
build-73:
$(BUILD_COMPOSE) $(COMPOSE_73)
.PHONY: build-74
build-74:
$(BUILD_COMPOSE) $(COMPOSE_74)
.PHONY: build-test
build-test:
$(BUILD_COMPOSE) tests-72 tests-73 tests-74
.PHONY: build-coverage
build-coverage:
$(BUILD_COMPOSE) coverage-72 coverage-73 coverage-74
#-------------------------------------------------------------------------------
# Clean Docker containers
.PHONY: dockerfile
dockerfile:
@ # tests:7.2
find $$(pwd)/build -type f -name Dockerfile-$(PHP_LAST)* -not -path "*build/base*" | xargs -P $$(nproc) -I% bash -c 'sed -i -r "s/^FROM simplepieng\/base:([^\s]+)/FROM simplepieng\/base:$(PHP_LAST)/" %'
find $$(pwd)/build -type f -name Dockerfile-$(PHP_LAST)* -not -path "*build/base*" | xargs -P $$(nproc) -I% bash -c 'sed -i -r "s/^ENV PHP_EXT_DATE ([^\s]+)/ENV PHP_EXT_DATE $(PHP_LAST_EXT_DATE)/" %'
@ # tests:7.3
find $$(pwd)/build -type f -name Dockerfile-$(PHP_LAST)* -not -path "*build/base*" | xargs -P $$(nproc) -I% bash -c 'cp -fv % $$(echo % | sed -r "s/$(PHP_LAST)/$(PHP_CURR)/g")'
find $$(pwd)/build -type f -name Dockerfile-$(PHP_CURR)* -not -path "*build/base*" | xargs -P $$(nproc) -I% bash -c 'sed -i -r "s/^FROM simplepieng\/base:$(PHP_LAST)/FROM simplepieng\/base:$(PHP_CURR)/" %'
find $$(pwd)/build -type f -name Dockerfile-$(PHP_CURR)* -not -path "*build/base*" | xargs -P $$(nproc) -I% bash -c 'sed -i -r "s/^ENV PHP_EXT_DATE ([^\s]+)/ENV PHP_EXT_DATE $(PHP_CURR_EXT_DATE)/" %'
@ # tests:7.4
find $$(pwd)/build -type f -name Dockerfile-$(PHP_CURR)* -not -path "*build/base*" | xargs -P $$(nproc) -I% bash -c 'cp -fv % $$(echo % | sed -r "s/$(PHP_CURR)/$(PHP_NEXT)/g")'
find $$(pwd)/build -type f -name Dockerfile-$(PHP_NEXT)* -not -path "*build/base*" | xargs -P $$(nproc) -I% bash -c 'sed -i -r "s/^FROM simplepieng\/base:$(PHP_CURR)/FROM simplepieng\/base:$(PHP_NEXT)/" %'
find $$(pwd)/build -type f -name Dockerfile-$(PHP_NEXT)* -not -path "*build/base*" | xargs -P $$(nproc) -I% bash -c 'sed -i -r "s/^ENV PHP_EXT_DATE ([^\s]+)/ENV PHP_EXT_DATE $(PHP_NEXT_EXT_DATE)/" %'
.PHONY: push-images
push-images:
docker push simplepieng/base:$(PHP_LAST)
docker push simplepieng/base:$(PHP_CURR)
docker push simplepieng/base:$(PHP_NEXT)
docker push simplepieng/test-runner:$(PHP_LAST)
docker push simplepieng/test-runner:$(PHP_CURR)
docker push simplepieng/test-runner:$(PHP_NEXT)
docker push simplepieng/test-coverage:$(PHP_LAST)
docker push simplepieng/test-coverage:$(PHP_CURR)
docker push simplepieng/test-coverage:$(PHP_NEXT)
.PHONY: clean-72
clean-72:
docker image rm --force $(IMAGES_72)
.PHONY: clean-73
clean-73:
docker image rm --force $(IMAGES_73)
.PHONY: clean-74
clean-74:
docker image rm --force $(IMAGES_74)
.PHONY: clean-all
clean-all: clean-72 clean-73 clean-74
.PHONY: rmint
rmint:
# Remove the intermediate Docker containers. All Docker image builds will start over from scratch.
docker images | grep "<none>" | awk '{print $$3}' | xargs -P 2 -I% docker rmi -f %
#-------------------------------------------------------------------------------
# Linting
.PHONY: hadolint
hadolint:
- hadolint build/base/Dockerfile-7.2
@echo "---------------------------------------------------------------------"
- hadolint build/base/Dockerfile-7.3
@echo "---------------------------------------------------------------------"
- hadolint build/base/Dockerfile-7.4
@echo "---------------------------------------------------------------------"
- hadolint build/tests/Dockerfile-7.2
@echo "---------------------------------------------------------------------"
- hadolint build/tests/Dockerfile-7.3
@echo "---------------------------------------------------------------------"
- hadolint build/tests/Dockerfile-7.4
@echo "---------------------------------------------------------------------"
- hadolint build/tests/Dockerfile-7.2-xdebug
@echo "---------------------------------------------------------------------"
- hadolint build/tests/Dockerfile-7.3-xdebug
@echo "---------------------------------------------------------------------"
- hadolint build/tests/Dockerfile-7.4-xdebug
.PHONY: lint
lint: hadolint
#-------------------------------------------------------------------------------
# Git Tasks
.PHONY: tag
tag:
@ if [ $$(git status -s -uall | wc -l) != 1 ]; then echo 'ERROR: Git workspace must be clean.'; exit 1; fi;
@echo "This release will be tagged as: $$(cat ./VERSION)"
@echo "This version should match your release. If it doesn't, re-run 'make version'."
@echo "---------------------------------------------------------------------"
@read -p "Press any key to continue, or press Control+C to cancel. " x;
@echo " "
@chag update $$(cat ./VERSION)
@echo " "
@echo "These are the contents of the CHANGELOG for this release. Are these correct?"
@echo "---------------------------------------------------------------------"
@chag contents
@echo "---------------------------------------------------------------------"
@echo "Are these release notes correct? If not, cancel and update CHANGELOG.md."
@read -p "Press any key to continue, or press Control+C to cancel. " x;
@echo " "
git add .
git commit -a -m "Preparing the $$(cat ./VERSION) release."
chag tag --sign
.PHONY: version
version:
@echo "Current version: $$(cat ./VERSION)"
@read -p "Enter new version number: " nv; \
printf "$$nv" > ./VERSION