Skip to content

Commit

Permalink
fix: Ensure build fails if changes are detected while building for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
sindre-nistad committed Jan 15, 2024
1 parent 2c10be2 commit 7fc2ec9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ install:
$(PYTHON) -m pip install $(CODE_DIR)

venv:
ifeq ($(ENFORCE_CLEAN_GIT),true)
# Ensure git 'trusts' the directory inside docker
git config --global --add safe.directory $(CODE_DIR)
$(CODE_DIR)/bin/ensure-clean-working-directory.sh

endif
$(PYTHON) -m venv venv

tests: venv
Expand Down
14 changes: 14 additions & 0 deletions bin/ensure-clean-working-directory.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail

readonly ROOT_DIR="$(cd "$(dirname -- "$0")/.." >/dev/null; pwd -P)"

CHANGED_FILES=$(git -C "$ROOT_DIR" status --untracked-files=no --porcelain | wc -l)

if [[ "$CHANGED_FILES" -eq 0 ]]; then
echo "Clean working directory"
else
echo "Changes detected" >/dev/stderr
git status --untracked-files=no >/dev/stderr
exit 1
fi
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ services:
image: quay.io/pypa/manylinux2014_x86_64
environment:
PYTHON:
ENFORCE_CLEAN_GIT: "true"
volumes:
# Sharing the entire volume causes the created venv to be broken on the host

Expand Down

0 comments on commit 7fc2ec9

Please sign in to comment.