Skip to content

Commit 10ebe5b

Browse files
authored
Merge branch 'canary' into dvoytenko/otel-internal-errors
2 parents d58bf5b + 8013ef7 commit 10ebe5b

File tree

134 files changed

+3035
-2538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+3035
-2538
lines changed

.github/actions/next-stats-action/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"dependencies": {
55
"async-sema": "^3.1.0",
66
"execa": "2.0.3",
7-
"fs-extra": "^8.1.0",
87
"get-port": "^5.0.0",
98
"glob": "^7.1.4",
109
"gzip-size": "^5.1.1",
@@ -20,7 +19,7 @@
2019
},
2120
"engines": {
2221
"node": ">=16.14.0",
23-
"pnpm": "8.7.1"
22+
"pnpm": "8.9.0"
2423
},
25-
"packageManager": "pnpm@8.7.1"
24+
"packageManager": "pnpm@8.9.0"
2625
}

.github/actions/next-stats-action/src/add-comment.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const shortenLabel = (itemKey) =>
2424
: itemKey
2525

2626
const twoMB = 2 * 1024 * 1024
27+
const ONE_HUNDRED_BYTES = 100
28+
const ONE_HUNDRED_MS = 100
2729

2830
module.exports = async function addComment(
2931
results = [],
@@ -82,24 +84,21 @@ module.exports = async function addComment(
8284
// otherwise only show gzip values
8385
else if (!isGzipItem && !groupKey.match(gzipIgnoreRegex)) return
8486

85-
if (
86-
!itemKey.startsWith('buildDuration') ||
87-
(isBenchmark && itemKey.match(/req\/sec/))
88-
) {
89-
if (typeof mainItemVal === 'number') mainRepoTotal += mainItemVal
90-
if (typeof diffItemVal === 'number') diffRepoTotal += diffItemVal
91-
}
92-
9387
// calculate the change
9488
if (mainItemVal !== diffItemVal) {
9589
if (
9690
typeof mainItemVal === 'number' &&
9791
typeof diffItemVal === 'number'
9892
) {
99-
change = round(diffItemVal - mainItemVal, 2)
93+
const roundedValue = round(diffItemVal - mainItemVal, 2)
10094

10195
// check if there is still a change after rounding
102-
if (change !== 0) {
96+
if (
97+
roundedValue !== 0 &&
98+
((prettyType === 'ms' && roundedValue > ONE_HUNDRED_MS) ||
99+
(prettyType === 'bytes' && roundedValue > ONE_HUNDRED_BYTES))
100+
) {
101+
change = roundedValue
103102
const absChange = Math.abs(change)
104103
const warnIfNegative = isBenchmark && itemKey.match(/req\/sec/)
105104
const warn = warnIfNegative
@@ -112,12 +111,22 @@ module.exports = async function addComment(
112111
change = `${warn}${change < 0 ? '-' : '+'}${
113112
useRawValue ? absChange : prettify(absChange, prettyType)
114113
}`
114+
} else {
115+
change = 'N/A'
115116
}
116117
} else {
117118
change = 'N/A'
118119
}
119120
}
120121

122+
if (
123+
(change !== 'N/A' && !itemKey.startsWith('buildDuration')) ||
124+
(isBenchmark && itemKey.match(/req\/sec/))
125+
) {
126+
if (typeof mainItemVal === 'number') mainRepoTotal += mainItemVal
127+
if (typeof diffItemVal === 'number') diffRepoTotal += diffItemVal
128+
}
129+
121130
groupTable += `| ${
122131
isBenchmark ? itemKey : shortenLabel(itemKey)
123132
} | ${mainItemStr} | ${diffItemStr} | ${change} |\n`
@@ -169,8 +178,7 @@ module.exports = async function addComment(
169178

170179
// add diffs
171180
if (result.diffs) {
172-
const diffHeading = '#### Diffs\n'
173-
let diffContent = diffHeading
181+
let diffContent = ''
174182

175183
Object.keys(result.diffs).forEach((itemKey) => {
176184
const curDiff = result.diffs[itemKey]
@@ -187,8 +195,11 @@ module.exports = async function addComment(
187195
diffContent += `\n</details>\n`
188196
})
189197

190-
if (diffContent !== diffHeading) {
198+
if (diffContent.length > 0) {
199+
resultContent += `<details>\n`
200+
resultContent += `<summary><strong>Diff details</strong></summary>\n\n`
191201
resultContent += diffContent
202+
resultContent += `\n</details>\n\n`
192203
}
193204
}
194205
let increaseDecreaseNote = ''
@@ -199,7 +210,7 @@ module.exports = async function addComment(
199210
increaseDecreaseNote = ' (Decrease detected ✓)'
200211
}
201212

202-
comment += `<details>\n`
213+
comment += `<details open>\n`
203214
comment += `<summary><strong>${result.title}</strong>${increaseDecreaseNote}</summary>\n\n<br/>\n\n`
204215
comment += resultContent
205216
comment += '</details>\n'

.github/actions/next-stats-action/src/index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require('path')
2-
const fs = require('fs-extra')
2+
const fs = require('fs/promises')
3+
const { existsSync } = require('fs')
34
const exec = require('./util/exec')
45
const logger = require('./util/logger')
56
const runConfigs = require('./run')
@@ -21,7 +22,7 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
2122

2223
;(async () => {
2324
try {
24-
if (await fs.pathExists(path.join(__dirname, '../SKIP_NEXT_STATS.txt'))) {
25+
if (existsSync(path.join(__dirname, '../SKIP_NEXT_STATS.txt'))) {
2526
console.log(
2627
'SKIP_NEXT_STATS.txt file present, exiting stats generation..'
2728
)
@@ -100,7 +101,7 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
100101
for (const dir of repoDirs) {
101102
logger(`Running initial build for ${dir}`)
102103
if (!actionInfo.skipClone) {
103-
const usePnpm = await fs.pathExists(path.join(dir, 'pnpm-lock.yaml'))
104+
const usePnpm = existsSync(path.join(dir, 'pnpm-lock.yaml'))
104105

105106
if (!statsConfig.skipInitialInstall) {
106107
await exec.spawnPromise(
@@ -121,15 +122,13 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
121122
}
122123

123124
await fs
124-
.copy(
125+
.cp(
125126
path.join(__dirname, '../native'),
126-
path.join(dir, 'packages/next-swc/native')
127+
path.join(dir, 'packages/next-swc/native'),
128+
{ recursive: true, force: true }
127129
)
128130
.catch(console.error)
129131

130-
console.log(await exec(`ls ${path.join(__dirname, '../native')}`))
131-
console.log(await exec(`cd ${dir} && ls ${dir}/packages/next-swc/native`))
132-
133132
logger(`Linking packages in ${dir}`)
134133
const isMainRepo = dir === mainRepoDir
135134
const pkgPaths = await linkPackages({

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
const path = require('path')
2-
const fse = require('fs-extra')
3-
const fs = require('fs')
4-
const fsp = require('fs/promises')
2+
const fs = require('fs/promises')
3+
const { existsSync } = require('fs')
54
const exec = require('../util/exec')
6-
const { remove } = require('fs-extra')
75
const logger = require('../util/logger')
86
const execa = require('execa')
97

108
module.exports = (actionInfo) => {
119
return {
1210
async cloneRepo(repoPath = '', dest = '', branch = '', depth = '20') {
13-
await remove(dest)
11+
await fs.rm(dest, { recursive: true, force: true })
1412
await exec(
1513
`git clone ${actionInfo.gitRoot}${repoPath} --single-branch --branch ${branch} --depth=${depth} ${dest}`
1614
)
@@ -72,7 +70,7 @@ module.exports = (actionInfo) => {
7270
let pkgs
7371

7472
try {
75-
pkgs = await fsp.readdir(path.join(repoDir, 'packages'))
73+
pkgs = await fs.readdir(path.join(repoDir, 'packages'))
7674
} catch (err) {
7775
if (err.code === 'ENOENT') {
7876
require('console').log('no packages to link')
@@ -87,8 +85,8 @@ module.exports = (actionInfo) => {
8785
const packedPkgPath = path.join(pkgPath, `${pkg}-packed.tgz`)
8886

8987
const pkgDataPath = path.join(pkgPath, 'package.json')
90-
if (fs.existsSync(pkgDataPath)) {
91-
const pkgData = JSON.parse(await fsp.readFile(pkgDataPath))
88+
if (existsSync(pkgDataPath)) {
89+
const pkgData = JSON.parse(await fs.readFile(pkgDataPath))
9290
const { name } = pkgData
9391

9492
pkgDatas.set(name, {
@@ -122,7 +120,7 @@ module.exports = (actionInfo) => {
122120
pkgData.files.push('native')
123121

124122
try {
125-
const swcBinariesDirContents = await fsp.readdir(
123+
const swcBinariesDirContents = await fs.readdir(
126124
path.join(pkgPath, 'native')
127125
)
128126
require('console').log(
@@ -155,7 +153,7 @@ module.exports = (actionInfo) => {
155153
}
156154
}
157155

158-
await fsp.writeFile(
156+
await fs.writeFile(
159157
pkgDataPath,
160158
JSON.stringify(pkgData, null, 2),
161159
'utf8'
@@ -186,9 +184,9 @@ module.exports = (actionInfo) => {
186184
'disabled-native-gitignore'
187185
)
188186

189-
await fsp.rename(nativeGitignorePath, renamedGitignorePath)
187+
await fs.rename(nativeGitignorePath, renamedGitignorePath)
190188
cleanup = async () => {
191-
await fsp.rename(renamedGitignorePath, nativeGitignorePath)
189+
await fs.rename(renamedGitignorePath, nativeGitignorePath)
192190
}
193191
}
194192

@@ -201,7 +199,7 @@ module.exports = (actionInfo) => {
201199
})
202200

203201
return Promise.all([
204-
fsp.rename(path.resolve(pkgPath, stdout.trim()), packedPkgPath),
202+
fs.rename(path.resolve(pkgPath, stdout.trim()), packedPkgPath),
205203
cleanup?.(),
206204
])
207205
}

.github/actions/next-stats-action/src/run/collect-diffs.js

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require('path')
2-
const fs = require('fs-extra')
2+
const fs = require('fs/promises')
3+
const { existsSync } = require('fs')
34
const exec = require('../util/exec')
45
const glob = require('../util/glob')
56
const logger = require('../util/logger')
@@ -12,15 +13,17 @@ module.exports = async function collectDiffs(
1213
if (initial) {
1314
logger('Setting up directory for diffing')
1415
// set-up diffing directory
15-
await fs.remove(diffingDir)
16-
await fs.mkdirp(diffingDir)
16+
await fs.rm(diffingDir, { recursive: true, force: true })
17+
await fs.mkdir(diffingDir, { recursive: true })
1718
await exec(`cd ${diffingDir} && git init`)
1819
} else {
1920
// remove any previous files in case they won't be overwritten
2021
const toRemove = await glob('!(.git)', { cwd: diffingDir, dot: true })
2122

2223
await Promise.all(
23-
toRemove.map((file) => fs.remove(path.join(diffingDir, file)))
24+
toRemove.map((file) =>
25+
fs.rm(path.join(diffingDir, file), { recursive: true, force: true })
26+
)
2427
)
2528
}
2629
const diffs = {}
@@ -40,7 +43,7 @@ module.exports = async function collectDiffs(
4043
const absPath = path.join(statsAppDir, file)
4144

4245
const diffDest = path.join(diffingDir, file)
43-
await fs.copy(absPath, diffDest)
46+
await fs.cp(absPath, diffDest, { recursive: true, force: true })
4447
}
4548

4649
if (curFiles.length > 0) {
@@ -75,7 +78,7 @@ module.exports = async function collectDiffs(
7578

7679
for (const line of renamedFiles) {
7780
const [, prev, cur] = line.split('\t')
78-
await fs.move(path.join(diffingDir, cur), path.join(diffingDir, prev))
81+
await fs.rename(path.join(diffingDir, cur), path.join(diffingDir, prev))
7982
diffs._renames.push({
8083
prev,
8184
cur,
@@ -91,7 +94,7 @@ module.exports = async function collectDiffs(
9194

9295
for (const file of changedFiles) {
9396
const fileKey = path.basename(file)
94-
const hasFile = await fs.exists(path.join(diffingDir, file))
97+
const hasFile = existsSync(path.join(diffingDir, file))
9598

9699
if (!hasFile) {
97100
diffs[fileKey] = 'deleted'
@@ -103,7 +106,7 @@ module.exports = async function collectDiffs(
103106
`cd ${diffingDir} && git diff --minimal HEAD ${file}`
104107
)
105108
stdout = (stdout.split(file).pop() || '').trim()
106-
if (stdout.length > 0) {
109+
if (stdout.length > 0 && !isLikelyHashOrIDChange(stdout)) {
107110
diffs[fileKey] = stdout
108111
}
109112
} catch (err) {
@@ -114,3 +117,48 @@ module.exports = async function collectDiffs(
114117
}
115118
return diffs
116119
}
120+
121+
function isLikelyHashOrIDChange(diff) {
122+
const lines = diff.split('\n')
123+
let additions = []
124+
let deletions = []
125+
126+
// Separate additions and deletions
127+
for (const line of lines) {
128+
if (line.startsWith('+')) {
129+
additions.push(line.substring(1).split(/\b/))
130+
} else if (line.startsWith('-')) {
131+
deletions.push(line.substring(1).split(/\b/))
132+
}
133+
}
134+
135+
// If the number of additions and deletions is different, it's not a hash or ID change
136+
if (additions.length !== deletions.length) {
137+
return false
138+
}
139+
140+
// Compare each addition with each deletion
141+
for (let i = 0; i < additions.length; i++) {
142+
const additionTokens = additions[i]
143+
const deletionTokens = deletions[i]
144+
145+
// Identify differing tokens
146+
const differingTokens = additionTokens.filter(
147+
(token, index) => token !== deletionTokens[index]
148+
)
149+
150+
// Analyze differing tokens
151+
for (const token of differingTokens) {
152+
const isLikelyHash = /^[a-f0-9]+$/.test(token)
153+
const isLikelyID = /^[0-9]+$/.test(token)
154+
// this is most likely noise because some path include the repo name, which can be main or diff
155+
const isLikelyNoise = ['main', 'diff'].includes(token)
156+
157+
if (!isLikelyHash && !isLikelyID && !isLikelyNoise) {
158+
return false
159+
}
160+
}
161+
}
162+
163+
return true
164+
}

.github/actions/next-stats-action/src/run/collect-stats.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path')
2-
const fs = require('fs-extra')
2+
const fs = require('fs/promises')
33
const getPort = require('get-port')
44
const fetch = require('node-fetch')
55
const glob = require('../util/glob')
@@ -84,7 +84,7 @@ module.exports = async function collectStats(
8484

8585
if (hasPagesToFetch) {
8686
const fetchedPagesDir = path.join(curDir, 'fetched-pages')
87-
await fs.mkdirp(fetchedPagesDir)
87+
await fs.mkdir(fetchedPagesDir, { recursive: true })
8888

8989
for (let url of runConfig.pagesToFetch) {
9090
url = url.replace('$PORT', port)

.github/actions/next-stats-action/src/run/get-dir-size.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path')
2-
const fs = require('fs-extra')
2+
const fs = require('fs/promises')
33

44
// getDirSize recursively gets size of all files in a directory
55
async function getDirSize(dir, ctx = { size: 0 }) {

0 commit comments

Comments
 (0)