Skip to content

Commit

Permalink
Automatically update Turbopack test manifest (#57778)
Browse files Browse the repository at this point in the history
### What?

This PR adds an hourly workflow that will update the test manifest used when testing with Turbopack.

### Why?

To ensure we don't regress any test suites.

### How?

I use the existing `scripts/update-fonts-data-workflow.js` workflow script which will execute a script, then create a PR with the current working tree. If any pending automated PRs exist, they will be closed when a new one is opened.
  • Loading branch information
jridgewell authored Oct 31, 2023
1 parent adc636d commit 7951131
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/update-turbopack-test-manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# A recurring workflow which updates the passing/failing/skipped integration tests for Turbopack.
name: Update Turbopack test manifest

on:
schedule:
# Every hour
- cron: '0 * * * *'
workflow_dispatch:

jobs:
update_manifest:
name: Update and upload Turbopack test manifest
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# Commits made with the default `GITHUB_TOKEN` won't trigger workflows.
# See: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true

- name: Create Pull Request
shell: bash
run: node scripts/automated-update-workflow.js
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PULL_REQUESTS }}
BRANCH_NAME: fonts-data
SCRIPT: test/build-turbopack-tests-manifest.js
PR_TITLE: Update Turbopack test manifest
PR_BODY: This auto-generated PR updates the integration test manifest used when testing Turbopack.
6 changes: 5 additions & 1 deletion .github/workflows/update_fonts_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:

- name: Create Pull Request
shell: bash
run: node scripts/update-fonts-data-workflow.js
run: node scripts/automated-update-workflow.js
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PULL_REQUESTS }}
BRANCH_NAME: fonts-data
SCRIPT: scripts/update-google-fonts.js
PR_TITLE: Update font data
PR_BODY: This auto-generated PR updates font data with latest available
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,28 @@ const { exec: execOriginal } = require('child_process')

const exec = promisify(execOriginal)

const GITHUB_TOKEN = process.env.GITHUB_TOKEN || ''
const {
GITHUB_TOKEN = '',
SCRIPT = '',
BRANCH_NAME = 'unknown',
PR_TITLE = 'Automated update',
PR_BODY = '',
} = process.env

if (!GITHUB_TOKEN) {
console.log('missing GITHUB_TOKEN env')
process.exit(1)
}
if (!SCRIPT) {
console.log('missing SCRIPT env')
process.exit(1)
}

async function main() {
const octokit = new Octokit({ auth: GITHUB_TOKEN })
const branchName = `update/fonts-data-${Date.now()}`
const branchName = `update/${BRANCH_NAME}-${Date.now()}`

await exec(`node scripts/update-google-fonts.js`)
await exec(`node ${SCRIPT}`)

await exec(`git config user.name "vercel-release-bot"`)
await exec(`git config user.email "[email protected]"`)
Expand Down Expand Up @@ -52,14 +62,14 @@ async function main() {
repo,
head: branchName,
base: 'canary',
title: `Update font data`,
body: `This auto-generated PR updates font data with latest available`,
title: PR_TITLE,
body: PR_BODY,
})

console.log('Created pull request', pullRequest.url)

const previousPullRequests = pullRequests.filter(({ title }) => {
return title.startsWith('Update font data')
const previousPullRequests = pullRequests.filter(({ title, user }) => {
return title.includes(PR_TITLE) && user.login === 'vercel-release-bot'
})

if (previousPullRequests.length) {
Expand Down

0 comments on commit 7951131

Please sign in to comment.