Unverified Commit 6e273824 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update to use specific swc version for PR stats (#40237)

Currently we use one dev swc build for running release/PR stats although the latest swc build could be incompatible with previous tags/commits being compared against so this updates to use the specific version related to that tag. This also updates to omit the swc size from `node_modules` size since it's a dev build and not helpful to track. 

Fixes: https://github.com/vercel/next.js/runs/8189857273?check_suite_focus=true
parent 77e7529d
...@@ -72,11 +72,15 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) { ...@@ -72,11 +72,15 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
} }
/* eslint-disable-next-line */ /* eslint-disable-next-line */
actionInfo.commitId = await getCommitId(diffRepoDir) actionInfo.commitId = await getCommitId(diffRepoDir)
let mainNextSwcVersion
if (!actionInfo.skipClone) { if (!actionInfo.skipClone) {
if (actionInfo.isRelease) { if (actionInfo.isRelease) {
logger('Release detected, resetting mainRepo to last stable tag') logger('Release detected, resetting mainRepo to last stable tag')
const lastStableTag = await getLastStable(mainRepoDir, actionInfo.prRef) const lastStableTag = await getLastStable(mainRepoDir, actionInfo.prRef)
mainNextSwcVersion = {
'@next/swc-linux-x64-gnu': lastStableTag,
}
if (!lastStableTag) throw new Error('failed to get last stable tag') if (!lastStableTag) throw new Error('failed to get last stable tag')
console.log('using latestStable', lastStableTag) console.log('using latestStable', lastStableTag)
await checkoutRef(lastStableTag, mainRepoDir) await checkoutRef(lastStableTag, mainRepoDir)
...@@ -130,9 +134,13 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) { ...@@ -130,9 +134,13 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
.catch(console.error) .catch(console.error)
logger(`Linking packages in ${dir}`) logger(`Linking packages in ${dir}`)
const pkgPaths = await linkPackages(dir) const isMainRepo = dir === mainRepoDir
const pkgPaths = await linkPackages(
dir,
isMainRepo ? mainNextSwcVersion : undefined
)
if (dir === mainRepoDir) mainRepoPkgPaths = pkgPaths if (isMainRepo) mainRepoPkgPaths = pkgPaths
else diffRepoPkgPaths = pkgPaths else diffRepoPkgPaths = pkgPaths
} }
......
...@@ -53,7 +53,7 @@ module.exports = (actionInfo) => { ...@@ -53,7 +53,7 @@ module.exports = (actionInfo) => {
} }
} }
}, },
async linkPackages(repoDir = '') { async linkPackages(repoDir = '', nextSwcPkg) {
const pkgPaths = new Map() const pkgPaths = new Map()
const pkgDatas = new Map() const pkgDatas = new Map()
let pkgs let pkgs
...@@ -109,6 +109,9 @@ module.exports = (actionInfo) => { ...@@ -109,6 +109,9 @@ module.exports = (actionInfo) => {
) )
} }
if (pkg === 'next') { if (pkg === 'next') {
if (nextSwcPkg) {
Object.assign(pkgData.dependencies, nextSwcPkg)
} else {
if (pkgDatas.get('@next/swc')) { if (pkgDatas.get('@next/swc')) {
pkgData.dependencies['@next/swc'] = pkgData.dependencies['@next/swc'] =
pkgDatas.get('@next/swc').packedPkgPath pkgDatas.get('@next/swc').packedPkgPath
...@@ -116,6 +119,7 @@ module.exports = (actionInfo) => { ...@@ -116,6 +119,7 @@ module.exports = (actionInfo) => {
pkgData.files.push('native') pkgData.files.push('native')
} }
} }
}
await fs.writeFile( await fs.writeFile(
pkgDataPath, pkgDataPath,
JSON.stringify(pkgData, null, 2), JSON.stringify(pkgData, null, 2),
......
...@@ -8,6 +8,10 @@ async function getDirSize(dir, ctx = { size: 0 }) { ...@@ -8,6 +8,10 @@ async function getDirSize(dir, ctx = { size: 0 }) {
await Promise.all( await Promise.all(
subDirs.map(async (curDir) => { subDirs.map(async (curDir) => {
// we use dev builds so the size isn't helpful to track
// here as it's not reflective of full releases
if (curDir.includes('@next/swc')) return
const fileStat = await fs.stat(curDir) const fileStat = await fs.stat(curDir)
if (fileStat.isDirectory()) { if (fileStat.isDirectory()) {
return getDirSize(curDir, ctx) return getDirSize(curDir, ctx)
......
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