-
Notifications
You must be signed in to change notification settings - Fork 1
202 lines (172 loc) · 6.22 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: ci
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "1 1 * * 1"
permissions:
contents: write
deployments: write
jobs:
bench-go:
defaults:
run:
working-directory: go
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go/go.mod
cache-dependency-path: |
go/go.sum
- name: Bench
run: |
go test -bench=. -benchmem ./... | tee benchmark_result.txt
- name: Continuous Benchmark
uses: benchmark-action/github-action-benchmark@v1.20.3
if: ${{ github.ref == 'refs/heads/main' }}
with:
name: Go Library Benchmark
tool: "go"
output-file-path: go/benchmark_result.txt
github-token: ${{ secrets.CI_TOKEN }}
gh-repository: "github.com/ringsaturn/tz-benchmark"
auto-push: true
alert-threshold: "150%"
comment-on-alert: false
fail-on-alert: false
gh-pages-branch: "gh-pages"
benchmark-data-dir-path: "docs/"
alert-comment-cc-users: "@ringsaturn"
- name: Setup benchmark file name
id: gen-benchmark-file-name
run: |
echo "filename=tz_benchmark_go_${{ matrix.go-version }}.md" >> $GITHUB_OUTPUT
- name: Report
run: |
set +e
echo "## Go ${{ matrix.go-version }}" >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
echo '```' >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
cat benchmark_result.txt >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
echo '```' >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
- run: ls -lah
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: benchmark_go_${{ steps.gen-benchmark-file-name.outputs.filename }}
path: go/${{ steps.gen-benchmark-file-name.outputs.filename }}
if-no-files-found: error
bench-python:
runs-on: ubuntu-latest
defaults:
run:
working-directory: python
env:
COLUMNS: 120
strategy:
matrix:
python-version: ["3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Build
run: |
pip install -r requirements.txt
- name: Setup benchmark file name
id: gen-benchmark-file-name
run: |
echo "filename=tz_benchmark_py_${{ matrix.python-version }}.md" >> $GITHUB_OUTPUT
- name: Bench Python
run: |
# ${{ steps.gen-benchmark-file-name.outputs.filename }}
pytest tz_test.py --benchmark-json output.json | tee benchmark_result.txt
- name: Continuous Benchmark
uses: benchmark-action/github-action-benchmark@v1.20.3
if: ${{ github.ref == 'refs/heads/main' }}
with:
name: Python Library Benchmark
tool: "pytest"
output-file-path: python/output.json
github-token: ${{ secrets.CI_TOKEN }}
gh-repository: "github.com/ringsaturn/tz-benchmark"
auto-push: true
alert-threshold: "150%"
comment-on-alert: false
fail-on-alert: false
gh-pages-branch: "gh-pages"
benchmark-data-dir-path: "docs/"
alert-comment-cc-users: "@ringsaturn"
- name: Report
run: |
set +e
echo "## Python ${{ matrix.python-version }}" >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
echo '```' >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
cat benchmark_result.txt >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
echo '```' >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
- run: ls -lah
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: benchmark_py_${{ steps.gen-benchmark-file-name.outputs.filename }}
path: python/${{ steps.gen-benchmark-file-name.outputs.filename }}
if-no-files-found: error
bench-rust:
defaults:
run:
working-directory: rust
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Setup benchmark file name
id: gen-benchmark-file-name
run: |
echo "filename=tz_benchmark_rust.md" >> $GITHUB_OUTPUT
- name: Run benchmark
run: cargo bench | tee benchmark_result.txt
- name: Continuous Benchmark
uses: benchmark-action/github-action-benchmark@v1.20.3
if: ${{ github.ref == 'refs/heads/main' }}
with:
name: Rust Library Benchmark
tool: "cargo"
output-file-path: rust/benchmark_result.txt
github-token: ${{ secrets.CI_TOKEN }}
gh-repository: "github.com/ringsaturn/tz-benchmark"
auto-push: true
alert-threshold: "150%"
comment-on-alert: false
fail-on-alert: false
gh-pages-branch: "gh-pages"
benchmark-data-dir-path: "docs/"
alert-comment-cc-users: "@ringsaturn"
- name: Report
run: |
set +e
echo "## Rust" >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
echo '```' >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
cat benchmark_result.txt >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
echo '```' >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
- run: ls -lah
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: benchmark_rust_${{ steps.gen-benchmark-file-name.outputs.filename }}
path: rust/${{ steps.gen-benchmark-file-name.outputs.filename }}
if-no-files-found: error
summary:
needs: [bench-go, bench-python, bench-rust]
runs-on: ubuntu-latest
steps:
- name: Download a Build Artifact
uses: actions/download-artifact@v4
with:
pattern: "benchmark_*"
- run: find . -name "*.md" -exec cat {} \; > $GITHUB_STEP_SUMMARY