Home GitHub Actions: Setup Check-In build
Post
Cancel

GitHub Actions: Setup Check-In build

In this article we gonna create continious integration check-in build using GitHub Actions that will be launched at every new commit or pull request in specific branches.

Create build workflow

All you need to do is to create new .yml file at your repository:

1
{YOUR_PROJECT}/.github/workflows/check-in.yml

With that content:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Check-in

env:
  GITHUB_TOKEN: ${{ github.token }}  # set this to access token to github.com
  TEST_PROJECT_NAME: Project.Tests   # set this to your test project name

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  check_in:
    name: Build and test
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v2
      - name: Setup .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: 3.1.101 # use your dotnet version

      - name: Restore dependencies
        run: dotnet restore

      - name: Build solution
        run: dotnet build --configuration Release --no-restore

      - name: Test solution and collect coverage # Your test framework support required (i.e. NUnit/xUnit)
        run: dotnet test --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutput=coverage/lcov.info /p:CoverletOutputFormat=lcov

      - name: Publish test coverage report to coveralls.io # Coveralls support required
        uses: coverallsapp/github-action@v1.1.2 # update this version to latest if possible
        with:
          github-token: ${{ env.GITHUB_TOKEN }}
          path-to-lcov: ./{{ env.TEST_PROJECT_NAME }}/coverage/lcov.info

NUnit support

Install NUnit + NUnit3TestAdapter NuGet packages in your test project(s) to be able to execute unit tests:

1
2
dotnet add package NUnit
dotnet add package NUnit3TestAdapter

Code Coverage

If you want to publish code coverage results at your project’s readme file, you can do following:

Login at coveralls through GitHub.

Install coverall.msbuild NuGet package in your test project(s):

1
dotnet add package coverlet.msbuild

Place badge that could be found at coveralls repository location into your readme file

This post is licensed under CC BY 4.0 by the author.

GPG: Files validation with GPG and SHA

Generate personal CA and certificates for client auth