Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
fd9ec646
Unverified
Commit
fd9ec646
authored
Dec 22, 2022
by
Jan Kaifer
Committed by
GitHub
Dec 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use turbo for packing files in test setup (#44074)
parent
02489c2f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
5 deletions
+50
-5
package.json
.github/actions/next-stats-action/package.json
+5
-1
repo-setup.js
.github/actions/next-stats-action/src/prepare/repo-setup.js
+44
-4
package.json
package.json
+1
-0
No files found.
.github/actions/next-stats-action/package.json
View file @
fd9ec646
{
{
"private"
:
true
,
"private"
:
true
,
"main"
:
"src/index.js"
,
"main"
:
"src/index.js"
,
"scripts"
:
{
"turbo"
:
"turbo"
},
"dependencies"
:
{
"dependencies"
:
{
"async-sema"
:
"^3.1.0"
,
"async-sema"
:
"^3.1.0"
,
"fs-extra"
:
"^8.1.0"
,
"fs-extra"
:
"^8.1.0"
,
...
@@ -12,6 +15,7 @@
...
@@ -12,6 +15,7 @@
"prettier"
:
"^1.18.2"
,
"prettier"
:
"^1.18.2"
,
"pretty-bytes"
:
"^5.3.0"
,
"pretty-bytes"
:
"^5.3.0"
,
"pretty-ms"
:
"^5.0.0"
,
"pretty-ms"
:
"^5.0.0"
,
"semver"
:
"7.3.4"
"semver"
:
"7.3.4"
,
"turbo"
:
"1.6.3"
}
}
}
}
.github/actions/next-stats-action/src/prepare/repo-setup.js
View file @
fd9ec646
...
@@ -10,6 +10,18 @@ const mockTrace = () => ({
...
@@ -10,6 +10,18 @@ const mockTrace = () => ({
traceChild
:
()
=>
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
)
=>
{
module
.
exports
=
(
actionInfo
)
=>
{
return
{
return
{
async
cloneRepo
(
repoPath
=
''
,
dest
=
''
)
{
async
cloneRepo
(
repoPath
=
''
,
dest
=
''
)
{
...
@@ -81,9 +93,15 @@ module.exports = (actionInfo) => {
...
@@ -81,9 +93,15 @@ module.exports = (actionInfo) => {
await
rootSpan
await
rootSpan
.
traceChild
(
'prepare packages for packing'
)
.
traceChild
(
'prepare packages for packing'
)
.
traceAsyncFn
(
async
()
=>
{
.
traceAsyncFn
(
async
()
=>
{
await
fs
.
ensureDir
(
packedPkgsDir
)
const
repoData
=
require
(
path
.
join
(
repoDir
,
'package.json'
))
for
(
const
pkg
of
pkgs
)
{
for
(
const
pkg
of
pkgs
)
{
const
pkgPath
=
path
.
join
(
repoDir
,
'packages'
,
pkg
)
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'
)
const
pkgDataPath
=
path
.
join
(
pkgPath
,
'package.json'
)
if
(
!
fs
.
existsSync
(
pkgDataPath
))
{
if
(
!
fs
.
existsSync
(
pkgDataPath
))
{
...
@@ -103,7 +121,8 @@ module.exports = (actionInfo) => {
...
@@ -103,7 +121,8 @@ module.exports = (actionInfo) => {
}
}
for
(
const
pkg
of
pkgDatas
.
keys
())
{
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
())
{
for
(
const
pkg
of
pkgDatas
.
keys
())
{
const
{
packedPkgPath
}
=
pkgDatas
.
get
(
pkg
)
const
{
packedPkgPath
}
=
pkgDatas
.
get
(
pkg
)
...
@@ -139,6 +158,27 @@ module.exports = (actionInfo) => {
...
@@ -139,6 +158,27 @@ 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
.
writeJSON
(
path
.
join
(
pkgPath
,
'turbo.json'
),
{
pipeline
:
{
'test-pack'
:
{
outputs
:
[
packedPkgPath
],
inputs
:
[
'*'
,
'!node_modules/'
,
'!.turbo/'
],
},
},
})
// Turbo requires pnpm-lock.yaml that is not empty
await
fs
.
writeFile
(
path
.
join
(
pkgPath
,
'pnpm-lock.yaml'
),
''
)
await
fs
.
writeFile
(
await
fs
.
writeFile
(
pkgDataPath
,
pkgDataPath
,
JSON
.
stringify
(
pkgData
,
null
,
2
),
JSON
.
stringify
(
pkgData
,
null
,
2
),
...
@@ -157,9 +197,9 @@ module.exports = (actionInfo) => {
...
@@ -157,9 +197,9 @@ module.exports = (actionInfo) => {
await
packingSpan
await
packingSpan
.
traceChild
(
`pack
${
pkgName
}
`
)
.
traceChild
(
`pack
${
pkgName
}
`
)
.
traceAsyncFn
(
async
()
=>
{
.
traceAsyncFn
(
async
()
=>
{
const
{
pkg
,
pkg
Path
}
=
pkgDatas
.
get
(
pkgName
)
const
{
pkgPath
}
=
pkgDatas
.
get
(
pkgName
)
await
exec
(
await
exec
(
`
cd
${
pkgPath
}
&& yarn pack -f '
${
pkg
}
-packed.tgz'
`
,
`
pnpm run --dir="
${
turboRepoRoot
}
" turbo run test-pack --cache-dir="
${
turboCacheLocation
}
" --cwd="
${
pkgPath
}
"
`
,
true
true
)
)
})
})
...
...
package.json
View file @
fd9ec646
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
"build"
:
"turbo run build"
,
"build"
:
"turbo run build"
,
"lerna"
:
"lerna"
,
"lerna"
:
"lerna"
,
"dev"
:
"turbo run dev --parallel"
,
"dev"
:
"turbo run dev --parallel"
,
"turbo"
:
"turbo"
,
"test-types"
:
"pnpm tsc"
,
"test-types"
:
"pnpm tsc"
,
"test-unit"
:
"pnpm jest test/unit/"
,
"test-unit"
:
"pnpm jest test/unit/"
,
"test-dev"
:
"cross-env NEXT_TEST_MODE=dev pnpm testheadless"
,
"test-dev"
:
"cross-env NEXT_TEST_MODE=dev pnpm testheadless"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment