-
-
Notifications
You must be signed in to change notification settings - Fork 143
83 lines (79 loc) · 3.05 KB
/
benchmark.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
name: benchmark
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'src/**'
- 'benchmarks/**'
- 'global.json'
- 'Directory.Build.props'
pull_request:
branches:
- main
paths:
- 'src/**'
- 'benchmarks/**'
- 'global.json'
- 'Directory.Build.props'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
BENCHMARKS_PATH: 'benchmarks/Riok.Mapperly.Benchmarks'
BENCHMARK_RESULT_DIR: 'benchmarks/Riok.Mapperly.Benchmarks/artifacts/results'
BENCHMARK_BASELINE_DIR: './benchmark-results'
BENCHMARK_BASELINE_FILE: './benchmark-results/benchmark-baseline-report.json'
jobs:
benchmark:
runs-on: ubuntu-latest
strategy:
matrix:
BENCHMARK_NAME:
- MappingBenchmarks
- SourceGeneratorBenchmarks
name: ${{ matrix.BENCHMARK_NAME }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
- name: Run ${{ matrix.BENCHMARK_NAME }}
working-directory: ${{ env.BENCHMARKS_PATH }}
run: dotnet run --exporters json --configuration Release --filter '*${{ matrix.BENCHMARK_NAME }}*'
- name: Restore baseline results
uses: actions/cache/restore@v3
id: cache-baseline-results-restore
with:
path: ${{ env.BENCHMARK_BASELINE_DIR }}
key: benchmarks-${{ matrix.BENCHMARK_NAME }}
- name: Compare benchmark result
uses: rhysd/github-action-benchmark@v1
with:
name: ${{ matrix.BENCHMARK_NAME }}
tool: benchmarkdotnet
external-data-json-path: ${{ env.BENCHMARK_BASELINE_FILE }}
output-file-path: >-
${{ env.BENCHMARK_RESULT_DIR }}/Riok.Mapperly.Benchmarks.${{ matrix.BENCHMARK_NAME }}-report-full-compressed.json
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
github-token: ${{ secrets.GITHUB_TOKEN }}
# it is not possible to update the cache
# delete it first https://github.com/actions/cache/issues/342
# needs to be done via PAT instead of GITHUB_TOKEN, since it requires additional permissions
# GH_REPO_PAT is only readable on the main branch / for contributors with write permissions
- name: Clear baseline results
if: steps.cache-baseline-results-restore.outputs.cache-hit == 'true' && github.ref == 'refs/heads/main'
env:
GH_TOKEN: ${{ secrets.GH_REPO_PAT }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete '${{ steps.cache-baseline-results-restore.outputs.cache-primary-key }}' --confirm
- name: Store baseline results
id: cache-baseline-results-save
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@v3
with:
path: ${{ env.BENCHMARK_BASELINE_DIR }}
key: ${{ steps.cache-baseline-results-restore.outputs.cache-primary-key }}