Skip to content

Commit

Permalink
Optimize cloning for PR stats (#50859)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored Jun 6, 2023
1 parent ea74ad0 commit 65e996b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
6 changes: 2 additions & 4 deletions .github/actions/next-stats-action/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {

// clone PR/newer repository/ref first to get settings
if (!actionInfo.skipClone) {
await cloneRepo(actionInfo.prRepo, diffRepoDir)
await checkoutRef(actionInfo.prRef, diffRepoDir)
await cloneRepo(actionInfo.prRepo, diffRepoDir, actionInfo.prRef)
}

if (actionInfo.isRelease) {
Expand All @@ -67,8 +66,7 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {

// clone main repository/ref
if (!actionInfo.skipClone) {
await cloneRepo(statsConfig.mainRepo, mainRepoDir)
await checkoutRef(statsConfig.mainBranch, mainRepoDir)
await cloneRepo(statsConfig.mainRepo, mainRepoDir, statsConfig.mainBranch)
}
/* eslint-disable-next-line */
actionInfo.commitId = await getCommitId(diffRepoDir)
Expand Down
9 changes: 4 additions & 5 deletions .github/actions/next-stats-action/src/prepare/repo-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ const execa = require('execa')

module.exports = (actionInfo) => {
return {
async cloneRepo(repoPath = '', dest = '') {
async cloneRepo(repoPath = '', dest = '', branch = '', depth = '20') {
await remove(dest)
await exec(`git clone ${actionInfo.gitRoot}${repoPath} ${dest}`)
},
async checkoutRef(ref = '', repoDir = '') {
await exec(`cd ${repoDir} && git fetch && git checkout ${ref}`)
await exec(
`git clone ${actionInfo.gitRoot}${repoPath} --single-branch --branch ${branch} --depth=${depth} ${dest}`
)
},
async getLastStable(repoDir = '', ref) {
const { stdout } = await exec(`cd ${repoDir} && git tag -l`)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trigger_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
node-version: 18
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'

Expand Down

0 comments on commit 65e996b

Please sign in to comment.