From b1aed07990685907760b87f20ad2a2347832dc66 Mon Sep 17 00:00:00 2001 From: Jan Kaifer Date: Wed, 4 Jan 2023 16:59:59 +0100 Subject: [PATCH] We cannot revert everything because other PRs expect stable package paths So we just disable turbo but leave the built pachages in stable location --- .../src/prepare/repo-setup.js | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/.github/actions/next-stats-action/src/prepare/repo-setup.js b/.github/actions/next-stats-action/src/prepare/repo-setup.js index f490a48ba3da..f242b42b954f 100644 --- a/.github/actions/next-stats-action/src/prepare/repo-setup.js +++ b/.github/actions/next-stats-action/src/prepare/repo-setup.js @@ -10,6 +10,18 @@ const mockTrace = () => ({ traceChild: () => mockTrace(), }) +let turboRepoRoot = path.join(__dirname, '..', '..', '..', '..', '..') + +// stats-action runs this code without access to the original repo. +// In that case we just use the temporary directory (everything is temporary anyway in CI) +if (turboRepoRoot === '/') { + turboRepoRoot = path.join(__dirname, '..', '..') +} + +/** Save turbo cache to persistent storage */ +const turboCacheLocation = path.join(turboRepoRoot, 'node_modules/.cache/turbo') +const packedPkgsDir = path.join(turboRepoRoot, 'test/tmp/packedPkgs') + module.exports = (actionInfo) => { return { async cloneRepo(repoPath = '', dest = '') { @@ -81,9 +93,15 @@ module.exports = (actionInfo) => { await rootSpan .traceChild('prepare packages for packing') .traceAsyncFn(async () => { + await fs.ensureDir(packedPkgsDir) + const repoData = require(path.join(repoDir, 'package.json')) + for (const pkg of pkgs) { const pkgPath = path.join(repoDir, 'packages', pkg) - const packedPkgPath = path.join(pkgPath, `${pkg}-packed.tgz`) + const packedPkgPath = path.join( + packedPkgsDir, + `${pkg}-packed.tgz` + ) const pkgDataPath = path.join(pkgPath, 'package.json') if (!fs.existsSync(pkgDataPath)) { @@ -103,7 +121,8 @@ module.exports = (actionInfo) => { } for (const pkg of pkgDatas.keys()) { - const { pkgDataPath, pkgData } = pkgDatas.get(pkg) + const { pkgDataPath, pkgData, pkgPath, packedPkgPath } = + pkgDatas.get(pkg) for (const pkg of pkgDatas.keys()) { const { packedPkgPath } = pkgDatas.get(pkg) @@ -139,6 +158,15 @@ module.exports = (actionInfo) => { } } + // Turbo requires package manager specification + pkgData.packageManager = + pkgData.packageManager || repoData.packageManager + + pkgData.scripts = { + ...pkgData.scripts, + 'test-pack': `yarn pack -f ${packedPkgPath}`, + } + await fs.writeFile( pkgDataPath, JSON.stringify(pkgData, null, 2), @@ -157,11 +185,8 @@ module.exports = (actionInfo) => { await packingSpan .traceChild(`pack ${pkgName}`) .traceAsyncFn(async () => { - const { pkg, pkgPath } = pkgDatas.get(pkgName) - await exec( - `cd ${pkgPath} && yarn pack -f '${pkg}-packed.tgz'`, - true - ) + const { pkgPath } = pkgDatas.get(pkgName) + await exec(`pnpm run --dir="${pkgPath}" test-pack`, true) }) }) )