Skip to content

Commit

Permalink
Merge branch 'canary' into 03-13-refactor_test_don_t_use_global_as_an…
Browse files Browse the repository at this point in the history
…y_in_test_utils
  • Loading branch information
balazsorban44 authored Mar 20, 2024
2 parents 3b50db3 + 491f6d8 commit b4c96b2
Show file tree
Hide file tree
Showing 402 changed files with 8,170 additions and 2,664 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ Cargo.toml @timneutkens @i
Cargo.lock @timneutkens @ijjk @shuding @huozhi @vercel/turbopack
/.cargo/config.toml @timneutkens @ijjk @shuding @huozhi @vercel/turbopack
/.config/nextest.toml @timneutkens @ijjk @shuding @huozhi @vercel/turbopack
/test/build-turbopack-tests-manifest.js @timneutkens @ijjk @shuding @huozhi @vercel/turbopack
/test/turbopack-tests-manifest.json @timneutkens @ijjk @shuding @huozhi @vercel/turbopack
/test/build-turbopack-dev-tests-manifest.js @timneutkens @ijjk @shuding @huozhi @vercel/turbopack
/test/turbopack-dev-tests-manifest.json @timneutkens @ijjk @shuding @huozhi @vercel/turbopack
2 changes: 1 addition & 1 deletion .github/actions/next-repo-info/dist/issues/index.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/actions/next-repo-info/dist/prs/index.mjs

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions .github/actions/next-repo-info/lib/util.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// format date to <month|short> <day|numeric>, <year|numeric>
export function formattedDate(createdAt) {
const date = new Date(createdAt)

return date.toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric',
})
}

// Get the date 90 days ago (YYYY-MM-DD)
export function ninetyDaysAgo() {
const date = new Date()
date.setDate(date.getDate() - 90)
return date.toISOString().split('T')[0]
}
15 changes: 6 additions & 9 deletions .github/actions/next-repo-info/src/popular-issues.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// @ts-check
import { context, getOctokit } from '@actions/github'
import { setFailed, info } from '@actions/core'
import { info, setFailed } from '@actions/core'
import { WebClient } from '@slack/web-api'
import { formattedDate, ninetyDaysAgo } from '../lib/util.mjs'

function generateBlocks(issues) {
const blocks = [
{
type: 'section',
text: {
type: 'mrkdwn',
text: '*A list of the top 15 issues sorted by most :+1: reactions over the last 90 days.*\n_Note: This :github2: workflow will run every Monday at 1PM UTC (9AM EST)._',
text: '*A list of the top 15 issues sorted by most :+1: reactions over the last 90 days.*\n_Note: This :github2: <https://github.com/vercel/next.js/blob/canary/.github/workflows/issue_popular.yml|workflow> → <https://github.com/vercel/next.js/blob/canary/.github/actions/next-repo-info/src/popular-issues.mjs|action> will run every Monday at 1PM UTC (9AM EST)._',
},
},
{
Expand All @@ -18,10 +19,11 @@ function generateBlocks(issues) {
]

let text = ''

issues.forEach((issue, i) => {
text += `${i + 1}. [<${issue.html_url}|#${issue.number}>, :+1: ${
issue.reactions['+1']
}]: ${issue.title}\n`
}, ${formattedDate(issue.created_at)}]: ${issue.title}\n`
})

blocks.push({
Expand All @@ -43,16 +45,11 @@ async function run() {
const octoClient = getOctokit(process.env.GITHUB_TOKEN)
const slackClient = new WebClient(process.env.SLACK_TOKEN)

// Get the date 90 days ago (YYYY-MM-DD)
const date = new Date()
date.setDate(date.getDate() - 90)
const ninetyDaysAgo = date.toISOString().split('T')[0]

const { owner, repo } = context.repo
const { data } = await octoClient.rest.search.issuesAndPullRequests({
order: 'desc',
per_page: 15,
q: `repo:${owner}/${repo} is:issue is:open created:>=${ninetyDaysAgo}`,
q: `repo:${owner}/${repo} is:issue is:open created:>=${ninetyDaysAgo()}`,
sort: 'reactions-+1',
})

Expand Down
12 changes: 4 additions & 8 deletions .github/actions/next-repo-info/src/popular-prs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { context, getOctokit } from '@actions/github'
import { setFailed, info } from '@actions/core'
import { WebClient } from '@slack/web-api'
import { formattedDate, ninetyDaysAgo } from '../lib/util.mjs'

function generateBlocks(prs) {
let text = ''
Expand All @@ -17,7 +18,7 @@ function generateBlocks(prs) {
if (pr.reactions['+1'] > 1) {
text += `${i + 1}. [<${pr.html_url}|#${pr.number}>, :+1: ${
pr.reactions['+1']
}]: ${pr.title}\n`
}, ${formattedDate(pr.created_at)}]: ${pr.title}\n`
count++
}
})
Expand All @@ -26,7 +27,7 @@ function generateBlocks(prs) {
type: 'section',
text: {
type: 'mrkdwn',
text: `*A list of the top ${count} PRs sorted by most :+1: reactions (> 1) over the last 90 days.*\n_Note: This :github2: workflow will run every Monday at 1PM UTC (9AM EST)._`,
text: `*A list of the top ${count} PRs sorted by most :+1: reactions (> 1) over the last 90 days.*\n_Note: This :github2: <https://github.com/vercel/next.js/blob/canary/.github/workflows/pull_request_popular.yml|workflow> → <https://github.com/vercel/next.js/blob/canary/.github/actions/next-repo-info/src/popular-prs.mjs|action> will run every Monday at 1PM UTC (9AM EST)._`,
},
})

Expand All @@ -49,16 +50,11 @@ async function run() {
const octoClient = getOctokit(process.env.GITHUB_TOKEN)
const slackClient = new WebClient(process.env.SLACK_TOKEN)

// Get the date 90 days ago (YYYY-MM-DD)
const date = new Date()
date.setDate(date.getDate() - 90)
const ninetyDaysAgo = date.toISOString().split('T')[0]

const { owner, repo } = context.repo
const { data } = await octoClient.rest.search.issuesAndPullRequests({
order: 'desc',
per_page: 15,
q: `repo:${owner}/${repo} is:pr is:open created:>=${ninetyDaysAgo}`,
q: `repo:${owner}/${repo} is:pr is:open created:>=${ninetyDaysAgo()}`,
sort: 'reactions-+1',
})

Expand Down
125 changes: 93 additions & 32 deletions .github/actions/upload-turboyet-data/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/actions/upload-turboyet-data/dist/index.js.map

Large diffs are not rendered by default.

139 changes: 119 additions & 20 deletions .github/actions/upload-turboyet-data/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,93 @@ const path = require('path')

const { createClient } = require('@vercel/kv')

async function main() {
try {
const file = path.join(process.cwd(), 'test/turbopack-tests-manifest.json')
async function collectExamplesResult(manifestFile) {
const file = path.join(process.cwd(), manifestFile)
const contents = await fs.readFile(file, 'utf-8')
const results = JSON.parse(contents)

let failingCount = 0
let passingCount = 0

const currentDate = new Date()
const isoString = currentDate.toISOString()
const timestamp = isoString.slice(0, 19).replace('T', ' ')

for (const isPassing of Object.values(results)) {
if (isPassing) {
passingCount += 1
} else {
failingCount += 1
}
}
const status = `${process.env.GITHUB_SHA}\t${timestamp}\t${passingCount}/${
passingCount + failingCount
}`

return {
status,
// Uses JSON.stringify to create minified JSON, otherwise whitespace is preserved.
data: JSON.stringify(results),
}
}

async function collectResults(manifestFile) {
const file = path.join(process.cwd(), manifestFile)
const contents = await fs.readFile(file, 'utf-8')
const results = JSON.parse(contents)

let passingTests = ''
let failingTests = ''
let passCount = 0
let failCount = 0

const currentDate = new Date()
const isoString = currentDate.toISOString()
const timestamp = isoString.slice(0, 19).replace('T', ' ')

if (results.version === 2) {
for (const [testFileName, result] of Object.entries(results.suites)) {
let suitePassCount = 0
let suiteFailCount = 0

suitePassCount += result.passed.length
suiteFailCount += result.failed.length

let passingTests = ''
let failingTests = ''
let passCount = 0
let failCount = 0
if (suitePassCount > 0) {
passingTests += `${testFileName}\n`
}

const contents = await fs.readFile(file, 'utf-8')
const results = JSON.parse(contents)
if (suiteFailCount > 0) {
failingTests += `${testFileName}\n`
}

const currentDate = new Date()
const isoString = currentDate.toISOString()
const timestamp = isoString.slice(0, 19).replace('T', ' ')
for (const passed of result.passed) {
const passedName = passed.replaceAll('`', '\\`')
passingTests += `* ${passedName}\n`
}

for (const passed of result.failed) {
const failedName = passed.replaceAll('`', '\\`')
failingTests += `* ${failedName}\n`
}

passCount += suitePassCount
failCount += suiteFailCount

if (suitePassCount > 0) {
passingTests += `\n`
}

if (suiteFailCount > 0) {
failingTests += `\n`
}
}

const testRun = `${process.env.GITHUB_SHA}\t${timestamp}\t${passCount}/${
passCount + failCount
}`
return { testRun, passingTests, failingTests }
} else {
for (const [testFileName, result] of Object.entries(results)) {
let suitePassCount = 0
let suiteFailCount = 0
Expand Down Expand Up @@ -55,27 +126,55 @@ async function main() {
failingTests += `\n`
}
}
const testRun = `${process.env.GITHUB_SHA}\t${timestamp}\t${passCount}/${
passCount + failCount
}`

return { testRun, passingTests, failingTests }
}
}

async function main() {
try {
const developmentResult = await collectResults(
'test/turbopack-dev-tests-manifest.json'
)
const productionResult = await collectResults(
'test/turbopack-build-tests-manifest.json'
)
const developmentExamplesResult = await collectExamplesResult(
'test/turbopack-dev-examples-manifest.json'
)

const kv = createClient({
url: process.env.TURBOYET_KV_REST_API_URL,
token: process.env.TURBOYET_KV_REST_API_TOKEN,
})

const testRun = `${process.env.GITHUB_SHA}\t${timestamp}\t${passCount}/${
passCount + failCount
}`
console.log('TEST RESULT DEVELOPMENT')
console.log(developmentResult.testRun)

console.log('TEST RESULT PRODUCTION')
console.log(productionResult.testRun)

console.log('TEST RESULT')
console.log(testRun)
console.log('EXAMPLES RESULT')
console.log(developmentExamplesResult.status)

await kv.rpush('test-runs', testRun)
await kv.rpush('test-runs', developmentResult.testRun)
await kv.rpush('test-runs-production', productionResult.testRun)
await kv.rpush('examples-runs', developmentExamplesResult.status)
console.log('SUCCESSFULLY SAVED RUNS')

await kv.set('passing-tests', passingTests)
await kv.set('passing-tests', developmentResult.passingTests)
await kv.set('passing-tests-production', productionResult.passingTests)
console.log('SUCCESSFULLY SAVED PASSING')

await kv.set('failing-tests', failingTests)
await kv.set('failing-tests', developmentResult.failingTests)
await kv.set('failing-tests-production', productionResult.failingTests)
console.log('SUCCESSFULLY SAVED FAILING')

await kv.set('examples-data', developmentExamplesResult.data)
console.log('SUCCESSFULLY SAVED EXAMPLES')
} catch (error) {
console.log(error)
}
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,52 @@ jobs:
name: wasm-binaries-${{matrix.target}}
path: packages/next-swc/crates/wasm/pkg-*

deployTarball:
if: ${{ needs.build.outputs.isRelease != 'true' }}
name: Deploy tarball
runs-on: ubuntu-latest
needs:
- build
- build-wasm
- build-native
env:
VERCEL_TEST_TOKEN: ${{ secrets.VERCEL_TEST_TOKEN }}
VERCEL_TEST_TEAM: vtest314-next-e2e-tests
steps:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true
- run: corepack enable

# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off

- uses: actions/cache@v4
timeout-minutes: 5
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}

- uses: actions/download-artifact@v4
with:
pattern: next-swc-binaries-*
merge-multiple: true
path: packages/next-swc/native

- uses: actions/download-artifact@v4
with:
pattern: wasm-binaries-*
merge-multiple: true
path: packages/next-swc/crates/wasm

- run: npm i -g vercel@latest

- run: node ./scripts/deploy-tarball.js

publishRelease:
if: ${{ needs.build.outputs.isRelease == 'true' }}
name: Potentially publish release
Expand Down
Loading

0 comments on commit b4c96b2

Please sign in to comment.