Skip to content

Commit 4369731

Browse files
authored
feat(CI): Revalidate vercel data cache on areweturboyet after uploading data to KV store (#76693)
Without this, you'll have to wait up to 600 seconds after merging a manifest update and waiting for the upload CI job to run, which leads to some confusion. This should make it near-instant. Calls the endpoint defined here: vercel-labs/areweturboyet#20 This needs the `TURBOYET_TOKEN` secret to be configured on the repository. (Thanks @timneutkens) Tested by running it here: https://github.com/vercel/next.js/actions/runs/13635362971/job/38112680086 ![Screenshot 2025-03-03 at 9.27.10 AM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/HAZVitxRNnZz8QMiPn4a/c69fd2b9-2729-4149-8082-5c4f27709585.png)
1 parent 58a22f7 commit 4369731

File tree

4 files changed

+69
-9
lines changed

4 files changed

+69
-9
lines changed

.github/actions/upload-turboyet-data/dist/index.js

Lines changed: 33 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/upload-turboyet-data/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/upload-turboyet-data/src/main.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ async function collectResults(manifestFile) {
134134
}
135135
}
136136

137-
async function collectAndUpload(kv, { jsonPrefix, kvPrefix }) {
137+
async function collectAndUpload(
138+
kv,
139+
{ jsonPrefix, kvPrefix, deploymentDomain }
140+
) {
138141
const developmentResult = await collectResults(
139142
`test/${jsonPrefix}dev-tests-manifest.json`
140143
)
@@ -175,6 +178,34 @@ async function collectAndUpload(kv, { jsonPrefix, kvPrefix }) {
175178

176179
await kv.set(`${kvPrefix}examples-data`, developmentExamplesResult.data)
177180
console.log('SUCCESSFULLY SAVED EXAMPLES')
181+
182+
if (deploymentDomain != null) {
183+
// Upstash does not provide strong consistency, so just wait a couple
184+
// seconds before invalidating the cache in case of replication lag.
185+
//
186+
// https://upstash.com/docs/redis/features/consistency
187+
await new Promise((resolve) => setTimeout(resolve, 2000))
188+
try {
189+
const response = await fetch(
190+
`https://${deploymentDomain}/api/revalidate`,
191+
{
192+
method: 'POST',
193+
headers: {
194+
'X-Auth-Token': process.env.TURBOYET_TOKEN,
195+
'Content-Type': 'application/json',
196+
},
197+
}
198+
)
199+
const responseJson = await response.json()
200+
if (!responseJson.revalidated) {
201+
throw new Error(responseJson.error)
202+
}
203+
console.log('SUCCESSFULLY REVALIDATED VERCEL DATA CACHE')
204+
} catch (error) {
205+
// non-fatal: the cache will eventually expire anyways
206+
console.error('FAILED TO REVALIDATE VERCEL DATA CACHE', error)
207+
}
208+
}
178209
}
179210

180211
async function main() {
@@ -187,6 +218,7 @@ async function main() {
187218
await collectAndUpload(kv, {
188219
jsonPrefix: 'turbopack-',
189220
kvPrefix: '',
221+
deploymentDomain: 'areweturboyet.com',
190222
})
191223
console.log('### UPLOADING RSPACK DATA')
192224
await collectAndUpload(kv, {

.github/workflows/upload-tests-manifest.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ name: Upload bundler test manifests to areweturboyet.com
66
on:
77
schedule:
88
- cron: '0 8 * * *'
9-
workflow_dispatch:
10-
inputs:
11-
version:
12-
description: Next.js version, sha, branch to test
13-
type: string
14-
default: 'canary'
9+
workflow_dispatch: {}
1510
push:
1611
branches:
1712
- canary
@@ -45,4 +40,5 @@ jobs:
4540
env:
4641
TURBOYET_KV_REST_API_URL: ${{ secrets.TURBOYET_KV_REST_API_URL }}
4742
TURBOYET_KV_REST_API_TOKEN: ${{ secrets.TURBOYET_KV_REST_API_TOKEN }}
43+
TURBOYET_TOKEN: ${{ secrets.TURBOYET_TOKEN }}
4844
uses: ./.github/actions/upload-turboyet-data

0 commit comments

Comments
 (0)