Repository navigation
140 lines (132 loc) · 5.04 KB
/
Copy pathbenchmark-react.yml
File metadata and controls
140 lines (132 loc) · 5.04 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Benchmark React
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- master
paths:
- 'packages/react/src/**'
- 'packages/core/src/**'
- 'packages/endpoint/src/schemas/**'
- 'packages/normalizr/src/**'
- 'examples/benchmark-react/**'
- '!packages/**/__tests__/**'
- '!examples/benchmark-react/**/*.md'
- 'yarn.lock'
- 'scripts/ci-deps-relevant.mjs'
- '.github/workflows/dependency-gate.yml'
- '.github/workflows/benchmark-react.yml'
push:
branches:
- master
paths:
- 'packages/react/src/**'
- 'packages/core/src/**'
- 'packages/endpoint/src/schemas/**'
- 'packages/normalizr/src/**'
- 'examples/benchmark-react/**'
- '!packages/**/__tests__/**'
- '!examples/benchmark-react/**/*.md'
- 'yarn.lock'
- 'scripts/ci-deps-relevant.mjs'
- '.github/workflows/dependency-gate.yml'
- '.github/workflows/benchmark-react.yml'
concurrency:
group: ${{ github.event_name == 'push' && 'gh-pages-bench-react-push' || format('benchmark-react-{0}', github.head_ref) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
# Master pushes queue every run (a cancelled one marks master red); PRs keep one
queue: ${{ github.event_name == 'push' && 'max' || 'single' }}
permissions:
contents: read
jobs:
# Skips dependency bumps that can't change what this measures
changes:
if: ${{ !github.event.pull_request.draft }}
uses: ./.github/workflows/dependency-gate.yml
with:
workspaces: examples/benchmark-react
benchmark-react:
needs: changes
if: ${{ needs.changes.outputs.relevant == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write # master pushes results to gh-pages-bench
pull-requests: write # PR result review
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 1
# PR code runs here; the benchmark action passes its own token to git
persist-credentials: false
- uses: actions/setup-node@v7
with:
node-version: '26'
cache: 'yarn'
- name: Install packages
run: ./scripts/ci-install.sh examples/benchmark-react
- name: Get Playwright version
id: playwright-version
run: |
echo "version=$(node -p "require(require.resolve('playwright/package.json', { paths: ['examples/benchmark-react'] })).version")" >> "$GITHUB_OUTPUT"
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v6
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
- name: Install Playwright (Chromium + system deps)
# System deps can't live in the cache, so install them either way.
run: |
if [ "${{ steps.playwright-cache.outputs.cache-hit }}" = "true" ]; then
npx playwright install-deps chromium
else
npx playwright install chromium --with-deps
fi
- name: Build packages
run: yarn build:benchmark-react
- name: Tune system for benchmarking
run: |
# Pin CPU governor to performance mode (reduces frequency scaling jitter)
for gov in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
echo performance | sudo tee "$gov" 2>/dev/null || true
done
# Disable swap to prevent memory pressure variance
sudo swapoff -a || true
- name: Run benchmark
run: |
yarn workspace example-benchmark-react preview &
for i in $(seq 1 30); do
curl -sf http://localhost:5173/ > /dev/null && break
sleep 1
done
cd examples/benchmark-react && taskset -c 0,1 yarn bench | tee react-bench-output.json
# PR comments on changes
- name: Store benchmark result (PR)
if: ${{ github.event_name == 'pull_request' }}
uses: rhysd/github-action-benchmark@v1
with:
name: 'Benchmark React'
tool: 'customBiggerIsBetter'
output-file-path: examples/benchmark-react/react-bench-output.json
github-token: "${{ secrets.GITHUB_TOKEN }}"
gh-pages-branch: 'gh-pages-bench'
benchmark-data-dir-path: react-bench
alert-threshold: '150%'
comment-always: true
fail-on-alert: false
alert-comment-cc-users: '@ntucker'
save-data-file: false
auto-push: false
# master reports to history
- name: Store benchmark result (main)
if: ${{ github.event_name == 'push' }}
uses: rhysd/github-action-benchmark@v1
with:
name: 'Benchmark React'
tool: 'customBiggerIsBetter'
output-file-path: examples/benchmark-react/react-bench-output.json
github-token: "${{ secrets.GITHUB_TOKEN }}"
gh-pages-branch: 'gh-pages-bench'
benchmark-data-dir-path: react-bench
auto-push: true
fail-on-alert: false