Skip to content

dotnet-build-and-test #48

dotnet-build-and-test

dotnet-build-and-test #48

#
# This workflow will build and run all unit tests using dotnet docker containers,
# each targeting a single version of the dotnet SDK.
#
name: dotnet-build-and-test
on:
workflow_dispatch:
schedule:
- cron: '0 7 * * *'
pull_request:
branches: [ "main", "feature*" ]
paths:
- 'dotnet/**'
- 'samples/dotnet/**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
include:
- { os: 'ubuntu', dotnet: '6.0-jammy', configuration: Debug }
- { os: 'ubuntu', dotnet: '7.0-jammy', configuration: Release }
- { os: 'ubuntu', dotnet: '8.0-preview-jammy', configuration: Release }
- { os: 'windows', dotnet: '6.0', configuration: Release }
- { os: 'windows', dotnet: '7.0', configuration: Debug }
- { os: 'windows', dotnet: '8.0-preview', configuration: Release }
runs-on: ubuntu-latest
env:
NUGET_CERT_REVOCATION_MODE: offline
DOTNET_DOCKER_IMG: mcr.microsoft.com/dotnet/sdk:${{ matrix.dotnet }}
steps:
- uses: actions/checkout@v3
with:
clean: true
- name: Pull container dotnet/sdk:${{ matrix.dotnet }}
run: docker pull mcr.microsoft.com/dotnet/sdk:${{ matrix.dotnet }}
- name: Build dotnet solutions
run: |
export SOLUTIONS=$(find ./dotnet/ -type f -name "*.sln" | tr '\n' ' ')
for solution in $SOLUTIONS; do
docker run --rm -v $(pwd):/app -w /app -e GITHUB_ACTIONS='true' $DOTNET_DOCKER_IMG /bin/sh -c "dotnet build -c ${{ matrix.configuration }} /warnaserror /app/$solution"
done
- name: Run Unit Tests
run: |
export UT_PROJECTS=$(find ./dotnet -type f -name "*.UnitTests.csproj" | tr '\n' ' ')
for project in $UT_PROJECTS; do
docker run --rm -v $(pwd):/app -w /app $DOTNET_DOCKER_IMG /bin/sh -c "dotnet test -c ${{ matrix.configuration }} /app/$project --no-build -v Normal --logger trx"
done