Skip to content

C# Linter for Unity Project #14

C# Linter for Unity Project

C# Linter for Unity Project #14

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: pwd; 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 -- "*.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/*" || true)
fi
if [ -z "$FILES" ]; then
echo "✅ No C# files to analyze!"
exit 0
fi
# Convert newline-separated list into a comma-separated list
FILES_CSV=$(echo "$FILES" | tr '\n' ',' | sed 's/,$//')
echo "Files to analyze: $FILES_CSV"
echo "FILES=$FILES_CSV" >> $GITHUB_ENV
- name: Run Roslyn Analyzers Using `dotnet format`
continue-on-error: true # Allow warnings but don’t fail the workflow
run: |
echo "🔍 Running analyzers on multiple files..."
dotnet format style --verify-no-changes --include "$FILES" --severity info --no-restore --verbosity diagnostic "workspace.sln" 2>&1 | tee -a lint_warnings.log
- name: Print Lint Warnings
run: |
echo "⚠️ Lint warnings detected:"
cat lint_warnings.log || echo "✅ No warnings found!"