Skip to content

fix: update cycle to build a test project (#41) #110

fix: update cycle to build a test project (#41)

fix: update cycle to build a test project (#41) #110

Workflow file for this run

name: Build and Test
on:
workflow_dispatch:
pull_request:
branches: [ main, develop ]
push:
branches: [ main, develop ]
paths-ignore:
- '**.md'
- '.gitignore'
- 'docs/**'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Cache .NET tools
uses: actions/cache@v4
with:
path: ~/.dotnet/tools
key: ${{ runner.os }}-dotnet-tools-${{ hashFiles('.config/dotnet-tools.json') }}
- name: Install linting tools
run: dotnet tool restore
- name: Validate code linting
run: dotnet dotnet-csharpier --check .
build_and_test:
needs: lint
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Run unit tests
run: dotnet test --no-build --filter "Category=Unit" --configuration Release --verbosity minimal --logger "trx;LogFileName=unit_tests.trx"
- name: Run integration tests
run: dotnet test --no-build --filter "Category=Integration" --configuration Release --verbosity minimal --logger "trx;LogFileName=integration_tests.trx"
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: .NET Tests # Name of the check run which will be created
path: '**/TestResults/*.trx' # Path to test results
reporter: dotnet-trx # Format of test results
fail-on-error: true # Fail workflow if test reporter fails
list-suites: 'all' # List all test suites in report
list-tests: 'failed' # List all failed tests in report
max-annotations: 50 # Maximum number of annotations to create
- name: Upload artifacts
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: app-build
path: |
**/bin/**/*.dll
**/bin/**/*.exe
**/bin/**/*.pdb
!**/bin/**/ref/**