48 lines
1.3 KiB
Makefile
48 lines
1.3 KiB
Makefile
|
.PHONY: default
|
||
|
default: ci-config
|
||
|
|
||
|
.PHONY: check-circleci-installed
|
||
|
check-circleci-installed:
|
||
|
@command -v circleci > /dev/null 2>&1 || { \
|
||
|
echo "Please install circleci-cli, see https://circleci.com/docs/2.0/local-cli/#installation"; \
|
||
|
exit 1; }
|
||
|
|
||
|
.PHONY: ci-config
|
||
|
# ci-config is just an alias for config.yml for now
|
||
|
ci-config: config.yml
|
||
|
|
||
|
CONFIG_SOURCE_DIR := config/
|
||
|
CONFIG_SOURCE := $(shell find config/) Makefile
|
||
|
OUT := config.yml
|
||
|
TMP := .tmp/config.yml.tmp
|
||
|
CONFIG_21 := .tmp/config.2.1.tmp
|
||
|
|
||
|
# Ensure the .tmp dir exists.
|
||
|
$(shell [ -d .tmp ] || mkdir .tmp)
|
||
|
|
||
|
define GEN_CONFIG
|
||
|
@circleci config pack $(CONFIG_SOURCE_DIR) > $(CONFIG_21)
|
||
|
@echo "### Generated by 'make ci-config' do not manually edit this file." > $@
|
||
|
@circleci config process $(CONFIG_21) >> $@
|
||
|
endef
|
||
|
|
||
|
$(OUT): $(CONFIG_SOURCE) check-circleci-installed
|
||
|
$(GEN_CONFIG)
|
||
|
@echo "$@ updated"
|
||
|
|
||
|
$(TMP): $(CONFIG_SOURCE) check-circleci-installed
|
||
|
$(GEN_CONFIG)
|
||
|
|
||
|
.PHONY: config-up-to-date
|
||
|
config-up-to-date: $(TMP) # Note this must not depend on $(OUT)!
|
||
|
@if diff config.yml $<; then \
|
||
|
echo "Generated $(OUT) is up to date!"; \
|
||
|
else \
|
||
|
echo "Generated $(OUT) is out of date, run make ci-config to update."; \
|
||
|
exit 1; \
|
||
|
fi
|
||
|
|
||
|
.PHONY: ci-verify
|
||
|
ci-verify: config-up-to-date
|
||
|
@circleci config validate config.yml
|