-
Notifications
You must be signed in to change notification settings - Fork 3
181 lines (154 loc) · 5.49 KB
/
benchmark.yml
File metadata and controls
181 lines (154 loc) · 5.49 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# name: benchmark
# on:
# schedule:
# # Mondays 06:00 UTC — once a week is plenty.
# - cron: "0 6 * * 1"
# workflow_dispatch:
# inputs:
# slugs:
# description: "Comma-separated slugs to scan (default: all in repos.yaml)"
# required: false
# type: string
# push:
# branches: [main]
# paths:
# - "repos.yaml"
# - "scripts/**"
# - ".github/workflows/benchmark.yml"
# permissions:
# contents: write
# concurrency:
# group: benchmark-${{ github.ref }}
# cancel-in-progress: false
# env:
# PNPM_VERSION: "10.33.3"
# NODE_VERSION: "22"
# # Silence GitHub's Node 20 actions deprecation warning until upstream
# # actions ship v5 majors targeting Node 24.
# FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
# jobs:
# matrix-prep:
# name: prepare matrix
# runs-on: ubuntu-latest
# outputs:
# matrix: ${{ steps.set.outputs.matrix }}
# count: ${{ steps.set.outputs.count }}
# steps:
# - uses: actions/checkout@v4
# - uses: pnpm/action-setup@v4
# with:
# version: ${{ env.PNPM_VERSION }}
# - uses: actions/setup-node@v4
# with:
# node-version: ${{ env.NODE_VERSION }}
# cache: pnpm
# - run: pnpm install --frozen-lockfile
# - id: set
# env:
# INPUT_SLUGS: ${{ github.event.inputs.slugs }}
# run: |
# set -euo pipefail
# MATRIX="$(pnpm -s tsx scripts/matrix.ts)"
# if [ -n "${INPUT_SLUGS:-}" ]; then
# echo "Filtering matrix to: $INPUT_SLUGS"
# MATRIX="$(node -e '
# const m = JSON.parse(process.argv[1]);
# const allow = new Set(process.argv[2].split(",").map(s => s.trim()).filter(Boolean));
# m.include = m.include.filter(e => allow.has(e.slug));
# process.stdout.write(JSON.stringify(m));
# ' "$MATRIX" "$INPUT_SLUGS")"
# fi
# COUNT="$(node -e '
# const m = JSON.parse(process.argv[1]);
# console.log(m.include.length);
# ' "$MATRIX")"
# echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
# echo "count=$COUNT" >> "$GITHUB_OUTPUT"
# echo "::notice::Will benchmark $COUNT repo(s)."
# benchmark:
# name: scan ${{ matrix.slug }}
# needs: matrix-prep
# if: needs.matrix-prep.outputs.count != '0'
# runs-on: ubuntu-latest
# timeout-minutes: 60
# strategy:
# fail-fast: false
# max-parallel: 10
# matrix: ${{ fromJSON(needs.matrix-prep.outputs.matrix) }}
# steps:
# - uses: actions/checkout@v4
# - uses: pnpm/action-setup@v4
# with:
# version: ${{ env.PNPM_VERSION }}
# - uses: actions/setup-node@v4
# with:
# node-version: ${{ env.NODE_VERSION }}
# cache: pnpm
# - uses: oven-sh/setup-bun@v2
# with:
# bun-version: latest
# # Make every common package manager available so per-repo install can
# # use whatever lockfile its upstream actually ships with.
# - name: enable corepack
# run: |
# corepack enable
# # Don't fail the run if corepack can't reach the registry.
# corepack prepare yarn@stable --activate || true
# corepack prepare npm@latest --activate || true
# - name: install harness deps
# run: pnpm install --frozen-lockfile
# - name: benchmark ${{ matrix.slug }}
# run: pnpm -s tsx scripts/benchmark-repo.ts "${{ matrix.slug }}"
# - name: upload result
# uses: actions/upload-artifact@v4
# with:
# name: result-${{ matrix.slug }}
# path: results/per-repo/${{ matrix.slug }}.json
# if-no-files-found: error
# retention-days: 30
# publish:
# name: publish leaderboard
# needs: [matrix-prep, benchmark]
# if: ${{ always() && !cancelled() && needs.matrix-prep.outputs.count != '0' }}
# runs-on: ubuntu-latest
# permissions:
# contents: write
# steps:
# - uses: actions/checkout@v4
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# fetch-depth: 0
# - uses: pnpm/action-setup@v4
# with:
# version: ${{ env.PNPM_VERSION }}
# - uses: actions/setup-node@v4
# with:
# node-version: ${{ env.NODE_VERSION }}
# cache: pnpm
# - run: pnpm install --frozen-lockfile
# - name: download per-repo results
# uses: actions/download-artifact@v4
# with:
# path: results/per-repo
# pattern: result-*
# merge-multiple: true
# - name: list downloaded results
# run: ls -la results/per-repo || true
# - name: aggregate
# run: pnpm -s tsx scripts/aggregate.ts
# - name: render README
# run: pnpm -s tsx scripts/render-readme.ts
# - name: commit and push
# run: |
# set -euo pipefail
# git config user.name "github-actions[bot]"
# git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# # On workflow_dispatch with a slug filter, we still want partial
# # results published — git add everything we generated.
# git add README.md results/
# if git diff --cached --quiet; then
# echo "No leaderboard changes; skipping commit."
# exit 0
# fi
# git commit -m "chore(benchmark): refresh leaderboard ($(date -u +%Y-%m-%d))"
# git push