-
Notifications
You must be signed in to change notification settings - Fork 3
212 lines (178 loc) · 5.55 KB
/
build.yml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: 'Build and publish'
on:
push:
branches:
- develop
- main
- 'release/**'
- 'feature/**'
- 'hotfix/**'
paths-ignore:
- 'README.md'
- 'docs/*'
- 'scripts/*'
- '.vscode/*'
permissions:
checks: write
contents: write
pull-requests: write
actions: read
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
NUGET_CERT_REVOCATION_MODE: offline
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
jobs:
net-test:
name: .NET tests
strategy:
matrix:
os: [
ubuntu-latest,
windows-latest,
macos-latest
]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Cache NuGet packages on Windows
uses: actions/cache@v3
if: matrix.os == 'windows-latest'
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.Build.props') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Install .NET 8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0
dotnet-quality: ga
- name: Restore NuGet packages
run: dotnet restore --verbosity minimal
- name: Run .NET tests
run: dotnet test --configuration Release
- name: Upload test results
uses: actions/upload-artifact@v3
if: matrix.os == 'ubuntu-latest'
with:
name: net-test-results
path: |
./**/*.trx
./**/coverage.*.cobertura.xml
test-and-coverage-results:
name: Publish test and coverage results
runs-on: ubuntu-latest
needs: [ net-test ]
steps:
# While we don't use sources directly in this job the test reporter wants to check
# some files through git so we need the sources.
- name: Checkout sources
uses: actions/checkout@v4
- name: Download .NET tests results
uses: actions/download-artifact@v3
with:
name: net-test-results
path: ./
- name: Publish .NET tests
uses: dorny/test-reporter@v1
with:
name: 🧪 .NET test results
path: ./**/*.trx
reporter: dotnet-trx
- name: Create history folder
run: mkdir ./coverage-history
working-directory: ./
- name: Download historial coverage
uses: dawidd6/[email protected]
with:
# Optional, GitHub token, a Personal Access Token with `public_repo` scope if needed
# Required, if the artifact is from a different repo
# Required, if the repo is private a Personal Access Token with `repo` scope is needed
# github_token: ${{secrets.GITHUB_TOKEN}}
workflow_conclusion: success
branch: ${{ github.head_ref }}
name: coverage-history
path: ./coverage-history
check_artifacts: true
search_artifacts: true
if_no_artifact_found: ignore
- name: Install .NET 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Generate coverage report
uses: danielpalme/ReportGenerator-GitHub-Action@5
with:
reports: '../**/{coverage.*.cobertura,cobertura-coverage}.xml'
targetdir: 'coverage-report'
historydir: 'coverage-history'
reporttypes: 'Html;MarkdownSummary;MarkdownDeltaSummary;Cobertura'
assemblyfilters: '-xunit*'
verbosity: 'Info'
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: coverage-report
- name: Upload to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage-report/Cobertura.xml
- name: Upload coverage history
uses: actions/upload-artifact@v3
with:
name: coverage-history
path: coverage-history
- name: Publish code coverage summary to run
uses: LouisBrunner/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
name: 📝 Code coverage
output: "{\"summary\":\"Summary of code coverage. For more detailed information, download the full artifact from the run.\"}"
output_text_description_file: ./coverage-report/Summary.md
net-build:
name: .NET build
runs-on: ubuntu-latest
needs: [ net-test ]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install .NET 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore NuGet packages
run: dotnet restore --verbosity minimal
- name: Pack project
run: dotnet pack ./src/RobotsTxt/RobotsTxt.csproj --configuration Release --output artifacts
- name: Upload packages
uses: actions/upload-artifact@v3
with:
name: packages
path: artifacts/*.nupkg
publish:
name: NuGet Publish
needs: net-build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Download artiifacts
uses: actions/download-artifact@v3
with:
name: packages
path: ./artifacts/
- name: Install .NET 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Publish package to NuGet.org
env:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
run: dotnet nuget push artifacts/*.nupkg --api-key $NUGET_KEY --source https://api.nuget.org/v3/index.json
working-directory: ./