ci(workspace): extract inline run steps to script files
This commit is contained in:
parent
efc8fc12ac
commit
ccd105e0d3
28
.github/scripts/check-lfs-pointers.sh
vendored
Executable file
28
.github/scripts/check-lfs-pointers.sh
vendored
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
# Verifies that every LFS-tracked path is committed as a Git LFS pointer rather than as a raw binary.
|
||||
#
|
||||
# Requires a checkout performed without LFS smudging: a raw-committed binary is only distinguishable from a proper pointer at the object level, not in a smudged working tree.
|
||||
|
||||
set -eu
|
||||
|
||||
# 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:"
|
||||
# Unquoted expansion is intentional: the accumulated list is split on whitespace back into individual paths.
|
||||
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."
|
||||
14
.github/scripts/run-selene.sh
vendored
Executable file
14
.github/scripts/run-selene.sh
vendored
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
# Downloads a pinned selene release and lints the repository's Lua sources.
|
||||
#
|
||||
# selene publishes no maintained GitHub Action, so the linter binary is fetched per run. The version is pinned so that an upstream release cannot change CI results without a deliberate commit here.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SELENE_VERSION="0.30.1"
|
||||
SELENE_URL="https://github.com/Kampfkarren/selene/releases/download/${SELENE_VERSION}/selene-light-${SELENE_VERSION}-linux.zip"
|
||||
|
||||
curl -sL "$SELENE_URL" -o selene.zip
|
||||
unzip -q selene.zip
|
||||
chmod +x selene
|
||||
./selene assets/scripts/ mods/
|
||||
25
.github/workflows/ci.yml
vendored
25
.github/workflows/ci.yml
vendored
|
|
@ -46,11 +46,7 @@ jobs:
|
|||
args: --check assets/scripts/ mods/
|
||||
|
||||
- name: Run Selene
|
||||
run: |
|
||||
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
|
||||
chmod +x selene
|
||||
./selene assets/scripts/ mods/
|
||||
run: ./.github/scripts/run-selene.sh
|
||||
|
||||
lfs-guard:
|
||||
name: LFS Pointer Guard
|
||||
|
|
@ -62,21 +58,4 @@ jobs:
|
|||
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."
|
||||
run: ./.github/scripts/check-lfs-pointers.sh
|
||||
|
|
|
|||
Loading…
Reference in a new issue