Unverified Commit 43697317 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

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: https://github.com/vercel/areweturboyet/pull/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)
parent 58a22f7a
......@@ -5242,7 +5242,10 @@ async function collectResults(manifestFile) {
}
}
async function collectAndUpload(kv, { jsonPrefix, kvPrefix }) {
async function collectAndUpload(
kv,
{ jsonPrefix, kvPrefix, deploymentDomain }
) {
const developmentResult = await collectResults(
`test/${jsonPrefix}dev-tests-manifest.json`
)
......@@ -5283,6 +5286,34 @@ async function collectAndUpload(kv, { jsonPrefix, kvPrefix }) {
await kv.set(`${kvPrefix}examples-data`, developmentExamplesResult.data)
console.log('SUCCESSFULLY SAVED EXAMPLES')
if (deploymentDomain != null) {
// Upstash does not provide strong consistency, so just wait a couple
// seconds before invalidating the cache in case of replication lag.
//
// https://upstash.com/docs/redis/features/consistency
await new Promise((resolve) => setTimeout(resolve, 2000))
try {
const response = await fetch(
`https://${deploymentDomain}/api/revalidate`,
{
method: 'POST',
headers: {
'X-Auth-Token': process.env.TURBOYET_TOKEN,
'Content-Type': 'application/json',
},
}
)
const responseJson = await response.json()
if (!responseJson.revalidated) {
throw new Error(responseJson.error)
}
console.log('SUCCESSFULLY REVALIDATED VERCEL DATA CACHE')
} catch (error) {
// non-fatal: the cache will eventually expire anyways
console.error('FAILED TO REVALIDATE VERCEL DATA CACHE', error)
}
}
}
async function main() {
......@@ -5295,6 +5326,7 @@ async function main() {
await collectAndUpload(kv, {
jsonPrefix: 'turbopack-',
kvPrefix: '',
deploymentDomain: 'areweturboyet.com',
})
console.log('### UPLOADING RSPACK DATA')
await collectAndUpload(kv, {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -134,7 +134,10 @@ async function collectResults(manifestFile) {
}
}
async function collectAndUpload(kv, { jsonPrefix, kvPrefix }) {
async function collectAndUpload(
kv,
{ jsonPrefix, kvPrefix, deploymentDomain }
) {
const developmentResult = await collectResults(
`test/${jsonPrefix}dev-tests-manifest.json`
)
......@@ -175,6 +178,34 @@ async function collectAndUpload(kv, { jsonPrefix, kvPrefix }) {
await kv.set(`${kvPrefix}examples-data`, developmentExamplesResult.data)
console.log('SUCCESSFULLY SAVED EXAMPLES')
if (deploymentDomain != null) {
// Upstash does not provide strong consistency, so just wait a couple
// seconds before invalidating the cache in case of replication lag.
//
// https://upstash.com/docs/redis/features/consistency
await new Promise((resolve) => setTimeout(resolve, 2000))
try {
const response = await fetch(
`https://${deploymentDomain}/api/revalidate`,
{
method: 'POST',
headers: {
'X-Auth-Token': process.env.TURBOYET_TOKEN,
'Content-Type': 'application/json',
},
}
)
const responseJson = await response.json()
if (!responseJson.revalidated) {
throw new Error(responseJson.error)
}
console.log('SUCCESSFULLY REVALIDATED VERCEL DATA CACHE')
} catch (error) {
// non-fatal: the cache will eventually expire anyways
console.error('FAILED TO REVALIDATE VERCEL DATA CACHE', error)
}
}
}
async function main() {
......@@ -187,6 +218,7 @@ async function main() {
await collectAndUpload(kv, {
jsonPrefix: 'turbopack-',
kvPrefix: '',
deploymentDomain: 'areweturboyet.com',
})
console.log('### UPLOADING RSPACK DATA')
await collectAndUpload(kv, {
......
......@@ -6,12 +6,7 @@ name: Upload bundler test manifests to areweturboyet.com
on:
schedule:
- cron: '0 8 * * *'
workflow_dispatch:
inputs:
version:
description: Next.js version, sha, branch to test
type: string
default: 'canary'
workflow_dispatch: {}
push:
branches:
- canary
......@@ -45,4 +40,5 @@ jobs:
env:
TURBOYET_KV_REST_API_URL: ${{ secrets.TURBOYET_KV_REST_API_URL }}
TURBOYET_KV_REST_API_TOKEN: ${{ secrets.TURBOYET_KV_REST_API_TOKEN }}
TURBOYET_TOKEN: ${{ secrets.TURBOYET_TOKEN }}
uses: ./.github/actions/upload-turboyet-data
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment