mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
Пустая Проверка (#3754)
Добавляет проверку на whitespace-only файлы в CI
This commit is contained in:
parent
f07ccbd0c8
commit
be7f23bd65
4 changed files with 63 additions and 0 deletions
63
.github/workflows/empty-files.yml
vendored
Normal file
63
.github/workflows/empty-files.yml
vendored
Normal 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."
|
||||
Loading…
Add table
Reference in a new issue