Optimize cloning for PR stats (#50859)
Follow-up to https://github.com/vercel/next.js/pull/50853 this optimizes how we clone the branches for generating stats. Before: https://github.com/vercel/next.js/actions/runs/5191059058/jobs/9358459062 21min After: https://github.com/vercel/next.js/actions/runs/5191282140/jobs/9358934393?pr=50859 11min
This commit is contained in:
parent
ea74ad0431
commit
65e996b70f
3 changed files with 7 additions and 10 deletions
|
@ -41,8 +41,7 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
|
||||||
|
|
||||||
// clone PR/newer repository/ref first to get settings
|
// clone PR/newer repository/ref first to get settings
|
||||||
if (!actionInfo.skipClone) {
|
if (!actionInfo.skipClone) {
|
||||||
await cloneRepo(actionInfo.prRepo, diffRepoDir)
|
await cloneRepo(actionInfo.prRepo, diffRepoDir, actionInfo.prRef)
|
||||||
await checkoutRef(actionInfo.prRef, diffRepoDir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actionInfo.isRelease) {
|
if (actionInfo.isRelease) {
|
||||||
|
@ -67,8 +66,7 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
|
||||||
|
|
||||||
// clone main repository/ref
|
// clone main repository/ref
|
||||||
if (!actionInfo.skipClone) {
|
if (!actionInfo.skipClone) {
|
||||||
await cloneRepo(statsConfig.mainRepo, mainRepoDir)
|
await cloneRepo(statsConfig.mainRepo, mainRepoDir, statsConfig.mainBranch)
|
||||||
await checkoutRef(statsConfig.mainBranch, mainRepoDir)
|
|
||||||
}
|
}
|
||||||
/* eslint-disable-next-line */
|
/* eslint-disable-next-line */
|
||||||
actionInfo.commitId = await getCommitId(diffRepoDir)
|
actionInfo.commitId = await getCommitId(diffRepoDir)
|
||||||
|
|
|
@ -8,12 +8,11 @@ const execa = require('execa')
|
||||||
|
|
||||||
module.exports = (actionInfo) => {
|
module.exports = (actionInfo) => {
|
||||||
return {
|
return {
|
||||||
async cloneRepo(repoPath = '', dest = '') {
|
async cloneRepo(repoPath = '', dest = '', branch = '', depth = '20') {
|
||||||
await remove(dest)
|
await remove(dest)
|
||||||
await exec(`git clone ${actionInfo.gitRoot}${repoPath} ${dest}`)
|
await exec(
|
||||||
},
|
`git clone ${actionInfo.gitRoot}${repoPath} --single-branch --branch ${branch} --depth=${depth} ${dest}`
|
||||||
async checkoutRef(ref = '', repoDir = '') {
|
)
|
||||||
await exec(`cd ${repoDir} && git fetch && git checkout ${ref}`)
|
|
||||||
},
|
},
|
||||||
async getLastStable(repoDir = '', ref) {
|
async getLastStable(repoDir = '', ref) {
|
||||||
const { stdout } = await exec(`cd ${repoDir} && git tag -l`)
|
const { stdout } = await exec(`cd ${repoDir} && git tag -l`)
|
||||||
|
|
2
.github/workflows/trigger_release.yml
vendored
2
.github/workflows/trigger_release.yml
vendored
|
@ -49,7 +49,7 @@ jobs:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
check-latest: true
|
check-latest: true
|
||||||
|
|
||||||
- run: git clone https://ijjk:${{ secrets.START_RELEASE_TOKEN }}@github.com/vercel/next.js.git --depth=25 .
|
- run: git clone https://github.com/vercel/next.js.git --depth=25 .
|
||||||
|
|
||||||
- run: git describe || 'echo failed to get tag'
|
- run: git describe || 'echo failed to get tag'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue