Skip to content

Commit 6cd5159

Browse files
committed
fix: improvements to the linter.
1 parent 3acace6 commit 6cd5159

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

.github/workflows/cs-linter.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
name: C# Linter for Targeted Directories
1+
name: C# Linter for Unity Project
22

33
on:
4+
pull_request:
5+
branches:
6+
- main
47
workflow_dispatch: # Allows manual execution via GitHub CLI
58

69
jobs:
@@ -16,25 +19,35 @@ jobs:
1619
with:
1720
dotnet-version: 8.0.x # Adjust as needed
1821

19-
- name: Find C# files in target directories (excluding EOS_SDK)
20-
id: find-files
22+
- name: Get C# Files (Changed in PR or All for Manual Runs)
23+
id: get-files
2124
run: |
22-
CS_FILES=$(find Assets com.playeveryware.eos -type f -name "*.cs" ! -path "com.playeveryware.eos/Runtime/EOS_SDK/*" | tr '\n' ' ')
23-
echo "Found C# files:"
24-
echo "$CS_FILES"
25-
echo "FILES=$CS_FILES" >> $GITHUB_ENV
25+
if [ "${{ github.event_name }}" = "pull_request" ]; then
26+
echo "🔎 Detecting changed C# files in PR..."
27+
FILES=$(git diff --name-only origin/main...HEAD | grep '\.cs$' || true)
28+
else
29+
echo "🟢 Manual run detected! Running on ALL C# files..."
30+
FILES=$(find Assets com.playeveryware.eos -type f -name "*.cs" ! -path "*/EOS_SDK/*" | tr '\n' ' ')
31+
fi
32+
33+
if [ -z "$FILES" ]; then
34+
echo "✅ No C# files to analyze!"
35+
exit 0
36+
fi
37+
38+
echo "Files to analyze:"
39+
echo "$FILES"
40+
echo "FILES=$FILES" >> $GITHUB_ENV
2641
27-
- name: Run Roslyn Analyzers on Selected C# Files
28-
if: env.FILES != ''
42+
- name: Run Roslyn Analyzers Using `dotnet format`
2943
continue-on-error: true # Allow warnings but don’t fail the workflow
3044
run: |
3145
for file in $FILES; do
32-
echo "🔍 Analyzing $file"
33-
dotnet build --no-restore -p:TreatWarningsAsErrors=false "$file" 2>&1 | tee -a lint_warnings.log
46+
echo "🔍 Running analyzers on $file"
47+
dotnet format analyze "$file" --severity info 2>&1 | tee -a lint_warnings.log
3448
done
3549
3650
- name: Print Lint Warnings
37-
if: env.FILES != ''
3851
run: |
3952
echo "⚠️ Lint warnings detected:"
40-
cat lint_warnings.log || echo "No warnings found!"
53+
cat lint_warnings.log || echo "No warnings found!"

0 commit comments

Comments
 (0)