Skip to content

Commit bb28227

Browse files
authored
make run workflow improvements (#1755)
Updates `make run` (used locally during development) to: - Run a second build after the first, which allows for easy testing of cached workflows. This second build uses a different build directory path to the first, to match the Heroku Cedar/classic build system and allow for testing that relocation/path rewriting works as expected. - Exit non-zero if the compile failed (it previously didn't, so we could test `bin/report` for failing builds - but that's now handled via a customisable exit code). GUS-W-17879839.
1 parent f2d2bc7 commit bb28227

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@ jobs:
7373
- name: Run buildpack using default app fixture
7474
run: make run
7575
- name: Run buildpack using an app fixture that's expected to fail
76-
run: make run FIXTURE=spec/fixtures/python_version_file_invalid_version/
76+
run: make run FIXTURE=spec/fixtures/python_version_file_invalid_version/ COMPILE_FAILURE_EXIT_CODE=0

Makefile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
STACK ?= heroku-24
55
FIXTURE ?= spec/fixtures/python_version_unspecified
6+
# Allow overriding the exit code in CI, so we can test bin/report works for failing builds.
7+
COMPILE_FAILURE_EXIT_CODE ?= 1
68

79
# Converts a stack name of `heroku-NN` to its build Docker image tag of `heroku/heroku:NN-build`.
810
STACK_IMAGE_TAG := heroku/$(subst -,:,$(STACK))-build
@@ -24,18 +26,21 @@ format:
2426
run:
2527
@echo "Running buildpack using: STACK=$(STACK) FIXTURE=$(FIXTURE)"
2628
@docker run --rm -v $(PWD):/src:ro --tmpfs /app -e "HOME=/app" -e "STACK=$(STACK)" "$(STACK_IMAGE_TAG)" \
27-
bash -euo pipefail -c '\
28-
mkdir /tmp/buildpack /tmp/build /tmp/cache /tmp/env; \
29+
bash -euo pipefail -O dotglob -c '\
30+
mkdir /tmp/buildpack /tmp/cache /tmp/env; \
2931
cp -r /src/{bin,lib,requirements,vendor} /tmp/buildpack; \
30-
cp -rT /src/$(FIXTURE) /tmp/build; \
32+
cp -r /src/$(FIXTURE) /tmp/build_1; \
3133
cd /tmp/buildpack; \
3234
unset $$(printenv | cut -d '=' -f 1 | grep -vE "^(HOME|LANG|PATH|STACK)$$"); \
33-
echo -e "\n~ Detect:" && ./bin/detect /tmp/build; \
34-
echo -e "\n~ Compile:" && { ./bin/compile /tmp/build /tmp/cache /tmp/env || COMPILE_FAILED=1; }; \
35-
echo -e "\n~ Report:" && ./bin/report /tmp/build /tmp/cache /tmp/env; \
36-
[[ "$${COMPILE_FAILED:-}" == "1" ]] && exit 0; \
37-
[[ -f /tmp/build/bin/compile ]] && { echo -e "\n~ Compile (Inline Buildpack):" && (source ./export && /tmp/build/bin/compile /tmp/build /tmp/cache /tmp/env); }; \
38-
echo -e "\n~ Release:" && ./bin/release /tmp/build; \
35+
echo -en "\n~ Detect: " && ./bin/detect /tmp/build_1; \
36+
echo -e "\n~ Compile:" && { ./bin/compile /tmp/build_1 /tmp/cache /tmp/env || COMPILE_FAILED=1; }; \
37+
echo -e "\n~ Report:" && ./bin/report /tmp/build_1 /tmp/cache /tmp/env; \
38+
[[ "$${COMPILE_FAILED:-}" == "1" ]] && exit $(COMPILE_FAILURE_EXIT_CODE); \
39+
[[ -f /tmp/build_1/bin/compile ]] && { echo -e "\n~ Compile (Inline Buildpack):" && (source ./export && /tmp/build_1/bin/compile /tmp/build_1 /tmp/cache /tmp/env); }; \
40+
echo -e "\n~ Release:" && ./bin/release /tmp/build_1; \
41+
rm -rf /app/* /tmp/buildpack/export /tmp/build_1; \
42+
cp -r /src/$(FIXTURE) /tmp/build_2; \
43+
echo -e "\n~ Recompile:" && ./bin/compile /tmp/build_2 /tmp/cache /tmp/env; \
3944
echo -e "\nBuild successful!"; \
4045
'
4146
@echo

0 commit comments

Comments
 (0)