Skip to content

C# Linter for Unity Project #11

C# Linter for Unity Project

C# Linter for Unity Project #11

Workflow file for this run

name: C# Linter for Unity Project
on:
pull_request:
branches:
- main
workflow_dispatch: # Allows manual execution via GitHub CLI
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build project
uses: game-ci/unity-builder@v4
env:
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
buildMethod: Packages.Rider.Editor.RiderScriptEditor.SyncSolution
- name: List Generated Files (Debugging)
run: ls -la
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x # Adjust as needed
- name: Get C# Files (Changed in PR or All for Manual Runs)
id: get-files
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "🔎 Detecting changed C# files in PR..."
FILES=$(git diff --name-only origin/main...HEAD | grep '\.cs$' || true)
else
echo "🟢 Manual run detected! Running on ALL C# files..."
FILES=$(find Assets com.playeveryware.eos -type f -name "*.cs" ! -path "*/EOS_SDK/*" | tr '\n' ' ')
fi
if [ -z "$FILES" ]; then
echo "✅ No C# files to analyze!"
exit 0
fi
echo "Files to analyze:"
echo "$FILES"
echo "FILES=$FILES" >> $GITHUB_ENV
- name: Run Roslyn Analyzers Using `dotnet format`
continue-on-error: true # Allow warnings but don’t fail the workflow
run: |
for file in $FILES; do
echo "🔍 Running analyzers on $file"
dotnet format style --verify-no-changes --include "$file" --severity info --no-restore --verbosity diagnostic "eos_plugin_for_unity.sln" 2>&1 | tee -a lint_warnings.log
done
- name: Print Lint Warnings
run: |
echo "⚠️ Lint warnings detected:"
cat lint_warnings.log || echo "✅ No warnings found!"