-
Notifications
You must be signed in to change notification settings - Fork 14
Added a top-level Makefile in dotnet-sdk to simplify running tests and linters #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
3222935
b009125
01974ab
5ec6bca
28b9880
e61a002
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| .PHONY: help test test-net48 test-net8 test-net9 lint fmt check | ||
|
|
||
| # Default target when running just 'make' | ||
| help: | ||
| @echo "Available targets:" | ||
| @echo " test - Run all tests" | ||
| @echo " test-net48 - Run tests for .NET Framework 4.8" | ||
| @echo " test-net8 - Run tests for .NET 8.0" | ||
| @echo " test-net9 - Run tests for .NET 9.0" | ||
| @echo " lint - Verify code formatting and style" | ||
| @echo " fmt - Apply code formatting" | ||
| @echo " check - Run all checks (lint + test)" | ||
|
|
||
| # Run tests for all supported frameworks | ||
| test: test-net48 test-net8 test-net9 | ||
| @echo "✅ All tests completed successfully!" | ||
|
|
||
| # Restore NuGet packages | ||
| restore: | ||
| @echo "📦 Restoring NuGet packages..." | ||
| @dotnet restore ./OpenFga.Sdk.sln | ||
|
|
||
| # Run tests for .NET Framework 4.8 | ||
| test-net48: restore | ||
| @echo "🚀 Running tests for .NET Framework 4.8..." | ||
| @dotnet test --framework net48 --no-build | ||
|
|
||
| # Run tests for .NET 8.0 | ||
| test-net8: restore | ||
| @echo "🚀 Running tests for .NET 8.0..." | ||
| @dotnet test --framework net8.0 --no-build | ||
|
|
||
| # Run tests for .NET 9.0 | ||
| test-net9: restore | ||
| @echo "🚀 Running tests for .NET 9.0..." | ||
| @dotnet test --framework net9.0 --no-build | ||
| # Verify code formatting and analyzers | ||
| lint: | ||
| @echo "🔍 Checking code formatting..." | ||
| @dotnet format --verify-no-changes --severity info || (echo "❌ Code formatting issues found. Run 'make fmt' to fix." && exit 1) | ||
| @echo "✅ Code formatting looks good!" | ||
|
|
||
| # Apply formatting fixes | ||
| fmt: | ||
| @echo "🎨 Applying code formatting..." | ||
| @# Create backups of project files | ||
| @cp src/OpenFga.Sdk/OpenFga.Sdk.csproj src/OpenFga.Sdk/OpenFga.Sdk.csproj.bak | ||
| @cp src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj.bak | ||
|
|
||
| @# Use sed with appropriate flags for platform compatibility | ||
| @if [ "$$(uname)" = "Darwin" ]; then \ | ||
| sed -i '' "s/<TargetFrameworks>.*<\\/TargetFrameworks>/<TargetFramework>net8.0<\\/TargetFramework>/" src/OpenFga.Sdk/OpenFga.Sdk.csproj && \ | ||
| sed -i '' "s/<TargetFrameworks>.*<\\/TargetFrameworks>/<TargetFramework>net8.0<\\/TargetFramework>/" src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj; \ | ||
| else \ | ||
| sed -i "s/<TargetFrameworks>.*<\\/TargetFrameworks>/<TargetFramework>net8.0<\\/TargetFramework>/" src/OpenFga.Sdk/OpenFga.Sdk.csproj && \ | ||
| sed -i "s/<TargetFrameworks>.*<\\/TargetFrameworks>/<TargetFramework>net8.0<\\/TargetFramework>/" src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj; \ | ||
| fi | ||
|
|
||
| @# Run formatting | ||
| @dotnet restore ./OpenFga.Sdk.sln | ||
| @dotnet format ./OpenFga.Sdk.sln || true | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The || true swallows errors. If formatting fails, you won't know. |
||
|
|
||
| @# Restore original project files | ||
| @mv src/OpenFga.Sdk/OpenFga.Sdk.csproj.bak src/OpenFga.Sdk/OpenFga.Sdk.csproj | ||
| @mv src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj.bak src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj | ||
| @echo "✅ Code formatting applied successfully!" | ||
|
|
||
| # Convenience target to run all checks | ||
| check: fmt lint test | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This applies formatting fixes, then checks formatting (which will always pass since you just fixed it). |
||
| @echo "✨ All checks completed successfully!" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --no-build flag skips building, but the dependency is only restore, not a build target. Tests will fail because there's no compiled output.