From 53a80b9d0e6828af8793799d8a76e93fc61a355b Mon Sep 17 00:00:00 2001 From: Bryce Adelstein Lelbach aka wash Date: Thu, 11 Dec 2025 19:47:52 -0500 Subject: [PATCH] CI: Add tests that validate that files are correctly tracked by Git LFS. --- .github/workflows/test-git-lfs.yml | 73 ++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/test-git-lfs.yml diff --git a/.github/workflows/test-git-lfs.yml b/.github/workflows/test-git-lfs.yml new file mode 100644 index 0000000..bd87c4c --- /dev/null +++ b/.github/workflows/test-git-lfs.yml @@ -0,0 +1,73 @@ +name: Test Git LFS Tracking + +on: + push: + branches: + - '**' + # pull_request is not supported for this workflow due to self-hosted runners + # see the "Reviewing PRs from forks" section in CONTRIBUTING.md for more details + +jobs: + check-lfs: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Check that binary files are tracked by LFS + run: | + echo "Checking that all binary files are tracked by Git LFS..." + + # File extensions that should be tracked by LFS (from .gitattributes) + EXTENSIONS="pptx pdf png jpg jpeg gif webp" + + # Build find pattern + FIND_PATTERN="" + for ext in $EXTENSIONS; do + if [ -n "$FIND_PATTERN" ]; then + FIND_PATTERN="$FIND_PATTERN -o" + fi + FIND_PATTERN="$FIND_PATTERN -name *.$ext" + done + + # Find all matching files + FILES=$(find . -type f \( $FIND_PATTERN \) ! -path "./.git/*" ! -path "./venv/*" 2>/dev/null || true) + + if [ -z "$FILES" ]; then + echo "No binary files found to check." + exit 0 + fi + + FAILED=0 + NOT_LFS_FILES="" + + for file in $FILES; do + # Check if file is an LFS pointer (starts with "version https://git-lfs.github.com/spec/v1") + if head -c 50 "$file" 2>/dev/null | grep -q "version https://git-lfs.github.com/spec/v1"; then + echo "✓ $file (LFS pointer)" + else + echo "✗ $file (NOT tracked by LFS)" + NOT_LFS_FILES="$NOT_LFS_FILES\n - $file" + FAILED=1 + fi + done + + if [ $FAILED -eq 1 ]; then + echo "" + echo "==========================================" + echo "ERROR: The following files should be tracked by Git LFS but are not:" + echo -e "$NOT_LFS_FILES" + echo "" + echo "To fix this, run:" + echo " git rm --cached " + echo " git add " + echo " git commit -m 'Track file with Git LFS'" + echo "" + echo "Make sure Git LFS is installed and .gitattributes includes the file pattern." + echo "==========================================" + exit 1 + fi + + echo "" + echo "All binary files are properly tracked by Git LFS!"