-
Notifications
You must be signed in to change notification settings - Fork 18
107 lines (87 loc) · 3.34 KB
/
dotnet-ci.yml
File metadata and controls
107 lines (87 loc) · 3.34 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Building and testing .NET
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
DOTNET_VERSION: 10.0.x
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up .NET ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v5.2.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
# The action searches for packages.lock.json in the repository root,
# calculates their hash, and uses it as a part of the cache key.
cache: true
# Use cache-dependency-path for cases when multiple dependency files
# are used, or they are located in different subdirectories.
cache-dependency-path: |
src/Dotnet.Samples.AspNetCore.WebApi/packages.lock.json
test/Dotnet.Samples.AspNetCore.WebApi.Tests/packages.lock.json
- name: Restore dependencies
run: dotnet restore
- name: Build projects
run: dotnet build --no-restore
test:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up .NET ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v5.2.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
cache: true
cache-dependency-path: |
src/Dotnet.Samples.AspNetCore.WebApi/packages.lock.json
test/Dotnet.Samples.AspNetCore.WebApi.Tests/packages.lock.json
- name: Lint commit messages
uses: wagoid/commitlint-github-action@v6.2.1
- name: Run tests and generate Cobertura coverage reports
run: dotnet test --results-directory "coverage" --collect:"XPlat Code Coverage" --settings .runsettings
- name: Install dotnet-coverage tool
run: dotnet tool install --global dotnet-coverage
- name: Merge Cobertura coverage reports
run: dotnet-coverage merge coverage/**/*.cobertura.xml --output coverage/cobertura.xml --output-format cobertura
- name: Install ReportGenerator tool
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Generate Markdown summary of coverage report
run: reportgenerator -reports:coverage/cobertura.xml -targetdir:coverage -reporttypes:"MarkdownSummaryGithub"
- name: Display Markdown summary of coverage report
run: cat coverage/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
- name: Upload Cobertura coverage report artifact
uses: actions/upload-artifact@v7.0.1
with:
name: cobertura.xml
path: coverage/cobertura.xml
coverage:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Download Cobertura coverage report artifact
uses: actions/download-artifact@v8.0.1
with:
name: cobertura.xml
- name: Upload Cobertura coverage report to Codecov
uses: codecov/codecov-action@v6.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: cobertura.xml
use_oidc: false