-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (126 loc) · 4.17 KB
/
Copy pathci.yml
File metadata and controls
144 lines (126 loc) · 4.17 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
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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
disassembly:
description: 'Enable DisassemblyDiagnoser for benchmarks'
required: false
default: 'false'
type: boolean
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- name: Build
run: dotnet build -c Release -bl:build.binlog
- name: Pack
run: dotnet pack -c Release --no-build
- name: Verify NuGet package
run: >
dotnet run --project samples/SortingNetworks.Sample
-p:RestoreAdditionalProjectSources=$(pwd)/SortingNetworks/bin/Release
- name: Upload artifacts
uses: actions/upload-artifact@v7
if: always()
with:
name: packages
path: |
**/*.nupkg
**/*.binlog
test-and-benchmark:
name: test & benchmark (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v6
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- name: Test
run: dotnet test -c Release
- name: Benchmarks
shell: bash
env:
DISASSEMBLY_DIAGNOSER: ${{ inputs.disassembly && '1' || '0' }}
run: |
dotnet run --project SortingNetworks.Benchmarks -c Release -- --filter '*' --exporters GitHub
for f in BenchmarkDotNet.Artifacts/results/*-report-github.md; do
name=$(basename "$f" -report-github.md)
name=${name##*.}
name=${name%SortingBenchmarks}
echo "## $name" >> benchmark-summary.md
echo "" >> benchmark-summary.md
echo "> **ArraySort** = BCL baseline \`Array.Sort\`, **GeneratedSort** = this library" >> benchmark-summary.md
echo "" >> benchmark-summary.md
cat "$f" >> benchmark-summary.md
echo "" >> benchmark-summary.md
done
if [ "$DISASSEMBLY_DIAGNOSER" = "1" ]; then
for f in BenchmarkDotNet.Artifacts/results/*-asm.md; do
[ -f "$f" ] || continue
name=$(basename "$f" -asm.md)
name=${name##*.}
echo "# Disassembly: $name" >> disassembly-summary.md
echo "" >> disassembly-summary.md
cat "$f" >> disassembly-summary.md
echo "" >> disassembly-summary.md
done
fi
- name: Upload benchmark summary
uses: actions/upload-artifact@v7
if: always()
with:
name: benchmark-summary-${{ matrix.os }}
path: benchmark-summary.md
if-no-files-found: ignore
- name: Upload disassembly
uses: actions/upload-artifact@v7
if: inputs.disassembly
with:
name: disassembly-${{ matrix.os }}
path: |
disassembly-summary.md
BenchmarkDotNet.Artifacts/results/*-asm.md
if-no-files-found: ignore
summarize:
needs: [test-and-benchmark]
runs-on: ubuntu-latest
if: always()
steps:
- name: Download all benchmark summaries
uses: actions/download-artifact@v7
with:
pattern: benchmark-summary-*
- name: Merge summaries
shell: bash
run: |
shopt -s nullglob
dirs=(benchmark-summary-*/)
if [ ${#dirs[@]} -eq 0 ]; then
echo "No benchmark summary artifacts found." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
for dir in "${dirs[@]}"; do
if [ ! -f "${dir}/benchmark-summary.md" ]; then
continue
fi
os="${dir#benchmark-summary-}"
os="${os%/}"
echo "# ${os}" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
cat "${dir}/benchmark-summary.md" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
done