Skip to content

Commit 275781a

Browse files
committed
fix(ci): reduce resources for common CI on PRs
1 parent dcf4bc3 commit 275781a

File tree

2 files changed

+63
-115
lines changed

2 files changed

+63
-115
lines changed

.github/workflows/benchmark.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Benchmark
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
benchmark:
13+
name: Run Benchmarks
14+
runs-on: ubuntu-latest-8-cores
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup Rust toolchain
21+
uses: actions-rust-lang/setup-rust-toolchain@v1
22+
with:
23+
cache-on-failure: true
24+
25+
- name: Install protoc
26+
uses: arduino/setup-protoc@v2
27+
with:
28+
version: "25.x"
29+
repo-token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Restore previous benchmark baseline
32+
id: cache-baseline
33+
uses: actions/cache@v4
34+
with:
35+
path: scripts/perf/baselines
36+
key: benchmark-baseline-main-${{ github.sha }}
37+
restore-keys: |
38+
benchmark-baseline-main-
39+
40+
- name: Run benchmarks and create baseline
41+
run: ./scripts/perf/run_baseline.sh
42+
43+
- name: Compare against previous baseline
44+
if: steps.cache-baseline.outputs.cache-hit == 'true'
45+
continue-on-error: true
46+
run: |
47+
echo "📊 Comparing against previous baseline..."
48+
./scripts/perf/compare_to_baseline.sh || true
49+
50+
- name: Save new baseline
51+
uses: actions/cache/save@v4
52+
with:
53+
path: scripts/perf/baselines
54+
key: benchmark-baseline-main-${{ github.sha }}
55+
56+
- name: Upload benchmark results
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: benchmark-results-${{ github.sha }}
60+
path: scripts/perf/baselines/
61+
retention-days: 90

.github/workflows/ci.yml

Lines changed: 2 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
jobs:
1717
format-and-lint:
1818
name: Format & Lint
19-
runs-on: ubuntu-latest-4-cores
19+
runs-on: ubuntu-latest
2020
steps:
2121
- uses: actions/checkout@v4
2222

@@ -39,7 +39,7 @@ jobs:
3939

4040
test:
4141
name: Test
42-
runs-on: ubuntu-latest-4-cores
42+
runs-on: ubuntu-latest
4343
steps:
4444
- uses: actions/checkout@v4
4545

@@ -59,116 +59,3 @@ jobs:
5959

6060
- name: Build examples
6161
run: cargo build --examples
62-
63-
benchmark-regression:
64-
name: Benchmark Regression Check
65-
runs-on: ubuntu-latest-8-cores
66-
permissions:
67-
pull-requests: write
68-
steps:
69-
- uses: actions/checkout@v4
70-
with:
71-
fetch-depth: 0
72-
73-
- name: Setup Rust toolchain
74-
uses: actions-rust-lang/setup-rust-toolchain@v1
75-
with:
76-
cache-on-failure: true
77-
78-
- name: Install protoc
79-
uses: arduino/setup-protoc@v2
80-
with:
81-
version: "25.x"
82-
repo-token: ${{ secrets.GITHUB_TOKEN }}
83-
84-
- name: Restore benchmark baseline
85-
id: cache-baseline
86-
uses: actions/cache@v4
87-
with:
88-
path: scripts/perf/baselines
89-
key: benchmark-baseline-${{ github.base_ref || 'main' }}-${{ github.sha }}
90-
restore-keys: |
91-
benchmark-baseline-${{ github.base_ref || 'main' }}-
92-
93-
- name: Run benchmark regression check
94-
if: github.event_name == 'pull_request' && steps.cache-baseline.outputs.cache-hit == 'true'
95-
id: regression-check
96-
continue-on-error: true
97-
run: |
98-
set -o pipefail
99-
./scripts/perf/compare_to_baseline.sh | tee benchmark-results.txt
100-
echo "EXIT_CODE=${PIPESTATUS[0]}" >> $GITHUB_OUTPUT
101-
102-
- name: Post regression results to PR
103-
if: github.event_name == 'pull_request' && steps.cache-baseline.outputs.cache-hit == 'true'
104-
uses: actions/github-script@v7
105-
with:
106-
script: |
107-
const fs = require('fs');
108-
let resultsText = '';
109-
try {
110-
resultsText = fs.readFileSync('benchmark-results.txt', 'utf8');
111-
} catch (e) {
112-
resultsText = 'Failed to read benchmark results';
113-
}
114-
115-
const hasRegressions = '${{ steps.regression-check.outputs.EXIT_CODE }}' !== '0';
116-
const status = hasRegressions ? '❌ **Benchmark Regression Detected**' : '✅ **No Benchmark Regressions**';
117-
118-
const body = `## ${status}
119-
120-
<details>
121-
<summary>Benchmark Comparison Results</summary>
122-
123-
\`\`\`
124-
${resultsText}
125-
\`\`\`
126-
127-
</details>
128-
129-
${hasRegressions ? '\n⚠️ **This PR contains performance regressions >10% and cannot be merged.**\n\nPlease optimize the code or update the baseline if this regression is intentional.' : ''}
130-
`;
131-
132-
const { data: comments } = await github.rest.issues.listComments({
133-
owner: context.repo.owner,
134-
repo: context.repo.repo,
135-
issue_number: context.issue.number,
136-
});
137-
138-
const botComment = comments.find(comment =>
139-
comment.user.type === 'Bot' &&
140-
comment.body.includes('Benchmark')
141-
);
142-
143-
if (botComment) {
144-
await github.rest.issues.updateComment({
145-
owner: context.repo.owner,
146-
repo: context.repo.repo,
147-
comment_id: botComment.id,
148-
body: body
149-
});
150-
} else {
151-
await github.rest.issues.createComment({
152-
owner: context.repo.owner,
153-
repo: context.repo.repo,
154-
issue_number: context.issue.number,
155-
body: body
156-
});
157-
}
158-
159-
- name: Fail if regressions detected
160-
if: github.event_name == 'pull_request' && steps.regression-check.outputs.EXIT_CODE != '0'
161-
run: |
162-
echo "❌ Benchmark regressions detected (>10% threshold)"
163-
exit 1
164-
165-
- name: Update baseline on main branch
166-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
167-
run: ./scripts/perf/run_baseline.sh
168-
169-
- name: Save new baseline
170-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
171-
uses: actions/cache/save@v4
172-
with:
173-
path: scripts/perf/baselines
174-
key: benchmark-baseline-main-${{ github.sha }}

0 commit comments

Comments
 (0)