Skip to content

Commit 658ecae

Browse files
committed
We cannot revert everything because other PRs expect stable package paths
So we just disable turbo but leave the built pachages in stable location
1 parent ef2672d commit 658ecae

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

.github/actions/next-stats-action/src/prepare/repo-setup.js

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ const mockTrace = () => ({
1010
traceChild: () => mockTrace(),
1111
})
1212

13+
let turboRepoRoot = path.join(__dirname, '..', '..', '..', '..', '..')
14+
15+
// stats-action runs this code without access to the original repo.
16+
// In that case we just use the temporary directory (everything is temporary anyway in CI)
17+
if (turboRepoRoot === '/') {
18+
turboRepoRoot = path.join(__dirname, '..', '..')
19+
}
20+
21+
/** Save turbo cache to persistent storage */
22+
const turboCacheLocation = path.join(turboRepoRoot, 'node_modules/.cache/turbo')
23+
const packedPkgsDir = path.join(turboRepoRoot, 'test/tmp/packedPkgs')
24+
1325
module.exports = (actionInfo) => {
1426
return {
1527
async cloneRepo(repoPath = '', dest = '') {
@@ -81,9 +93,15 @@ module.exports = (actionInfo) => {
8193
await rootSpan
8294
.traceChild('prepare packages for packing')
8395
.traceAsyncFn(async () => {
96+
await fs.ensureDir(packedPkgsDir)
97+
const repoData = require(path.join(repoDir, 'package.json'))
98+
8499
for (const pkg of pkgs) {
85100
const pkgPath = path.join(repoDir, 'packages', pkg)
86-
const packedPkgPath = path.join(pkgPath, `${pkg}-packed.tgz`)
101+
const packedPkgPath = path.join(
102+
packedPkgsDir,
103+
`${pkg}-packed.tgz`
104+
)
87105

88106
const pkgDataPath = path.join(pkgPath, 'package.json')
89107
if (!fs.existsSync(pkgDataPath)) {
@@ -103,7 +121,8 @@ module.exports = (actionInfo) => {
103121
}
104122

105123
for (const pkg of pkgDatas.keys()) {
106-
const { pkgDataPath, pkgData } = pkgDatas.get(pkg)
124+
const { pkgDataPath, pkgData, pkgPath, packedPkgPath } =
125+
pkgDatas.get(pkg)
107126

108127
for (const pkg of pkgDatas.keys()) {
109128
const { packedPkgPath } = pkgDatas.get(pkg)
@@ -139,6 +158,15 @@ module.exports = (actionInfo) => {
139158
}
140159
}
141160

161+
// Turbo requires package manager specification
162+
pkgData.packageManager =
163+
pkgData.packageManager || repoData.packageManager
164+
165+
pkgData.scripts = {
166+
...pkgData.scripts,
167+
'test-pack': `yarn pack -f ${packedPkgPath}`,
168+
}
169+
142170
await fs.writeFile(
143171
pkgDataPath,
144172
JSON.stringify(pkgData, null, 2),
@@ -157,11 +185,8 @@ module.exports = (actionInfo) => {
157185
await packingSpan
158186
.traceChild(`pack ${pkgName}`)
159187
.traceAsyncFn(async () => {
160-
const { pkg, pkgPath } = pkgDatas.get(pkgName)
161-
await exec(
162-
`cd ${pkgPath} && yarn pack -f '${pkg}-packed.tgz'`,
163-
true
164-
)
188+
const { pkgPath } = pkgDatas.get(pkgName)
189+
await exec(`pnpm run --dir="${pkgPath}" test-pack`, true)
165190
})
166191
})
167192
)

0 commit comments

Comments
 (0)