Synvael/.github/workflows/ci.yml

80 lines
2.7 KiB
YAML

name: CI
on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev", "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
rust-lint:
name: Rust Check & Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Check Rust Formatting
run: cargo fmt --all -- --check
- name: Run Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
lua-lint:
name: Lua Lint & Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check Lua Formatting
uses: JohnnyMorganz/stylua-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
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/
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."