Skip to content

fix: convert TypeInfoDto from struct to class to resolve self-referen… #420

fix: convert TypeInfoDto from struct to class to resolve self-referen…

fix: convert TypeInfoDto from struct to class to resolve self-referen… #420

Workflow file for this run

name: CI - Build and Test
on:
push:
branches: [ "main", "develop" ]
paths:
- 'src/**'
- '.github/workflows/ci.yml'
pull_request:
branches: [ "main", "develop" ]
paths:
- 'src/**'
- '.github/workflows/ci.yml'
workflow_call:
# Security: Minimal required permissions
permissions:
contents: read # Read repository contents
actions: write # Upload artifacts
pull-requests: read # Read PR context
checks: write # Write test results
# Prevent concurrent runs of the same workflow only when CI actually runs
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
# Set global defaults
defaults:
run:
working-directory: ./src
jobs:
build-test:
name: Build and Test
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{ vars.DOTNET_VERSION || '8.0.x' }}
8.0.x
6.0.x
2.1.x
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build solution
run: dotnet build --no-restore --configuration Debug
- name: Copy DLLs for Unity tests
run: |
cp ./Nino/bin/Debug/netstandard2.1/Nino.Core.dll ./Nino.Unity/Packages/com.jasonxudeveloper.nino/Runtime/Nino.Core.dll
cp ./Nino/bin/Debug/netstandard2.1/Nino.Generator.dll ./Nino.Unity/Packages/com.jasonxudeveloper.nino/Runtime/Nino.Generator.dll
- name: Run unit tests
run: dotnet test --no-build --verbosity normal --configuration Debug --collect:"XPlat Code Coverage" --results-directory ./TestResults
- name: Cache Unity Library
uses: actions/cache@v4
with:
path: src/Nino.Unity/Library
key: Library-Nino-${{ runner.os }}-${{ hashFiles('Nino.Unity/Assets/**', 'Nino.Unity/ProjectSettings/**') }}
restore-keys: |
Library-Nino-${{ runner.os }}-
Library-Nino-
Library-
- name: Run Unity tests
# Skip Unity tests for external PRs (secrets not available in forks)
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: game-ci/unity-test-runner@v4
id: unity-tests
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
projectPath: ./src/Nino.Unity
testMode: editmode
githubToken: ${{ secrets.GITHUB_TOKEN }}
unityVersion: '2022.3.51f1'
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ github.run_number }}
path: |
artifacts
./src/TestResults
retention-days: 30
- name: Upload Unity coverage
uses: actions/upload-artifact@v4
if: always() && steps.unity-tests.outputs.coveragePath
with:
name: unity-coverage-${{ github.run_number }}
path: ${{ steps.unity-tests.outputs.coveragePath }}
retention-days: 30
# Run benchmarks on PRs only
benchmark:
name: Run Benchmarks
runs-on: ubuntu-latest
needs: [ build-test ]
if: github.event_name == 'pull_request'
timeout-minutes: 180
permissions:
contents: read
pull-requests: write
defaults:
run:
working-directory: ./src
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{ vars.DOTNET_VERSION || '8.0.x' }}
8.0.x
6.0.x
2.1.x
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-benchmark-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build benchmark project
run: |
cd Nino.Benchmark
dotnet build -c Release
- name: Run benchmarks
run: |
cd Nino.Benchmark
echo "Running benchmarks for PR #${{ github.event.pull_request.number }}..."
dotnet run -c Release --no-build
# Verify benchmark results exist (check for any github markdown file)
MARKDOWN_FILE=$(find BenchmarkDotNet.Artifacts/results -name "*-report-github.md" -type f 2>/dev/null | head -n1)
if [[ -n "$MARKDOWN_FILE" && -f "$MARKDOWN_FILE" ]]; then
echo "✅ Benchmark completed successfully - found report file:"
echo "$MARKDOWN_FILE"
else
echo "❌ Benchmark results not found"
echo "Looking for markdown files in results directory..."
find BenchmarkDotNet.Artifacts -name "*.md" -type f || echo "No markdown files found"
exit 1
fi
- name: Upload benchmark results
uses: actions/upload-artifact@v4
if: always()
with:
name: benchmark-results-pr-${{ github.event.pull_request.number }}
path: src/Nino.Benchmark/**/BenchmarkDotNet.Artifacts/results
retention-days: 30