-
-
Notifications
You must be signed in to change notification settings - Fork 7
182 lines (174 loc) · 5.74 KB
/
ci.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
name: CI
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
paths:
- '.github/**'
- 'src/**'
- build.cake
- CodeCoverage.runsettings
- dotnet-tools.json
- global.json
- Key.snk
- Paseto.sln
pull_request:
branches:
- master
paths:
- 'src/**'
- build.cake
- CodeCoverage.runsettings
- dotnet-tools.json
- global.json
- Key.snk
- Paseto.sln
release:
types:
- published
env:
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true
# Set the DOTNET_SKIP_FIRST_TIME_EXPERIENCE environment variable to stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true
# Set the build number in MinVer
MINVERBUILDMETADATA: build.${{github.run_number}}
# Set artifacts directory
BUILD_ARTIFACT_PATH: './Artifacts'
jobs:
build:
name: Build on ${{matrix.os}} # with .NET ${{ matrix.dotnet }}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
#dotnet: [ '6.0.x', '8.0.x' ]
steps:
- name: 'Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
#filter: tree:0
- name: 'Install .NET SDK'
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
#dotnet-version: ${{ matrix.dotnet }}
- name: '.NET Restore'
run: dotnet tool restore
- name: 'Build Project'
run: dotnet cake --target=Build
- name: 'Run Unit Tests'
run: dotnet cake --target=Test
- name: 'Run Unit Tests'
run: dotnet test -f net8.0 --no-restore --logger trx -r ${{env.BUILD_ARTIFACT_PATH}} --settings "CodeCoverage.runsettings"
if: ${{ false }} # always skip since coverage is somehow always empty in GitHub Actions
- name: 'Run Test Report'
uses: zyborg/dotnet-tests-report@v1
with:
project_path: tests/Paseto.Tests
report_name: paseto_dotnet_tests
report_title: Paseto.NET Tests
github_token: ${{ secrets.GITHUB_TOKEN }}
gist_name: paseto_dotnet_tests.md
gist_badge_label: 'Paseto Tests: %Counters_passed%/%Counters_total%'
gist_token: ${{ secrets.GIST_TOKEN }}
if: ${{ false }} # always skip due to 65K limit
- name: 'Pack NuGet'
run: dotnet cake --target=Pack
- name: 'Publish Artifacts'
uses: actions/upload-artifact@v4
with:
name: ${{matrix.os}}
path: |
${{env.BUILD_ARTIFACT_PATH}}
!${{env.BUILD_ARTIFACT_PATH}}/**/In/**/*
coverage:
name: 'Process Coverage'
runs-on: ubuntu-latest
needs: build
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Download Artifact'
uses: actions/download-artifact@v4
with:
name: 'ubuntu-latest'
- name: 'Install ReportGenerator'
run: dotnet tool install -g dotnet-reportgenerator-globaltool
- name: 'Generate Coverage Report'
run: reportgenerator -reports:./TestResults/**/coverage.cobertura.xml -targetdir:${{env.BUILD_ARTIFACT_PATH}}/TestResults/Coverage/Reports "-reporttypes:HtmlInline;HTMLChart;Cobertura"
- name: 'Upload Coverage'
uses: codecov/codecov-action@v4
with:
file: Cobertura.xml
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- name: 'Publish Coverage Report'
uses: actions/upload-artifact@v4
with:
name: 'coverage-report'
path: ${{env.BUILD_ARTIFACT_PATH}}
benchmark:
name: 'Execute Benchmarks'
runs-on: ubuntu-latest
needs: coverage
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Run Benchmarks'
run: cd benchmarks/Paseto.Benchmark && dotnet run -f net8.0 -c Release --exporters json --filter '*'
- name: 'Store Benchmark Result'
uses: rhysd/github-action-benchmark@v1
with:
name: Benchmark.Net Benchmark
tool: 'benchmarkdotnet'
output-file-path: benchmarks/Paseto.Benchmark/BenchmarkDotNet.Artifacts/results/Benchmarks-report-full-compressed.json
auto-push: false
if: ${{ false }} # always skip for now
- name: 'Push Benchmark Result'
run: git push 'https://daviddesmet:${{ secrets.GITHUB_TOKEN }}@github.com/daviddesmet/paseto-dotnet.git' gh-pages:gh-pages
if: ${{ false }} # always skip for now
push-to-github-packages:
name: 'Push GitHub Packages'
needs: build
if: github.ref == 'refs/heads/master' || github.event_name == 'release'
environment:
name: 'GitHub Packages'
url: https://github.com/daviddesmet/paseto-dotnet/packages
permissions:
packages: write
runs-on: windows-latest
steps:
- name: 'Download Artifact'
uses: actions/download-artifact@v4
with:
name: 'windows-latest'
- name: 'NuGet Push'
run: dotnet nuget push *.nupkg --source https://nuget.pkg.github.com/daviddesmet/index.json --skip-duplicate --api-key ${{secrets.GITHUB_TOKEN}}
push-to-nuget:
name: 'Push NuGet Packages'
needs: build
if: github.event_name == 'release'
environment:
name: 'NuGet'
url: https://www.nuget.org/packages/Paseto.Core
runs-on: windows-latest
steps:
- name: 'Download Artifact'
uses: actions/download-artifact@v4
with:
name: 'windows-latest'
- name: 'NuGet Push'
run: |
Get-ChildItem . -Filter *.nupkg |
Where-Object { !$_.Name.Contains('preview') } |
ForEach-Object { dotnet nuget push $_ --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} }
shell: pwsh