-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (48 loc) · 2.21 KB
/
Makefile
File metadata and controls
55 lines (48 loc) · 2.21 KB
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
APP_DIR := test/smoke/my-app-1
BUILD_DIR := /tmp/uv-bp-build
CACHE_DIR := /tmp/uv-bp-cache
ENV_DIR := /tmp/uv-bp-env
ROOT_DIR := $(CURDIR)
BUILDPACK_DIR := $(ROOT_DIR)
PYTHON_BIN ?= python3
.PHONY: test-buildpack clean-test-buildpack unit-test smoke-test start-local
# Reset the temporary staging directories used for local buildpack testing.
clean-test-buildpack:
rm -rf $(BUILD_DIR) $(CACHE_DIR) $(ENV_DIR)
# Run the sample app through detect, compile, and release using the same
# temporary directories each time so local testing is repeatable.
test-buildpack: clean-test-buildpack
mkdir -p $(BUILD_DIR) $(CACHE_DIR) $(ENV_DIR)
cp -R $(APP_DIR)/. $(BUILD_DIR)
# Run detect from the fixture app directory, but use the buildpack script from the repo root.
cd $(APP_DIR) && $(BUILDPACK_DIR)/bin/detect
$(BUILDPACK_DIR)/bin/compile $(BUILD_DIR) $(CACHE_DIR) $(ENV_DIR)
# Confirm staged dependencies are importable before checking the release metadata.
cd $(BUILD_DIR) && /bin/bash -lc 'source .profile.d/python.sh && $(PYTHON_BIN) -c "import fastapi; print(fastapi.__version__)"'
$(BUILDPACK_DIR)/bin/release $(BUILD_DIR)
# Start the staged sample app locally using the dependencies prepared by `test-buildpack`.
start-local:
@cd $(BUILD_DIR) && /bin/bash -lc '\
source .profile.d/python.sh && \
# Prefer the app Procfile, otherwise reuse the buildpack release logic. \
if [ -f Procfile ]; then \
WEB_CMD=$$(awk -F": " '\''$$1 == "web" { print $$2; exit }'\'' Procfile); \
else \
WEB_CMD=$$($(BUILDPACK_DIR)/bin/release | awk -F": " '\''$$1 ~ /web/ { print $$2; exit }'\''); \
fi; \
if [ -z "$$WEB_CMD" ]; then \
echo "Could not determine a web command to run locally."; \
exit 1; \
fi; \
# Local machines often expose `python3` instead of `python`, so normalize that here. \
WEB_CMD=$$(printf "%s" "$$WEB_CMD" | sed "s/^python /$(PYTHON_BIN) /"); \
eval "$$WEB_CMD"'
# Run the single-app smoke test target against every app fixture under test/smoke.
smoke-test:
@./scripts/smoke-test.sh
# Run all lightweight script-level unit tests together.
unit-test:
@./scripts/unit-test.sh
# Build a cached buildpack artifact for testing with `pack` and `pack build`.
build:
@buildpack-packager build -cached -any-stack