-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (34 loc) · 1.53 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
# These targets are not files
.PHONY: lint lint-scripts lint-ruby check-format format run publish
STACK ?= heroku-24
FIXTURE ?= spec/fixtures/basic_web_8.0
# Converts a stack name of `heroku-NN` to its build Docker image tag of `heroku/heroku:NN-build`.
STACK_IMAGE_TAG := heroku/$(subst -,:,$(STACK))-build
lint: lint-scripts check-format lint-ruby
lint-scripts:
@git ls-files -z --cached --others --exclude-standard 'bin/*' '*/bin/*' '*.sh' | xargs -0 shellcheck --check-sourced --color=always
lint-ruby:
@bundle exec rubocop
check-format:
@shfmt --diff .
format:
@shfmt --write --list .
run:
@echo "Running buildpack using: STACK=$(STACK) FIXTURE=$(FIXTURE)"
@docker run --rm -v $(PWD):/src:ro --tmpfs /app -e "HOME=/app" -e "STACK=$(STACK)" "$(STACK_IMAGE_TAG)" \
bash -euo pipefail -c '\
mkdir /tmp/buildpack /tmp/build /tmp/cache /tmp/env; \
cp -r /src/{bin,lib,vendor} /tmp/buildpack; \
cp -rT /src/$(FIXTURE) /tmp/build; \
cd /tmp/buildpack; \
unset $$(printenv | cut -d '=' -f 1 | grep -vE "^(HOME|LANG|PATH|STACK)$$"); \
echo -e "\n~ Detect:" && ./bin/detect /tmp/build; \
echo -e "\n~ Compile:" && { ./bin/compile /tmp/build /tmp/cache /tmp/env || COMPILE_FAILED=1; }; \
[[ "$${COMPILE_FAILED:-}" == "1" ]] && exit 0; \
[[ -f /tmp/build/bin/compile ]] && { echo -e "\n~ Compile (Inline Buildpack):" && (source ./export && /tmp/build/bin/compile /tmp/build /tmp/cache /tmp/env); }; \
echo -e "\n~ Release:" && ./bin/release /tmp/build; \
echo -e "\nBuild successful!"; \
'
@echo
publish:
@etc/publish.sh