Debian Codegraph @

.github/workflows/benchmark-report.yml

raw
1 name: Benchmark report
2 # Measures the JSON libraries of Go doing the same work ( benchmarks/report_test.go ) on amd64 and arm64, and
3 # publishes the results to GitHub Pages: the page, the SVG summary which the README shows, and the result files,
4 # which are attested so that anyone can verify where they come from ( gh attestation verify ).
5 #
6 # The results are measured again when what is measured changes, which reaches master by a push: go-json, the
7 # versions of the other libraries ( benchmarks/go.mod ), or the report itself. A run without such a change would
8 # measure the same code again, and differ only by the machine it got. A run can also be started by hand, as after
9 # a release of Go. A pull request which changes the report only checks that it runs and renders, with a short
10 # measurement, and publishes nothing.
11 on:
12 push:
13 branches:
14 - master
15 paths-ignore:
16 - '**.md'
17 - 'LICENSE'
18 - 'benchmarks/licenses/**'
19 - '.github/FUNDING.yml'
20 pull_request:
21 paths:
22 - 'benchmarks/**'
23 - '.github/workflows/benchmark-report.yml'
24 workflow_dispatch:
25
26 permissions:
27 contents: read
28
29 concurrency:
30 group: benchmark-report-${{ github.ref }}
31 cancel-in-progress: true
32
33 jobs:
34 measure:
35 name: Measure (${{ matrix.arch }})
36 strategy:
37 fail-fast: false
38 matrix:
39 include:
40 - arch: amd64
41 runner: ubuntu-latest
42 - arch: arm64
43 runner: ubuntu-24.04-arm
44 runs-on: ${{ matrix.runner }}
45 steps:
46 - uses: actions/checkout@v7
47 - uses: actions/setup-go@v7
48 with:
49 go-version: '1.27'
50 cache-dependency-path: |
51 go.sum
52 benchmarks/go.sum
53 - name: measure
54 env:
55 BENCH_REPORT_OUT: ${{ github.workspace }}/results-${{ matrix.arch }}.json
56 # a pull request only checks that the report runs
57 BENCH_REPORT_ROUNDS: ${{ github.event_name == 'pull_request' && '1' || '3' }}
58 BENCH_TIME: ${{ github.event_name == 'pull_request' && '5ms' || '100ms' }}
59 run: |
60 export BENCH_CPU="$(lscpu | sed -n 's/^Model name: *//p' | head -1)"
61 echo "CPU: $BENCH_CPU"
62 cd benchmarks
63 go test -run '^TestReport$' -count=1 -timeout 60m -test.benchtime="$BENCH_TIME" .
64 - uses: actions/upload-artifact@v7
65 with:
66 name: results-${{ matrix.arch }}
67 path: results-${{ matrix.arch }}.json
68 if-no-files-found: error
69
70 render:
71 name: Render
72 needs: measure
73 runs-on: ubuntu-latest
74 steps:
75 - uses: actions/checkout@v7
76 - uses: actions/setup-go@v7
77 with:
78 go-version: '1.27'
79 cache-dependency-path: |
80 go.sum
81 benchmarks/go.sum
82 - uses: actions/download-artifact@v8
83 with:
84 pattern: results-*
85 merge-multiple: true
86 - name: render
87 run: |
88 cd benchmarks
89 go run ./cmd/benchreport -out ../site -attestations "https://github.com/${{ github.repository }}/attestations" ../results-amd64.json ../results-arm64.json
90 - uses: actions/upload-artifact@v7
91 with:
92 name: site
93 path: site
94 if-no-files-found: error
95
96 deploy:
97 name: Attest and deploy
98 if: github.event_name != 'pull_request'
99 needs: render
100 runs-on: ubuntu-latest
101 permissions:
102 contents: read
103 id-token: write
104 attestations: write
105 pages: write
106 environment:
107 name: github-pages
108 url: ${{ steps.deployment.outputs.page_url }}
109 steps:
110 - uses: actions/download-artifact@v8
111 with:
112 name: site
113 path: site
114 - uses: actions/attest-build-provenance@v4
115 with:
116 subject-path: |
117 site/results-*.json
118 site/index.html
119 site/summary.svg
120 - uses: actions/configure-pages@v6
121 - uses: actions/upload-pages-artifact@v5
122 with:
123 path: site
124 - id: deployment
125 uses: actions/deploy-pages@v5