In the previous post, I talked about running .NET application using CLI. Now, we can use GitHub actions and run unittest for the desktop application.
GitHub provides action runner, so we can use their runners without self-hosting a runner. At my work, we were not able to use GitHub provided runners. Therefore, we had to self-host a runner to introduce CI.
GitHub provides a very gentle introduction to setup a runner. All we need to do is copy and paste their instruction.
We need to download the runner package and then, configure a runner on your computer.
After proper setup of the the runner, we should be able to use the runner we just configured. In my case, I see "TestRunner".
We can use the runner in the workflow. We setup the workflow for .NET 6 Windows Forms application.
name: .NET Framework Desktop on: push: branches: [ "master" ] pull_request: branches: [ "master" ] jobs: build: #The runs-on below needs to match the tags of the runner. runs-on: [self-hosted, Windows,x64] steps: - uses: actions/checkout@v1 name: Checkout Code - name: Add msbuild to PATH uses: email@example.com # Execute all unit tests in the solution - name: Execute unit tests run: dotnet test
The workflow syntax can be found in their official documentation, so I will not go into details of it.
In the last line of the yml file, this is what I wanted to achieve in this post.
I want to run the test everytime I push my code to this repository.