Correct setup dotnet for build #598
Workflow file for this run
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: Dotnet Build and Test | |
on: | |
- push | |
- workflow_dispatch | |
permissions: | |
contents: read | |
actions: read | |
checks: write | |
pages: write | |
id-token: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup dotnet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
9.0.x | |
8.0.x | |
- name: Install tools | |
run: | | |
dotnet tool restore --tool-manifest .config/dotnet-tools-ci.json | |
- name: Install dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build | |
- name: Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: . | |
tests: | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
version: | |
- 8.0 | |
- 9.0 | |
steps: | |
- name: Setup dotnet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
${{ matrix.version }}.x | |
- name: Download a single artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
- name: Install tools | |
run: | | |
dotnet tool restore --tool-manifest .config/dotnet-tools-ci.json | |
- name: Tests with Coverage | |
run: > | |
dotnet coverage collect -o ${{ github.workspace }}/coverage/Coverage-${{ matrix.version }}.xml -f cobertura -s coverage.runsettings | |
dotnet test --no-build --logger "trx;LogFileName=TestResults-${{ matrix.version }}.trx" -f ${{ matrix.version }} | |
- name: Generate Coverage Report | |
if: always() | |
run: > | |
dotnet reportgenerator | |
-reports:${{ github.workspace }}/coverage/Coverage-${{ matrix.version }}.xml | |
-targetdir:"${{ github.workspace }}/coverage/" | |
-reporttypes:'MarkdownSummaryGithub;Html' | |
- name: Tests and Coverage Summary | |
id: coverage | |
if: always() | |
run: pwsh make-summary.ps1 | |
- name: Tests Report | |
uses: dorny/test-reporter@v1 | |
if: always() | |
with: | |
name: DotNET Tests (${{ matrix.version }}) | |
path: "**/TestResults-${{ matrix.version }}.trx" | |
reporter: dotnet-trx | |
- name: Coverage Report | |
uses: LouisBrunner/[email protected] | |
if: always() | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: DotNET Coverage (${{ matrix.version }}) | |
conclusion: success | |
output: '{"summary":"${{ steps.coverage.outputs.coverage_badge }}"}' | |
output_text_description_file: coverage/SummaryGithub.md | |
- name: Coverage PR Comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: github.event_name == 'pull_request' | |
with: | |
recreate: true | |
path: coverage/SummaryGithub.md | |
- name: Upload Tests artifact | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: tests-${{ matrix.version }} | |
path: "**/TestResults-${{ matrix.version }}.trx" | |
- name: Upload Coverage artifact | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: coverage-${{ matrix.version }} | |
path: coverage/ | |
- name: Upload Pages artifact | |
if: matrix.version == 9.0 | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: test/Html | |
# Deployment job | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: tests | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |