Update GitHub Actions (#112) #335
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: .NET Build & Test | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
dotnet: [net7.0, net8.0] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
7.0.x | |
8.0.x | |
- name: Install dependencies | |
run: cd src && dotnet restore | |
- name: Build | |
run: cd src && dotnet build --configuration Release --no-restore | |
- name: Unit Test With Coverage Report | |
run: | | |
cd ./tests/Atrea.PolicyEngine.Tests/ | |
dotnet test --framework=${{ matrix.dotnet }} --no-restore /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov | |
- name: Upload Code Coverage Results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: code-coverage-report-${{ matrix.dotnet }} | |
path: ./tests/Atrea.PolicyEngine.Tests/TestResults/coverage.${{ matrix.dotnet }}.info | |
coverage: | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
dotnet: [net8.0] # only upload one coverage report | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download Code Coverage Results | |
uses: actions/download-artifact@v4 | |
with: | |
name: code-coverage-report-${{ matrix.dotnet }} | |
- name: Publish Coverage Report | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path-to-lcov: coverage.${{ matrix.dotnet }}.info |