Repository navigation
192 lines (172 loc) · 7.43 KB
/
Copy pathpull_request_stats.yml
File metadata and controls
192 lines (172 loc) · 7.43 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
182
183
184
185
186
187
188
189
190
191
192
on:
pull_request:
types: [opened, synchronize]
push:
branches:
- canary
name: Generate Stats
concurrency:
# Keep cancel-on-update behavior for PRs, but allow canary pushes to run independently.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
NAPI_CLI_VERSION: 2.18.4
TURBO_VERSION: 2.9.4
TEST_CONCURRENCY: 6
TURBO_TEAM: 'vtest314-next-adapter-e2e-tests'
# Prefer shared remote cache across runs, but keep local cache enabled so jobs
# degrade gracefully if the remote cache or token is unavailable.
TURBO_CACHE: 'local:rw,remote:rw'
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
NEXT_TELEMETRY_DISABLED: 1
# Vercel KV Store for test timings
KV_REST_API_URL: ${{ secrets.KV_REST_API_URL }}
KV_REST_API_TOKEN: ${{ secrets.KV_REST_API_TOKEN }}
NEXT_TEST_JOB: 1
NEXT_DISABLE_SWC_WASM: 1
jobs:
pr-ci-metadata:
name: Upload PR CI metadata
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Write PR metadata
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
PR_IS_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
run: |
mkdir -p pr-ci-metadata
node <<'NODE'
const fs = require('fs')
fs.writeFileSync(
'pr-ci-metadata/pr.json',
JSON.stringify(
{
number: Number(process.env.PR_NUMBER),
headSha: process.env.PR_HEAD_SHA,
headRef: process.env.PR_HEAD_REF,
headRepo: process.env.PR_HEAD_REPO,
baseRef: process.env.PR_BASE_REF,
isFork: process.env.PR_IS_FORK === 'true',
},
null,
2
)
)
NODE
- name: Upload PR metadata
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pr-ci-metadata
path: pr-ci-metadata/pr.json
retention-days: 1
build:
uses: ./.github/workflows/build_reusable.yml
secrets: inherit
with:
stepName: 'generate-pull-request-stats'
uploadSwcArtifact: 'yes'
uploadAnalyzerArtifacts: 'yes'
stats:
name: Stats (${{ matrix.bundler }})
needs: build
# The webpack benchmark alone takes ~25 minutes, so anything at or below
# that cancels the job right as it finishes (seen on canary and PRs alike).
timeout-minutes: 35
strategy:
fail-fast: false
matrix:
# Keep in sync with STATS_EXPECTED_BUNDLERS
bundler: [webpack, turbopack]
runs-on: ubuntu-latest-16-core-arm-oss
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 25
persist-credentials: false
- name: Check non-docs only change
run: echo "DOCS_CHANGE<<EOF" >> $GITHUB_OUTPUT; echo "$(node scripts/run-for-change.mjs --not --type docs --exec echo 'nope')" >> $GITHUB_OUTPUT; echo 'EOF' >> $GITHUB_OUTPUT
id: docs-change
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
with:
name: next-swc-binary-${{ runner.os }}-${{ runner.arch }}
path: packages/next-swc/native
- run: cp -r packages/next-swc/native .github/actions/next-stats-action/native
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
- uses: ./.github/actions/next-stats-action
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
with:
bundler: ${{ matrix.bundler }}
env:
TURBO_TEAM: ${{ env.TURBO_TEAM }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_CACHE: ${{ env.TURBO_CACHE }}
PREVIEW_BUILDS_BASE_URL: ${{ vars.PREVIEW_BUILDS_BASE_URL }}
- name: Upload stats results
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pr-stats-${{ matrix.bundler }}
path: pr-stats-${{ matrix.bundler }}.json
retention-days: 1
stats-aggregate:
name: Aggregate Stats
needs: stats
# Always run so we can recover partial results. A single bundler timing out
# cancels its job, which makes `cancelled()` true here and marks the whole
# run "cancelled" even though the other bundler finished, so `!cancelled()`
# would wrongly skip aggregation. Running unconditionally lets us aggregate
# whatever bundlers succeeded; the reason a bundler is missing is reported in
# the comment, and a truly cancelled run (no results at all) is handled by
# the cancelled fallback in scripts/pr-ci-comment.mjs.
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 25
persist-credentials: false
- name: Check non-docs only change
run: echo "DOCS_CHANGE<<EOF" >> $GITHUB_OUTPUT; echo "$(node scripts/run-for-change.mjs --not --type docs --exec echo 'nope')" >> $GITHUB_OUTPUT; echo 'EOF' >> $GITHUB_OUTPUT
id: docs-change
- name: Download all stats artifacts
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: pr-stats-*
path: stats-results
merge-multiple: true
- name: Setup Node.js
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .node-version
package-manager-cache: false
- name: Install dependencies
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
working-directory: .github/actions/next-stats-action
run: npm install
- name: Aggregate and post results
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
working-directory: .github/actions/next-stats-action
run: node src/aggregate-results.js ${{ github.workspace }}/stats-results
env:
KV_REST_API_URL: ${{ secrets.KV_REST_API_URL }}
KV_REST_API_TOKEN: ${{ secrets.KV_REST_API_TOKEN }}
# Keep in sync with the `stats` job matrix above. The aggregate uses it
# to detect and report bundlers whose job failed or was cancelled
# (their pr-stats-<bundler>.json artifact will be missing).
STATS_EXPECTED_BUNDLERS: 'webpack turbopack'
# Collapsed matrix result ('success' | 'failure' | 'cancelled' |
# 'skipped'). Used to decide, when no artifacts exist at all, whether
# the bundlers genuinely failed (post an "all failed" notice) or the
# run was cancelled/superseded (stay silent and let pr-ci-comment.mjs
# post the cancelled notice).
STATS_RESULT: ${{ needs.stats.result }}