|
| 1 | +name: Benchmark Logs |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +permissions: |
| 8 | + actions: write |
| 9 | + contents: write |
| 10 | + pages: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + bench: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - uses: actions/setup-go@v5 |
| 19 | + with: |
| 20 | + go-version-file: go.mod |
| 21 | + |
| 22 | + - name: Fetch existing merged.json from bench-data |
| 23 | + run: | |
| 24 | + git init /tmp/bench-data |
| 25 | + cd /tmp/bench-data |
| 26 | + git remote add origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" |
| 27 | + git fetch origin bench-data 2>/dev/null || true |
| 28 | + if git rev-parse origin/bench-data &>/dev/null; then |
| 29 | + git checkout bench-data |
| 30 | + cp merged.json "${{ github.workspace }}/prev-merged.json" |
| 31 | + fi |
| 32 | +
|
| 33 | + - name: Run benchmark and merge |
| 34 | + uses: goptics/vizb@v0 |
| 35 | + with: |
| 36 | + bench-cmd: "go test -bench=. -benchmem -cpu=1" |
| 37 | + tag: ${{ github.ref_name }} |
| 38 | + merge-dir: prev-merged.json |
| 39 | + group-pattern: n/y |
| 40 | + name: "VarMQ Benchmark Log" |
| 41 | + scale: log |
| 42 | + tag-axis: x |
| 43 | + output-json: merged.json |
| 44 | + output-html: pages/bench-log/index.html |
| 45 | + |
| 46 | + - name: Push merged.json to orphan bench-data branch |
| 47 | + run: | |
| 48 | + cd /tmp/bench-data |
| 49 | + if [ ! -f merged.json ] || ! git rev-parse --verify bench-data &>/dev/null; then |
| 50 | + git checkout --orphan bench-data |
| 51 | + git rm -rf . || true |
| 52 | + fi |
| 53 | + cp "${{ github.workspace }}/merged.json" . |
| 54 | + git add merged.json |
| 55 | + git config user.name "github-actions[bot]" |
| 56 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 57 | + git diff --cached --quiet || git commit -m "update benchmark data [${{ github.ref_name }}]" |
| 58 | + git push origin bench-data |
| 59 | +
|
| 60 | + - name: Deploy index.html to GitHub Pages |
| 61 | + uses: peaceiris/actions-gh-pages@v4 |
| 62 | + with: |
| 63 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + publish_dir: pages |
| 65 | + publish_branch: gh-pages |
0 commit comments