-
-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (112 loc) · 3.66 KB
/
Copy pathbenchmark.yml
File metadata and controls
123 lines (112 loc) · 3.66 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
name: Benchmark
on:
# Runs only on demand or on a schedule so CI minutes aren't burned on every push.
schedule:
- cron: "0 3 * * 1" # weekly (Mon 03:00 UTC)
workflow_dispatch:
inputs:
benchtime:
description: Duration per benchmark (go -benchtime)
required: false
default: "1s"
count:
description: Number of runs per benchmark (go -count); median of runs is reported
required: false
default: "3"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
BENCHTIME: ${{ inputs.benchtime || '1s' }}
BENCH_COUNT: ${{ inputs.count || '3' }}
jobs:
benchmark:
name: Benchmark (${{ matrix.db }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
db: [sqlite, postgres]
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: bench
POSTGRES_INITDB_ARGS: --nosync
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--tmpfs /var/lib/postgresql/data:rw,noatime,size=1024m
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: benchmark/go.mod
cache-dependency-path: benchmark/go.sum
- name: Build Phi CLI
run: go build -o bin/phi
- name: Run Benchmark (${{ matrix.db }})
run: |
cd benchmark
if [ "${{ matrix.db }}" = "postgres" ]; then
make bench/pg
else
make bench/sqlite
fi
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/bench?sslmode=disable
DATABASE_DIRECT_URL: postgres://postgres:postgres@localhost:5432/bench?sslmode=disable
SKIP_DB_RESET: true
- name: Upload Benchmark Artifact
uses: actions/upload-artifact@v4
with:
name: bench-${{ matrix.db }}-${{ github.sha }}
path: benchmark/benchmarks.json
save-benchmarks:
name: Save Benchmark JSON
needs: benchmark
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Download SQLite Artifact
uses: actions/download-artifact@v4
with:
name: bench-sqlite-${{ github.sha }}
path: ./artifacts/sqlite
- name: Download Postgres Artifact
uses: actions/download-artifact@v4
with:
name: bench-postgres-${{ github.sha }}
path: ./artifacts/postgres
- name: Merge and Commit benchmarks.json
run: |
node benchmark/mergeBenchmarks.js
if [ -n "$(git status --porcelain benchmark/benchmarks.json)" ]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add benchmark/benchmarks.json
git commit -m "chore(benchmark): update benchmark results [skip ci]"
git push
else
echo "No benchmark results changed."
fi
- name: Trigger Website Benchmark Revalidation
run: |
SECRET="${{ secrets.REVALIDATE_SECRET }}"
if [ -z "$SECRET" ]; then
SECRET="someSecret"
fi
echo "Triggering Vercel cache revalidation..."
curl -s "https://phi-orm.vercel.app/api/revalidate-benchmarks?secret=$SECRET"
echo ""
echo "Website benchmark cache revalidated!"