RecordVisitors–CI –part 4

It will be perfect for any project to have a CI to improve feedback. GitHub actions is helpful here  – just put a gitlab.yml.

After few iterations, mine looks like this

name: BuildAndTest

on:

push:

branches: [ main ]

  pull_request:

    branches: [ main ]

jobs:

  build:

    #runs-on: ubuntu-latest

    runs-on: windows-2019

    steps:

    – uses: actions/checkout@v2

    – name: Setup .NET

      uses: actions/setup-dotnet@v1

      with:

        dotnet-version: 5.0.x

    – name: Restore dependencies

      run: |

        cd src/RecordVisitors

        dotnet restore

    – name: Build

      run: |

        cd src/RecordVisitors

        dotnet build –no-restore

    – name: Test

      run: |

        cd src/RecordVisitors

        dotnet test –no-build –verbosity normal

    – name: code coverage

      run: |

        cd src/RecordVisitors

        dotnet tool restore

        dotnet coverlet AutomatedTestRecord\bin\Debug\net5.0\AutomatedTestRecord.dll –target “dotnet” –targetargs “test RecordVisitors.sln –no-build”  –format opencover –exclude “[SampleWeb*]*”  –exclude “[xunit*]*” –verbosity detailed

        #dotnet coverlet AutomatedTestRecord\bin\Debug\net5.0\AutomatedTestRecord.dll –target “dotnet” –targetargs “test RecordVisitors.sln”  –format opencover  –verbosity detailed

        dotnet reportgenerator “-reports:coverage.opencover.xml” “-targetdir:coveragereport” “-reporttypes:HTMLInline;HTMLSummary;Badges”

    – name: ‘Upload Artifact’

      uses: actions/upload-artifact@v2

      with:

        name: codeCoverage

        path: src/RecordVisitors/coveragereport

        retention-days: 1

    – name: verify code coverage

      run: |

        ls src/RecordVisitors/coverage.opencover.xml

    – uses: codecov/codecov-action@v1

      with:

        files: src/RecordVisitors/coverage.opencover.xml

        fail_ci_if_error: true # optional (default = false)

        #verbose: true # optional (default = false)

    – name: Pack

      run: |

        cd src/RecordVisitors/RecordVisitors

        dotnet pack –include-source –include-symbols

Looks pretty much self-explanatory to me. Build, test, run code coverage and uploads to https://app.codecov.io/gh/ignatandrei/RecordVisitors  ( I am proud : CC 94 % )