Skip to content

Commit

Permalink
Update release stats install/build executing (#54576)
Browse files Browse the repository at this point in the history
Aims to make debugging the release stats failure easier as currently we
don't see the logs are the command is executing

x-ref:
https://github.com/vercel/next.js/actions/runs/5976635577/job/16221230094
x-ref: #54536
  • Loading branch information
ijjk committed Aug 25, 2023
1 parent b048d7e commit eee1376
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
20 changes: 6 additions & 14 deletions .github/actions/next-stats-action/src/index.js
Expand Up @@ -7,14 +7,8 @@ const addComment = require('./add-comment')
const actionInfo = require('./prepare/action-info')()
const { mainRepoDir, diffRepoDir } = require('./constants')
const loadStatsConfig = require('./prepare/load-stats-config')
const {
cloneRepo,
checkoutRef,
mergeBranch,
getCommitId,
linkPackages,
getLastStable,
} = require('./prepare/repo-setup')(actionInfo)
const { cloneRepo, mergeBranch, getCommitId, linkPackages, getLastStable } =
require('./prepare/repo-setup')(actionInfo)

const allowedActions = new Set(['synchronize', 'opened'])

Expand Down Expand Up @@ -109,21 +103,19 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
const usePnpm = await fs.pathExists(path.join(dir, 'pnpm-lock.yaml'))

if (!statsConfig.skipInitialInstall) {
await exec(
await exec.spawnPromise(
`cd ${dir}${
usePnpm
? // --no-frozen-lockfile is used here to tolerate lockfile
// changes from merging latest changes
` && pnpm install --no-frozen-lockfile`
: ' && yarn install --network-timeout 1000000'
}`,
false
}`
)

await exec(
await exec.spawnPromise(
statsConfig.initialBuildCommand ||
`cd ${dir} && ${usePnpm ? 'pnpm build' : 'echo built'}`,
false
`cd ${dir} && ${usePnpm ? 'pnpm build' : 'echo built'}`
)
}
}
Expand Down
14 changes: 14 additions & 0 deletions .github/actions/next-stats-action/src/util/exec.js
Expand Up @@ -34,4 +34,18 @@ exec.spawn = function spawn(command = '', opts = {}) {
return child
}

exec.spawnPromise = function spawnPromise(command = '', opts = {}) {
return new Promise((resolve, reject) => {
const child = exec.spawn(command)
child.on('exit', (code, signal) => {
if (code || signal) {
return reject(
new Error(`bad exit code/signal code: ${code} signal: ${signal}`)
)
}
resolve()
})
})
}

module.exports = exec
2 changes: 2 additions & 0 deletions .github/workflows/build_and_deploy.yml
Expand Up @@ -229,6 +229,7 @@ jobs:
name: stable - ${{ matrix.settings.target }} - node@16
runs-on: ${{ matrix.settings.host }}
timeout-minutes: 30
steps:
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
Expand Down Expand Up @@ -509,6 +510,7 @@ jobs:
- 'linux'
- 'x64'
- 'metal'
timeout-minutes: 25
needs: [publishRelease]
steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull_request_stats.yml
Expand Up @@ -31,6 +31,7 @@ jobs:
stats:
name: PR Stats
needs: build
timeout-minutes: 25
runs-on:
- 'self-hosted'
- 'linux'
Expand Down

0 comments on commit eee1376

Please sign in to comment.