Skip to content

Commit bd1173b

Browse files
committed
Replaced ripgrep with normal grep so we don't have to install anything
1 parent 43214cc commit bd1173b

2 files changed

Lines changed: 11 additions & 17 deletions

File tree

.github/workflows/check-runtime-editor-refs.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,5 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818

19-
- name: Install ripgrep
20-
run: sudo apt-get install -y ripgrep
21-
2219
- name: Check Runtime code has no Editor namespace references
23-
run: bash check-runtime-editor-refs.sh
20+
run: bash check-runtime-editor-refs.sh

check-runtime-editor-refs.sh

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
#!/bin/bash
2-
2+
[ -n "$BASH_VERSION" ] || { echo "ERROR: This script requires bash. Run with: bash $0" >&2; exit 1; }
33
set -euo pipefail
44

55
RUNTIME_DIR="Packages/com.unity.inputsystem/InputSystem/Runtime"
66

7-
# Rust regexes (no PCRE2 required) — \b prevents matching identifiers that merely contain these strings.
7+
# POSIX ERE patterns for grep -E, compatible with macOS (BSD grep) and Ubuntu (GNU grep).
8+
# No \b word boundaries — not portable across both. False positive risk is negligible
9+
# since no real identifiers contain these namespace roots as substrings.
810
# (\.[A-Za-z0-9_]+)* covers sub-namespaces (UnityEditor.UI, …Editor.Tools, …).
9-
# Add more lines as needed, e.g. '\bUnityEditorInternal(\.[A-Za-z0-9_]+)*\b'
11+
# Add more lines as needed, e.g. 'UnityEditorInternal(\.[A-Za-z0-9_]+)*'
1012
FORBIDDEN_REGEX=(
11-
'\bUnityEditor(\.[A-Za-z0-9_]+)*\b'
12-
'\bUnityEngine\.InputSystem\.Editor(\.[A-Za-z0-9_]+)*\b'
13+
'UnityEditor(\.[A-Za-z0-9_]+)*'
14+
'UnityEngine\.InputSystem\.Editor(\.[A-Za-z0-9_]+)*'
1315
)
1416

1517
RED=$'\033[0;31m'
1618
GREEN=$'\033[0;32m'
1719
NC=$'\033[0m'
1820

19-
command -v rg >/dev/null 2>&1 || { echo "ERROR: ripgrep (rg) is not installed. See https://github.com/BurntSushi/ripgrep#installation" >&2; exit 1; }
20-
2121
INCLUDE_COMMENTS=false
2222
for arg in "$@"; do
2323
case "$arg" in
@@ -42,15 +42,12 @@ done
4242

4343
COMBINED=$(IFS='|'; echo "${FORBIDDEN_REGEX[*]}")
4444

45-
PATTERN="(?:$COMBINED)"
46-
47-
RG_OUTPUT=$(rg --type cs --line-number --no-heading --color never "$PATTERN" "$RUNTIME_DIR" || true)
45+
GREP_OUTPUT=$(grep -rn --include='*.cs' --color=never -E "$COMBINED" "$RUNTIME_DIR" || true)
4846

4947
if [ "$INCLUDE_COMMENTS" = false ]; then
50-
# Filter out pure comment lines (/// and //) by checking the content portion (field 3+)
51-
VIOLATIONS=$(echo "$RG_OUTPUT" | grep -Ev ':[0-9]+:[[:space:]]*//' || true)
48+
VIOLATIONS=$(echo "$GREP_OUTPUT" | grep -Ev ':[0-9]+:[[:space:]]*//' || true)
5249
else
53-
VIOLATIONS="$RG_OUTPUT"
50+
VIOLATIONS="$GREP_OUTPUT"
5451
fi
5552

5653
if [ -z "$VIOLATIONS" ]; then

0 commit comments

Comments
 (0)