Skip to content

Migrate to Codecov test analytics #35

Migrate to Codecov test analytics

Migrate to Codecov test analytics #35

Workflow file for this run

# SPDX-FileCopyrightText: 2024 Frans van Dorsselaer
#
# SPDX-License-Identifier: MIT
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
issues: read
checks: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Cache
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}
- name: Install dependencies
run: |
dotnet tool restore
dotnet restore
- name: Build
run: |
dotnet build --configuration Release --no-restore GitVersion.MsBuild -p:Bootstrap=true
dotnet build --configuration Release --no-restore
- name: Test
run: |
dotnet run --configuration Release --no-build --project Example
dotnet test --configuration Release --no-build \
-p:TestingPlatformCommandLineArguments="--report-trx --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml"
- name: Package
run: dotnet pack --configuration Release --no-build
- name: Upload Package Artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: |
**/*.nupkg
**/*.snupkg
retention-days: 14
- name: Convert test results
if: ${{ !cancelled() }}
run: |
find . -name "*.trx" -exec dotnet tool run trx2junit --output TestResults/JUnit {} +
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true
files: TestResults/JUnit/*.xml
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}