ci(workspace): guard against raw blobs that should be git lfs
This commit is contained in:
parent
57d8729470
commit
e5d39be400
33
.github/workflows/ci.yml
vendored
33
.github/workflows/ci.yml
vendored
|
|
@ -34,17 +34,46 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Check Lua Formatting
|
- name: Check Lua Formatting
|
||||||
uses: JohnnyMorganz/stylua-action@v4
|
uses: JohnnyMorganz/stylua-action@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
version: latest
|
version: latest
|
||||||
args: --check assets/scripts/ mods/
|
args: --check assets/scripts/ mods/
|
||||||
|
|
||||||
- name: Run Selene
|
- name: Run Selene
|
||||||
run: |
|
run: |
|
||||||
curl -sL https://github.com/Kampfkarren/selene/releases/download/0.30.1/selene-light-0.30.1-linux.zip -o selene.zip
|
curl -sL https://github.com/Kampfkarren/selene/releases/download/0.30.1/selene-light-0.30.1-linux.zip -o selene.zip
|
||||||
unzip -q selene.zip
|
unzip -q selene.zip
|
||||||
chmod +x selene
|
chmod +x selene
|
||||||
./selene assets/scripts/ mods/
|
./selene assets/scripts/ mods/
|
||||||
|
|
||||||
|
lfs-guard:
|
||||||
|
name: LFS Pointer Guard
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Checkout without smudging LFS content so the committed git objects can be inspected directly; a raw-committed binary is only distinguishable from a proper pointer at the object level, not in a smudged working tree.
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
lfs: false
|
||||||
|
|
||||||
|
- name: Verify LFS-tracked files are stored as pointers
|
||||||
|
run: |
|
||||||
|
# Every tracked path whose .gitattributes filter resolves to lfs must be committed as an LFS pointer. A binary committed in its place (e.g. by a contributor without git-lfs installed) is the failure this guard catches.
|
||||||
|
should_be_lfs=$(git ls-files | git check-attr --stdin filter | sed -n 's/: filter: lfs$//p')
|
||||||
|
violations=""
|
||||||
|
while IFS= read -r f; do
|
||||||
|
[ -z "$f" ] && continue
|
||||||
|
first_line=$(git cat-file -p "HEAD:$f" | head -n1)
|
||||||
|
if [ "$first_line" != "version https://git-lfs.github.com/spec/v1" ]; then
|
||||||
|
violations="$violations $f"
|
||||||
|
fi
|
||||||
|
done <<< "$should_be_lfs"
|
||||||
|
if [ -n "$violations" ]; then
|
||||||
|
echo "::error::Files match an LFS pattern in .gitattributes but were committed as raw blobs instead of Git LFS pointers:"
|
||||||
|
for f in $violations; do echo " - $f"; done
|
||||||
|
echo "Fix: install git-lfs, run 'git lfs install', then 're-add' each file with 'git add --renormalize <file>' and recommit."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "All LFS-tracked files are stored as pointers."
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue