Skip to content
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions Makefile
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
Copy link
Member

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.


# 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
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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!"
Loading