Add GitHub Actions workflow for .NET build and test#15
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a GitHub Actions workflow intended to build, test, and publish the .NET solution in CI.
Changes:
- Introduces
.github/workflows/build.ymlwith steps to restore, build, test, upload TRX results, and publish. - Configures the workflow to run on manual dispatch and on pushes to a specified branch.
- Sets a repo-wide
DOTNET_VERSIONfor the workflow job.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| defaults: | ||
| run: | ||
| working-directory: src | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: ${{ env.DOTNET_VERSION }} | ||
|
|
||
| - name: Restore | ||
| run: dotnet restore CodeClash.sln |
There was a problem hiding this comment.
The workflow sets defaults.run.working-directory: src, but all dotnet ... CodeClash.sln commands assume the solution is in the current directory. In this repo CodeClash.sln is at the repository root, so restore/build will fail with "solution file not found". Either remove the working-directory default, or change the commands to reference ../CodeClash.sln (and adjust any other relative paths accordingly).
| - name: Restore | ||
| run: dotnet restore CodeClash.sln | ||
|
|
||
| - name: Build | ||
| run: > | ||
| dotnet build CodeClash.sln | ||
| --configuration Release | ||
| --no-restore | ||
| -p:TreatWarningsAsErrors=true | ||
| -p:EnforceCodeStyleInBuild=true | ||
|
|
There was a problem hiding this comment.
dotnet restore/build/test/publish CodeClash.sln will attempt to build every project in the solution, including docker-compose.dcproj (uses Sdk="Microsoft.Docker.Sdk"). That SDK typically isn't available on ubuntu-latest, so the workflow is likely to fail even if the .sln path issue is fixed. Consider building/publishing the actual .NET projects directly (e.g., the API csproj), or exclude the docker-compose project from the CI build path.
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - master |
There was a problem hiding this comment.
The workflow is configured to run on pushes to master, but this PR appears to be targeting main. If the default branch is main, this workflow won't run on normal pushes. Update the branch filter to main (or include both main and master if you need to support both).
| - master | |
| - main |
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - master |
There was a problem hiding this comment.
CI currently won't run for pull requests (only workflow_dispatch and push). Adding a pull_request trigger helps catch build/test issues before merge and is typically expected for a build workflow.
| - master | |
| - master | |
| pull_request: | |
| branches: | |
| - master |
| - name: Test | ||
| run: > | ||
| dotnet test CodeClash.sln | ||
| --configuration Release | ||
| --no-restore | ||
| --no-build | ||
| --verbosity normal | ||
| --logger "trx;LogFileName=test-results.trx" | ||
|
|
There was a problem hiding this comment.
The repo doesn't contain any test projects (no csproj references Microsoft.NET.Test.Sdk), so dotnet test CodeClash.sln is likely to fail (or at best provide no meaningful signal). Consider either targeting specific test projects once they exist, or making this step conditional/omitting it until tests are added so CI doesn't fail permanently.
No description provided.