-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (47 loc) · 1.77 KB
/
Copy pathMakefile
File metadata and controls
52 lines (47 loc) · 1.77 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
IMAGE_TAG ?= science-template:verify
.PHONY: docker-build docker-verify docker-verify-rw clean
docker-build:
docker build -f .devcontainer/Dockerfile -t $(IMAGE_TAG) .
# Env guardrails: HOME=/tmp and PYTHONNOUSERSITE=1 prevent pip user-site writes (e.g. /.local)
docker-verify: docker-build
mkdir -p .sisyphus/evidence
docker run --rm \
-v "$(CURDIR)":/work:ro \
-v science-template-pip-cache:/tmp/pip-cache \
-e PYTHONDONTWRITEBYTECODE=1 \
-e XDG_CACHE_HOME=/tmp/.cache \
-e PIP_CACHE_DIR=/tmp/pip-cache \
-e HOME=/tmp \
-e PYTHONNOUSERSITE=1 \
$(IMAGE_TAG) \
sh -lc 'cp -a /work /tmp/work \
&& cd /tmp/work \
&& python -m venv /tmp/venv \
&& /tmp/venv/bin/pip install -U pip \
&& /tmp/venv/bin/pip install ".[test]" \
&& /tmp/venv/bin/pytest -q -o cache_dir=/tmp/pytest_cache \
&& /tmp/venv/bin/python app/main.py' \
| tee .sisyphus/evidence/task-1-docker-verify.log
# Debugging target: read-write mount (use only when read-only breaks)
docker-verify-rw: docker-build
@echo "WARNING: Using read-write mount. This may pollute the workspace."
mkdir -p .sisyphus/evidence
docker run --rm \
-v "$(CURDIR)":/work \
-w /work \
-e PYTHONDONTWRITEBYTECODE=1 \
-e XDG_CACHE_HOME=/tmp/.cache \
-e PIP_CACHE_DIR=/tmp/pip-cache \
-e HOME=/tmp \
-e PYTHONNOUSERSITE=1 \
$(IMAGE_TAG) \
sh -lc 'python -m venv /tmp/venv \
&& /tmp/venv/bin/pip install -U pip \
&& /tmp/venv/bin/pip install ".[test]" \
&& /tmp/venv/bin/pytest -q -o cache_dir=/tmp/pytest_cache \
&& /tmp/venv/bin/python app/main.py' \
| tee .sisyphus/evidence/task-1-docker-verify-rw.log
clean:
rm -rf build/ dist/ src/*.egg-info/ .pytest_cache/ .sisyphus/evidence/
find . -type d -name "__pycache__" -exec rm -rf {} +
$(MAKE) -C docs clean