Skip to content

Add a top-level Makefile in dotnet-sdk to simplify running tests and linters #138

@SoulPancake

Description

@SoulPancake

Checklist

Describe the problem you'd like to have solved

Contributors currently need to know the exact dotnet incantations (including multi-TFM testing) and CI nuances to run tests and formatting locally.
a standard Makefile with test, lint, and fmt targets will make local workflows consistent and reduce onboarding friction.

Describe the ideal solution

Add a Makefile at the root of the dotnet-sdk repository with the following structure:

.PHONY: test lint fmt check

# Run tests for all supported frameworks
test:
	dotnet test --framework net48
	dotnet test --framework net8.0
	dotnet test --framework net9.0

# Verify code formatting and analyzers
lint:
	dotnet format --verify-no-changes --severity info || true

# Apply formatting fixes
fmt:
	# Format using a single target to avoid merge conflicts with multi-target projects
	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 && \
	sed "s/<TargetFrameworks>.*<\/TargetFrameworks>/<TargetFramework>net8.0<\/TargetFramework>/" src/OpenFga.Sdk/OpenFga.Sdk.csproj.bak > src/OpenFga.Sdk/OpenFga.Sdk.csproj && \
	sed "s/<TargetFrameworks>.*<\/TargetFrameworks>/<TargetFramework>net8.0<\/TargetFramework>/" src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj.bak > src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj && \
	dotnet restore ./OpenFga.Sdk.sln && dotnet format ./OpenFga.Sdk.sln || true && \
	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

# Convenience target to run all c
```hecks
check: fmt lint test


This allows contributors to simply run:

make test # run all unit tests
make lint # verify code style and analyzers
make fmt # apply formatting
make check # run all of the above



### Alternatives and current workarounds

_No response_

### References

_No response_

### Additional context

_No response_

Metadata

Metadata

Assignees

Labels

Projects

Status

In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions