Continuous Integration
Normally when using a code formatter like CSharpier, you'll want to ensure that all code that makes it to your main branch has been formatted. This can be accomplished by doing the following
Set up a dotnet tool manifest file at
.config/dotnet-tools.json
with the following content. Replacing[SpecificVersion]
with the version of CSharpier you are currently using.{
"version": 1,
"isRoot": true,
"tools": {
"csharpier": {
"version": "[SpecificVersion]",
"commands": [
"dotnet-csharpier"
]
}
}
}Use your preferred CI/CD tool to run the following commands.
dotnet tool restore
dotnet csharpier --check .An example Github Actions workflow to accomplish this
name: Validate PR
on:
pull_request:
branches: [ main ]
jobs:
check_formatting:
runs-on: ubuntu-latest
name: Check Formatting
steps:
- uses: actions/checkout@v2
- run: |
dotnet tool restore
dotnet csharpier --check .