-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (106 loc) · 3.95 KB
/
Copy pathbenchmark.yaml
File metadata and controls
122 lines (106 loc) · 3.95 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
name: Provider Benchmarks
on:
pull_request:
paths:
- "packages/disco/lib/**"
- "packages/disco/benchmark/**"
- ".github/workflows/benchmark.yaml"
push:
branches:
- main
- dev
paths:
- "packages/disco/lib/**"
- "packages/disco/benchmark/**"
workflow_dispatch:
jobs:
benchmark:
name: Run Provider Benchmarks
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2.18.0
with:
channel: "stable"
cache: true
- name: Install dependencies
run: flutter pub get
working-directory: packages/disco
- name: Run benchmarks (Debug Mode - Worst Case)
working-directory: packages/disco
run: |
# Run benchmark, it will generate benchmark_results.md automatically
flutter test benchmark/provider_benchmark.dart
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: packages/disco/benchmark_results.md
- name: Update README with benchmark results
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev')
run: |
# Read benchmark results
BENCHMARK_CONTENT=$(cat packages/disco/benchmark_results.md)
# Check if README already has a Benchmark section
if grep -q "^## Benchmark" packages/disco/README.md; then
# Remove everything from ## Benchmark to the end
sed -i '/^## Benchmark/,$d' packages/disco/README.md
fi
# Add benchmark section at the end
echo "" >> packages/disco/README.md
echo "## Benchmark" >> packages/disco/README.md
echo "" >> packages/disco/README.md
echo "$BENCHMARK_CONTENT" >> packages/disco/README.md
- name: Commit benchmark results to README
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev')
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add packages/disco/README.md
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "chore: update benchmark results in README [skip ci]"
git push
fi
- name: Comment PR with results
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const results = fs.readFileSync('packages/disco/benchmark_results.md', 'utf8');
// Check if we already commented
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Provider Benchmark Results')
);
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: results
});
} else {
// Create new comment
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: results
});
}
- name: Display results
run: cat packages/disco/benchmark_results.md