-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (72 loc) · 2.6 KB
/
Copy pathbenchmark.yml
File metadata and controls
81 lines (72 loc) · 2.6 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
name: Benchmark
on:
push:
branches: [main]
workflow_call:
permissions:
contents: write
pull-requests: write
jobs:
benchmark:
name: Run Benchmarks
runs-on: ubuntu-latest
outputs:
has_benchmarks: ${{ steps.check_results.outputs.has_benchmarks }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
- name: Run benchmarks
run: |
go test -bench=. -benchmem -benchtime=100ms -timeout=5m -run=^$ \
./pkg/catalog/... \
./pkg/ui/profiles/... \
./pkg/workspace/... \
./internal/preferences/... | tee benchmark.txt || true
- name: Check if benchmark results exist
id: check_results
run: |
if grep -q "Benchmark" benchmark.txt; then
echo "has_benchmarks=true" >> $GITHUB_OUTPUT
SIZE=$(ls -lh benchmark.txt | awk '{print $5}')
echo "📊 Benchmark results found (Size: $SIZE)."
else
echo "has_benchmarks=false" >> $GITHUB_OUTPUT
echo "No benchmarks found in the codebase."
fi
- name: Create gh-pages branch if it does not exist
if: steps.check_results.outputs.has_benchmarks == 'true'
run: |
if ! git ls-remote --exit-code --heads origin gh-pages; then
CURRENT_SHA=$(git rev-parse HEAD)
git checkout --orphan gh-pages
git rm -rf .
git commit --allow-empty -m "Initial gh-pages commit"
git push origin gh-pages
git checkout $CURRENT_SHA
fi
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1.20.3
if: steps.check_results.outputs.has_benchmarks == 'true' && ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_call')
with:
name: Go Benchmark
tool: "go"
output-file-path: benchmark.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
fail-on-alert: false
- name: Compare benchmark results (PR)
uses: benchmark-action/github-action-benchmark@v1.20.3
if: steps.check_results.outputs.has_benchmarks == 'true' && github.event_name == 'pull_request'
continue-on-error: true
with:
name: Go Benchmark
tool: "go"
output-file-path: benchmark.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: false
comment-always: true
fail-on-alert: false