DEV Community

Shuto Osawa
Shuto Osawa

Posted on

Learning GitHub Runner Self-Hosting with Windows Desktop Application

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.

GitHub Settings

We can construct a runner by simply visiting GitHub settings.
Image description

Since I am working on Windows Desktop App, I chose Windows Runner Image.
Image description

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".

Image description

Configure yml file

We can use the runner in the workflow. We setup the workflow for .NET 6 Windows Forms application.

Image description

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: microsoft/setup-msbuild@v1.1

    # Execute all unit tests in the solution
    - name: Execute unit tests
      run: dotnet test
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)