generated from devantler/dotnet-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (46 loc) · 1.76 KB
/
test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Test
on:
pull_request:
# Added 'edited' temporarily, as there currently is no trigger for when the base branch is updated.
# https://github.com/orgs/community/discussions/64119
types: [opened, synchronize, reopened, ready_for_review, closed, edited]
branches: main
push:
branches: main
workflow_dispatch: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
if: github.event.pull_request.draft == false
steps:
- name: 📑 Checkout
uses: actions/checkout@v4
- name: ⚙️ Setup .NET
uses: actions/setup-dotnet@v4
- name: 🧪 Test
run: dotnet test --collect:"XPlat Code Coverage"
- name: 📄 Get Coverage Files
id: get_coverage_files
if: matrix.os != 'windows-latest'
run: |
coverage_files=$(find . -name 'coverage.cobertura.xml' -print0 | tr '\0' ',' | sed 's/,$//')
echo "COVERAGE_FILES=$coverage_files" >> "$GITHUB_OUTPUT"
- name: 📄 Get Coverage Files on Windows
id: get_coverage_files_windows
if: matrix.os == 'windows-latest'
run: |
$coverage_files = Get-ChildItem -Path . -Recurse -Filter coverage.cobertura.xml -ErrorAction SilentlyContinue | ForEach-Object { $_.FullName }
$coverage_files = $coverage_files -join ','
echo "COVERAGE_FILES=$coverage_files" >> "$GITHUB_OUTPUT"
- name: 📄 Upload Code Coverage to CodeCov
uses: codecov/codecov-action@v4
with:
files: ${{ steps.get_coverage_files.outputs.COVERAGE_FILES }}
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}