feat: add CI github action to build and test project - #5
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a GitHub Actions CI workflow to build and test the .NET solution on pushes and pull requests targeting main.
Changes:
- Introduces
.github/workflows/dotnet.ymlto restore, build, and test onubuntu-latest. - Configures the runner to install .NET SDK
9.0.xviaactions/setup-dotnet.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - uses: actions/checkout@v4 | ||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 |
There was a problem hiding this comment.
For supply-chain security, consider pinning GitHub Actions to a full commit SHA (instead of the mutable @v4 tag) for both actions/checkout and actions/setup-dotnet.
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@3f14f4970e29fbfe43b8a0123c2f7bd0d1c7db2f # v4.0.0 |
| branches: [ "main" ] | ||
|
|
||
| jobs: | ||
| build: |
There was a problem hiding this comment.
This workflow does not set explicit permissions for GITHUB_TOKEN. To reduce risk when running on pull_request events (including from forks), consider adding least-privilege permissions (e.g., contents: read) at the workflow or job level.
| build: | |
| build: | |
| permissions: | |
| contents: read |
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 9.0.x |
There was a problem hiding this comment.
Consider enabling NuGet caching via actions/setup-dotnet (e.g., its built-in cache option) to speed up CI runs and reduce restore time on repeated builds.
| dotnet-version: 9.0.x | |
| dotnet-version: 9.0.x | |
| cache: true |
| - name: Restore dependencies | ||
| run: dotnet restore | ||
| - name: Build | ||
| run: dotnet build --no-restore |
There was a problem hiding this comment.
We should always build and test our code in Release
There was a problem hiding this comment.
we need to treat warnings as errors: -p:TreatWarningsAsErrors=true
| - name: Build | ||
| run: dotnet build --no-restore | ||
| - name: Test | ||
| run: dotnet test --no-build --verbosity normal |
There was a problem hiding this comment.
We need to output the test results into a structured format
- build in `release` mode. - output test results into structured format.
No description provided.