-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
336 lines (276 loc) · 10.9 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
ifeq (,$(wildcard yplatform/Makefile))
INSTALL_YP := $(shell ln -s . yplatform)
ifneq (,$(filter undefine,$(.FEATURES)))
undefine INSTALL_YP
endif
endif
include yplatform/build.mk/generic.common.mk
include yplatform/build.mk/sh.check.shellcheck.mk
include yplatform/build.mk/js.deps.npm.mk
include yplatform/build.mk/js.check.eslint.mk
include yplatform/build.mk/core.misc.release.tag.mk
# ------------------------------------------------------------------------------
RAW_GUC_URL := https://raw.githubusercontent.com
BREWFILE_LOCK := Brewfile.lock
# for testing purposes, so that 'make docker-ci' works
# otherwise YP_DOCKER_CI_IMAGE=false (set in .ci.main.sh)
YP_DOCKER_CI_IMAGE := ysoftwareab/yp-ubuntu-20.04-minimal
BREW = $(call which,BREW,brew)
$(foreach VAR,BREW,$(call make-lazy,$(VAR)))
NODE_ENV_CI := $(YP_DIR)/bin/node-env-ci
CI_PRINTVARS := $(YP_DIR)/bin/ci-printvars
COMMON_MKS := $(wildcard build.mk/*.common.mk)
COMMON_MKS := $(filter-out build.mk/generic.common.mk,$(COMMON_MKS))
FORMULA_PATCH_FILES = $(shell $(GIT_LS) "Formula/*.patch")
FORMULA_PATCHED_FILES = $(patsubst %.original.rb,%.rb,$(shell $(GIT_LS) "Formula/patch-src/*.original.rb"))
YP_CLEAN_FILES += \
yplatform \
YP_VENDOR_FILES_IGNORE += \
-e "^Formula/.*\.patch$$" \
-e "^Formula/patch-src/" \
-e "^bin/aws-cfviz$$" \
-e "^bin/esh$$" \
-e "^bin/git-archive-all$$" \
-e "^bin/nanoseconds-" \
-e "^bin/retry$$" \
-e "^bin/semver2$$" \
-e "^bin/transcrypt$$" \
-e "^bin/travis-wait$$" \
-e "^bin/urldecode$$" \
-e "^bin/urlencode$$" \
-e "^bin/wait-for$$" \
-e "^bin/wsl-fix-exec-format-error$$" \
-e "^bootstrap/brew-util/homebrew-install\.sh$$" \
-e "^bootstrap/brew-util/homebrew-install\.sh\.original$$" \
-e "^bootstrap/brew-util/homebrew-install\.sh\.patch$$" \
-e "^\.devcontainer/devcontainer\.json$$" \
-e "^doc/bak/" \
YP_SYMLINK_FILES_IGNORE += \
-e "^repo/dot\.git-hooks/pre-push$$" \
YP_PATH_FILES_IGNORE += \
-e "^Formula/" \
-e "^aws-cfn.mk/tpl\.Makefile$$" \
-e "^dockerfiles/build.FROM_DOCKER_IMAGE_TAG$$" \
-e "^generic/dot\.gitattributes_global$$" \
-e "^generic/dot\.gitignore_global$$" \
-e "^gitconfig/dot\.gitattributes_global$$" \
-e "^gitconfig/dot\.gitattributes_global\.base" \
-e "^gitconfig/dot\.gitattributes_global\.tpl$$" \
-e "^gitconfig/dot\.gitignore_global$$" \
-e "^gitconfig/dot\.gitignore_global\.base$$" \
-e "^gitconfig/dot\.gitignore_global\.tpl$$" \
-e "^repo/AUTHORS$$" \
-e "^repo/Brewfile.inc.sh$$" \
-e "^repo/LICENSE$$" \
-e "^repo/NOTICE$$" \
-e "^repo/UNLICENSE$$" \
-e "^repo/dot\.github/" \
-e "^sshconfig/known_hosts\." \
YP_ECLINT_FILES_IGNORE += \
-e "^\.github/workflows/deployc\.yml$$" \
-e "^\.github/workflows/main\.yml$$" \
-e "^\.github/workflows/mainc\.yml$$" \
-e "^\.github/workflows/tmate\.yml$$" \
-e "^\.travis\.yml\.bak$$" \
-e "^bin/" \
-e "^gitconfig/dot.gitignore_global$$" \
-e "^gitconfig/dot.gitignore_global.base$$" \
-e "^release-notes/" \
-e "^repo/LICENSE$$" \
-e "^repo/UNLICENSE$$" \
-e "^yplatform$$" \
YP_SHELLCHECK_FILES_IGNORE += \
-e "^doc/ci-sh\.md$$" \
-e "sh/common\.inc\.dist\.sh" \
YP_CHECK_TPL_FILES += \
$(FORMULA_PATCHED_FILES) \
$(FORMULA_PATCH_FILES) \
.devcontainer/devcontainer.json \
.github/workflows/main.yml \
.github/workflows/mainc.yml \
.github/workflows/deployc.yml \
.gitpod.yml \
gitconfig/dot.gitignore_global \
mk/common.inc.dist.mk \
sh/common.inc.dist.sh \
ifeq (true,$(CI))
.PHONY: $(YP_CHECK_TPL_FILES)
endif
YP_DEPS_TARGETS += \
.devcontainer/devcontainer.json \
.github/workflows/main.yml \
.github/workflows/mainc.yml \
.github/workflows/deployc.yml \
.gitpod.yml \
# NOTE check-shellcheck is slow, and skip it during 'git push' hook, unless on master branch
YP_GIT_HOOK ?=
ifeq (true,$(YP_GIT_HOOK))
ifneq (master,$(GIT_BRANCH))
YP_CHECK_TARGETS := $(filter-out check-shellcheck,$(YP_CHECK_TARGETS))
endif
endif
YP_TEST_TARGETS += \
test-secret \
test-upload-job-artifacts \
test-repo-mk \
test-gitignore \
test-env-ci \
test-env-ci-unknown \
# ------------------------------------------------------------------------------
.devcontainer/devcontainer.json: yplatform/package.json
.devcontainer/devcontainer.json: .vscode/extensions.json
.devcontainer/devcontainer.json: .devcontainer/devcontainer.json.tpl
$(eval export YP_DOCKER_CI_IMAGE)
$(call yp-generate-from-template)
.github/workflows/main.yml: bin/github-checkout
.github/workflows/main.yml: bin/json2yaml
.github/workflows/main.yml: bin/yaml-expand
.github/workflows/main.yml: $(wildcard priv/wsl.conf)
.github/workflows/main.yml: $(wildcard .github/workflows.src/common*)
.github/workflows/main.yml: $(wildcard .github/workflows.src/main*)
.github/workflows/main.yml: .github/workflows/main.yml.tpl
$(call yp-generate-from-template)
.github/workflows/mainc.yml: bin/github-checkout
.github/workflows/mainc.yml: bin/json2yaml
.github/workflows/mainc.yml: bin/yaml-expand
.github/workflows/mainc.yml: $(wildcard .github/workflows.src/common*)
.github/workflows/mainc.yml: $(wildcard .github/workflows.src/mainc*)
.github/workflows/mainc.yml: .github/workflows/mainc.yml.tpl
$(call yp-generate-from-template)
.github/workflows/deployc.yml: bin/github-checkout
.github/workflows/deployc.yml: bin/json2yaml
.github/workflows/deployc.yml: bin/yaml-expand
.github/workflows/deployc.yml: $(wildcard .github/workflows.src/common*)
.github/workflows/deployc.yml: $(wildcard .github/workflows.src/deployc*)
.github/workflows/deployc.yml: .github/workflows/deployc.yml.tpl
$(call yp-generate-from-template)
.gitpod.yml: yplatform/package.json
.gitpod.yml: .vscode/extensions.json
.gitpod.yml: .gitpod.yml.tpl
$(eval export YP_DOCKER_CI_IMAGE)
$(call yp-generate-from-template)
Formula/editorconfig-checker.rb: Formula/editorconfig-checker.rb.tpl
$(call yp-generate-from-template)
.PHONY: test-secret
test-secret:
ifeq ($(YP_IS_TRANSCRYPTED),true)
$(ECHO_DO) "Testing transcrypt..."
$(CAT) doc/how-to-manage-secrets.md.test.secret
$(CAT) doc/how-to-manage-secrets.md.test.secret | \
$(GREP) -q "This is a test of transcrypt."
$(ECHO_DONE)
else
:
endif
.PHONY: test-upload-job-artifacts
test-upload-job-artifacts:
$(ECHO_DO) "Testing upload-job-artifacts..."
$(ECHO) "This is a test of upload-job-artifacts" >some-job-artifact.md
$(ECHO_DONE)
.PHONY: test-gitignore
test-gitignore:
$(ECHO_DO) "Testing .gitignore..."
$(CAT) .gitignore | $(GREP) -q -Fx "/some-job-artifact.md"
$(GIT) check-ignore --verbose some-job-artifact.md | $(CUT) -d: -f1 | $(GREP) -q -Fx ".gitignore"
$(CAT) gitconfig/dot.gitignore_global | $(GREP) -q -Fx "Makefile.lazy"
$(GIT) check-ignore --verbose Makefile.lazy | $(CUT) -d: -f1 | $(GREP) -q -Fx ".git/info/exclude"
$(ECHO_DONE)
.PHONY: test-env-ci
test-env-ci:
$(ECHO_DO) "Testing that we are in sync with env-ci..."
$(COMM) -23 <($(NODE_ENV_CI) --yp | $(SORT)) <($(CI_PRINTVARS) --yp | $(SORT)) | \
$(YP_DIR)/bin/ifne --not --fail --print-on-fail || { \
$(ECHO_ERR) "Found the above differences with env-ci."; \
$(ECHO_INFO) "A full diff between YP_CI_* env vars between bin/env-ci and bin/ci-printvars follows:"; \
$(DIFF) --unified=1000000 --label node-env-ci --label ci-printvars \
<($(NODE_ENV_CI) --yp | $(SORT)) <($(CI_PRINTVARS) --yp | $(SORT)) || true; \
$(ECHO_INFO) "A full printout of CI env vars follows:"; \
$(CI_PRINTVARS) | $(SORT); \
exit 1; \
}
$(ECHO_DONE)
.PHONY: test-env-ci-unknown
test-env-ci-unknown:
$(ECHO_DO) "Testing that there are no new environment variables in CI..."
$(CI_PRINTVARS) --unknown
$(CI_PRINTVARS) --unknown --yp
$(ECHO_DONE)
.PHONY: test-repo-mk
test-repo-mk:
$(ECHO_DO) "Testing 'make help' and makefiles in build.mk..."
$(MAKE) help
for mk in $(COMMON_MKS); do \
$(ECHO_DO) "Testing $${mk}..."; \
$(MAKE) -f build.mk/generic.common.mk -f $${mk} help; \
$(ECHO_DONE); \
done
$(ECHO_DONE)
gitconfig/dot.gitattributes_global: ## Regenerate gitconfig/dot.gitattributes_global.
gitconfig/dot.gitattributes_global: $(wildcard gitconfig/dot.gitattributes_global.base*)
gitconfig/dot.gitattributes_global: gitconfig/dot.gitattributes_global.tpl
$(call yp-generate-from-template)
gitconfig/dot.gitignore_global: ## Regenerate gitconfig/dot.gitignore_global.
gitconfig/dot.gitignore_global: gitconfig/dot.gitignore_global.base
gitconfig/dot.gitignore_global: gitconfig/dot.gitignore_global.tpl
$(call yp-generate-from-template)
mk/common.inc.dist.mk: ## Regenerate mk/common.inc.dist.mk.
mk/common.inc.dist.mk: $(filter-out mk/common.inc.dist.mk,$(wildcard mk/*.mk))
mk/common.inc.dist.mk: mk/common.inc.dist.mk.tpl
$(call yp-generate-from-template)
sh/common.inc.dist.sh: ## Regenerate sh/common.inc.dist.sh.
sh/common.inc.dist.sh: $(filter-out sh/common.inc.dist.sh,$(wildcard sh/*.sh))
sh/common.inc.dist.sh: sh/common.inc.dist.sh.tpl
$(call yp-generate-from-template)
bootstrap/brew-util/homebrew-install.sh: ## Regenerate bootstrap/brew-util/homebrew-install.sh
ifneq (true,$(CI))
bootstrap/brew-util/homebrew-install.sh: $(BREWFILE_LOCK)
endif
bootstrap/brew-util/homebrew-install.sh:
$(eval BREW_INSTALL_GIT_REF := $(shell $(CAT) $(BREWFILE_LOCK) | $(GREP) "^homebrew/install " | $(CUT) -d" " -f2 || $(ECHO) "master")) # editorconfig-checker-disable-line
$(CURL) -o [email protected] $(RAW_GUC_URL)/Homebrew/install/$(BREW_INSTALL_GIT_REF)/install.sh
if [[ -f "[email protected]" ]]; then \
$(CAT) [email protected] | $(PATCH) [email protected] -o $@; \
else \
$(CP) [email protected] $@; \
fi
if [[ -t 0 ]] && [[ -t 1 ]]; then \
$(EDITOR) $@; \
else \
$(ECHO_INFO) "No tty."; \
$(ECHO_SKIP) "$(EDITOR) $@"; \
fi
$(MAKE) [email protected]
PHONY: bootstrap/brew-util/homebrew-install.sh.patch
bootstrap/brew-util/homebrew-install.sh.patch: bootstrap/brew-util/homebrew-install.sh.original
bootstrap/brew-util/homebrew-install.sh.patch: bootstrap/brew-util/homebrew-install.sh
$(DIFF) -u --label $(word 2,$^) --label $< $(word 2,$^) $< > $@ || true
.PHONY: Formula/patch-src/%.original.rb
ifneq (true,$(CI))
Formula/patch-src/%.original.rb: $(BREWFILE_LOCK)
endif
Formula/patch-src/%.original.rb:
$(eval HOMEBREW_CORE_GIT_REF := $(shell $(CAT) $(BREWFILE_LOCK) | \
$(GREP) "^homebrew/homebrew-core" | $(CUT) -d" " -f2))
$(CURL) -q -fsSL \
https://raw.githubusercontent.com/homebrew/homebrew-core/$(HOMEBREW_CORE_GIT_REF)/Formula/$*.rb -o $@
if [[ -f Formula/$*.linux.patch ]]; then \
$(MAKE) Formula/patch-src/$*.rb || { \
$(ECHO_ERR) "Failed to apply old patch Formula/$*.linux.patch and update patched file Formula/patch-src/$*.rb."; \
exit 1; \
} \
else \
$(CP) Formula/patch-src/$*.original.rb Formula/patch-src/$*.rb; \
fi
if [[ -t 0 ]] && [[ -t 1 ]]; then \
$(EDITOR) Formula/patch-src/$*.rb; \
else \
$(ECHO_INFO) "No tty."; \
$(ECHO_SKIP) "$(EDITOR) Formula/patch-src/$*.rb"; \
fi
$(MAKE) Formula/$*.linux.patch
.PHONY: Formula/%.linux.patch
Formula/%.linux.patch: Formula/patch-src/%.original.rb
$(call yp-generate-from-template-patch,Formula/patch-src/$*.rb)
.PHONY: Formula/patch-src/%.rb
Formula/patch-src/%.rb: Formula/patch-src/%.original.rb
$(call yp-generate-from-template-patched,Formula/$*.linux.patch)