Пустая Проверка (#3754)

Добавляет проверку на whitespace-only файлы в CI
This commit is contained in:
Zekins 2026-10-03 19:25:54 +03:00 • committed by GitHub
parent f07ccbd0c8
commit be7f23bd65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 63 additions and 0 deletions

63
.github/workflows/empty-files.yml vendored Normal file
View file

@ -0,0 +1,63 @@
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."