Skip to content

Commit ce1c273

Browse files
committed
fix: Ensure build fails if changes are detected while building for linux
1 parent 21e8290 commit ce1c273

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ install:
2525
$(PYTHON) -m pip install $(CODE_DIR)
2626

2727
venv:
28+
ifeq ($(ENFORCE_CLEAN_GIT),true)
29+
# Ensure git 'trusts' the directory inside docker
30+
git config --global --add safe.directory $(CODE_DIR)
31+
$(CODE_DIR)/bin/ensure-clean-working-directory.sh
32+
33+
endif
2834
$(PYTHON) -m venv venv
2935

3036
tests: venv

bin/ensure-clean-working-directory.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
readonly ROOT_DIR="$(cd "$(dirname -- "$0")/.." >/dev/null; pwd -P)"
5+
6+
CHANGED_FILES=$(git -C "$ROOT_DIR" status --untracked-files=no --porcelain | wc -l)
7+
8+
if [[ "$CHANGED_FILES" -eq 0 ]]; then
9+
echo "Clean working directory"
10+
else
11+
echo "Changes detected" >/dev/stderr
12+
git status --untracked-files=no >/dev/stderr
13+
exit 1
14+
fi

compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ services:
33
image: quay.io/pypa/manylinux2014_x86_64
44
environment:
55
PYTHON:
6+
ENFORCE_CLEAN_GIT: "true"
67
volumes:
78
# Sharing the entire volume causes the created venv to be broken on the host
89

@@ -32,6 +33,7 @@ services:
3233
# These are included in the source distribution
3334
- "./LICENSE.txt:/code/LICENSE.txt"
3435
- "./README.md:/code/README.md"
36+
- "./SECURITY.md:/code/SECURITY.md"
3537
- "./py.typed:/code/py.typed"
3638

3739
# The build artifacts are stored in these locations

0 commit comments

Comments
 (0)