Skip to content

Compatibility-Check #351

Compatibility-Check

Compatibility-Check #351

name: Compatibility-Check
on:
pull_request:
branches: [ master ]
push:
branches: [ master ]
workflow_dispatch:
schedule:
- cron: "0 3 * * *" # every day at 03:00 UTC
jobs:
api-compatibility-check:
name: API Compatibility Check
runs-on: windows-latest
steps:
- name: Checkout current fork
uses: actions/checkout@v6
- name: Checkout original repository
uses: actions/checkout@v6
with:
repository: SmartlyDressedGames/Legally-Distinct-Missile
path: original-repo
- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.x
- name: Build current fork (RocketModFix)
run: |
dotnet restore Rocket/Rocket.API/Rocket.API.csproj
dotnet restore Rocket/Rocket.Core/Rocket.Core.csproj
dotnet restore Rocket.Unturned/Rocket.Unturned.csproj
dotnet build Rocket/Rocket.API/Rocket.API.csproj --configuration Release --no-restore
dotnet build Rocket/Rocket.Core/Rocket.Core.csproj --configuration Release --no-restore
dotnet build Rocket.Unturned/Rocket.Unturned.csproj --configuration Release --no-restore
- name: Build original repository (Legally-Distinct-Missile)
run: |
cd original-repo
dotnet build Rocket/Rocket.API/Rocket.API.csproj --configuration Release --verbosity minimal
dotnet build Rocket/Rocket.Core/Rocket.Core.csproj --configuration Release --verbosity minimal
dotnet build Rocket.Unturned/Rocket.Unturned.csproj --configuration Release --verbosity minimal
- name: Verify assemblies exist
shell: cmd
run: |
echo "=== Checking if assemblies exist ==="
REM Define list of required assemblies
set "assemblies="
set "assemblies=%assemblies%Rocket\Rocket.API\bin\Release\net461\Rocket.API.dll "
set "assemblies=%assemblies%Rocket\Rocket.Core\bin\Release\net461\Rocket.Core.dll "
set "assemblies=%assemblies%Rocket.Unturned\bin\Release\net461\Rocket.Unturned.dll "
set "assemblies=%assemblies%original-repo\Rocket\Rocket.API\bin\Release\Rocket.API.dll "
set "assemblies=%assemblies%original-repo\Rocket\Rocket.Core\bin\Release\Rocket.Core.dll "
set "assemblies=%assemblies%original-repo\Rocket.Unturned\bin\Release\Rocket.Unturned.dll"
REM Check each assembly
for %%f in (%assemblies%) do (
if exist "%%f" (
echo "✅ %%~nxf exists"
) else (
echo "❌ %%~nxf not found"
echo "Expected path: %%f"
dir "%%~dpf" 2>nul || echo "Directory does not exist"
exit /b 1
)
)
- name: Install API compatibility tools
run: dotnet tool install --global Microsoft.DotNet.ApiCompat.Tool
- name: Generate suppression file for all breaking changes
id: generate
shell: cmd
run: |
echo "Generating suppression file for all breaking changes..."
apicompat ^
--left ./original-repo/Rocket/Rocket.API/bin/Release/Rocket.API.dll ^
--right ./Rocket/Rocket.API/bin/Release/net461/Rocket.API.dll ^
--left ./original-repo/Rocket/Rocket.Core/bin/Release/Rocket.Core.dll ^
--right ./Rocket/Rocket.Core/bin/Release/net461/Rocket.Core.dll ^
--left ./original-repo/Rocket.Unturned/bin/Release/Rocket.Unturned.dll ^
--right ./Rocket.Unturned/bin/Release/net461/Rocket.Unturned.dll ^
--generate-suppression-file ^
--suppression-output-file ./generated-api-suppressions.xml
- name: Upload generated suppression file
uses: actions/upload-artifact@v6
with:
name: generated-api-suppressions
path: ./generated-api-suppressions.xml
retention-days: 30
- name: Check API compatibility with manual suppressions
shell: pwsh
run: |
Write-Host "Checking API compatibility using manual suppression file..."
# Run apicompat and capture output directly to variables
$output = & apicompat @(
"--left", "./original-repo/Rocket/Rocket.API/bin/Release/Rocket.API.dll",
"--right", "./Rocket/Rocket.API/bin/Release/net461/Rocket.API.dll",
"--left", "./original-repo/Rocket/Rocket.Core/bin/Release/Rocket.Core.dll",
"--right", "./Rocket/Rocket.Core/bin/Release/net461/Rocket.Core.dll",
"--left", "./original-repo/Rocket.Unturned/bin/Release/Rocket.Unturned.dll",
"--right", "./Rocket.Unturned/bin/Release/net461/Rocket.Unturned.dll",
"--suppression-file", ".github\workflows\api-suppressions.xml"
) 2>&1
$exitCode = $LASTEXITCODE
$fullOutput = $output | Out-String
# Always show apicompat output
Write-Host "=== apicompat output ==="
Write-Host $fullOutput
Write-Host "=== end of apicompat output ==="
Write-Host "Exit code: $exitCode"
# Check output content instead of exit code, because for some reason it always returns 0, instead of 1!
if ($fullOutput -match "APICompat ran successfully without finding any breaking changes\.") {
Write-Host "✅ API compatibility check passed!" -ForegroundColor Green
Write-Host "No breaking changes found."
} elseif ($fullOutput -match "API breaking changes found") {
Write-Host "❌ API compatibility check failed!" -ForegroundColor Red
Write-Host "Breaking changes detected that are not covered by your suppression file."
Write-Host "Please either fix breaking change or update .github/workflows/api-suppressions.xml with generated-api-suppressions.xml from artifacts and commit if it's not important breaking change."
exit 1
} else {
Write-Host "❌ API compatibility check failed!" -ForegroundColor Red
Write-Host "Unexpected output from apicompat. Please check the output above."
exit 1
}
workflow-keepalive:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: liskin/gh-workflow-keepalive@v1