mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
63 lines
1.8 KiB
YAML
63 lines
1.8 KiB
YAML
name: Empty Files Checker
|
|
|
|
on:
|
|
push:
|
|
branches: [ master, staging, stable ]
|
|
merge_group:
|
|
pull_request:
|
|
types: [ opened, reopened, synchronize, ready_for_review ]
|
|
paths:
|
|
- 'Content.Client/**'
|
|
- 'Content.Server/**'
|
|
- 'Content.Shared/**'
|
|
- 'Resources/**'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: ${{ github.event_name != 'merge_group' }}
|
|
|
|
env:
|
|
# Directories to scan for empty files. obj/ and bin/ are skipped
|
|
SEARCH_PATHS: "Content.Client Content.Server Content.Shared Resources"
|
|
# File extensions to check, without dots
|
|
FILE_EXTENSIONS: "cs xaml yaml yml ftl xml json"
|
|
|
|
jobs:
|
|
check_empty_files:
|
|
name: Check for empty files
|
|
if: github.actor != 'PJBot' && github.event.pull_request.draft == false
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Setup Submodule
|
|
run: git submodule update --init
|
|
|
|
- name: Find empty files
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
|
|
read -ra paths <<< "$SEARCH_PATHS"
|
|
read -ra exts <<< "$FILE_EXTENSIONS"
|
|
|
|
find_expr=()
|
|
for ext in "${exts[@]}"; do
|
|
find_expr+=( -o -name "*.$ext" )
|
|
done
|
|
find_expr=("${find_expr[@]:1}") # drop leading -o
|
|
|
|
mapfile -t EMPTY < <(
|
|
find "${paths[@]}" \
|
|
\( -name obj -o -name bin \) -prune -o \
|
|
-type f \( "${find_expr[@]}" \) \
|
|
-exec sh -c 'test -z "$(tr -d "[:space:]" < "$1")" && echo "$1"' sh {} \;
|
|
)
|
|
|
|
if [ "${#EMPTY[@]}" -gt 0 ]; then
|
|
echo "::error::Found empty files:"
|
|
printf ' - %s\n' "${EMPTY[@]}"
|
|
exit 1
|
|
fi
|
|
|
|
echo "No empty files found."
|