diff --git a/.circleci/config.yml b/.circleci/config.yml index 83c5643400a4..d70ce6f482fb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -125,6 +125,8 @@ workflows: branches: ignore: - master + requires: + - prep-deps - test-deps-audit: requires: - prep-deps @@ -491,7 +493,7 @@ jobs: at: . - run: name: Get changed files with git diff - command: npx tsx .circleci/scripts/git-diff-develop.ts + command: yarn git-diff-default-branch - persist_to_workspace: root: . paths: diff --git a/.circleci/scripts/git-diff-develop.ts b/.circleci/scripts/git-diff-default-branch.ts similarity index 95% rename from .circleci/scripts/git-diff-develop.ts rename to .circleci/scripts/git-diff-default-branch.ts index 3800c03d3254..8db64e0f7058 100644 --- a/.circleci/scripts/git-diff-develop.ts +++ b/.circleci/scripts/git-diff-default-branch.ts @@ -10,7 +10,7 @@ const PR_NUMBER = process.env.CIRCLE_PR_NUMBER || process.env.CIRCLE_PULL_REQUEST?.split('/').pop(); -const MAIN_BRANCH = 'main'; +const GITHUB_DEFAULT_BRANCH = 'main'; const SOURCE_BRANCH = `refs/pull/${PR_NUMBER}/head`; const CHANGED_FILES_DIR = 'changed-files'; @@ -48,7 +48,7 @@ async function getPrInfo(): Promise { */ async function fetchWithDepth(depth: number): Promise { try { - await exec(`git fetch --depth ${depth} origin "${MAIN_BRANCH}"`); + await exec(`git fetch --depth ${depth} origin "${GITHUB_DEFAULT_BRANCH}"`); await exec( `git fetch --depth ${depth} origin "${SOURCE_BRANCH}:${SOURCE_BRANCH}"`, ); @@ -84,7 +84,7 @@ async function fetchUntilMergeBaseFound() { } } } - await exec(`git fetch --unshallow origin "${MAIN_BRANCH}"`); + await exec(`git fetch --unshallow origin "${GITHUB_DEFAULT_BRANCH}"`); } /** @@ -137,7 +137,7 @@ async function storeGitDiffOutputAndPrBody() { if (!baseRef) { console.log('Not a PR, skipping git diff'); return; - } else if (baseRef !== MAIN_BRANCH) { + } else if (baseRef !== GITHUB_DEFAULT_BRANCH) { console.log(`This is for a PR targeting '${baseRef}', skipping git diff`); writePrBodyToFile(prInfo.body); return; diff --git a/.circleci/scripts/rerun-ci-workflow-from-failed.ts b/.circleci/scripts/rerun-ci-workflow-from-failed.ts index 2863ca5bcda0..3c1826a4971e 100644 --- a/.circleci/scripts/rerun-ci-workflow-from-failed.ts +++ b/.circleci/scripts/rerun-ci-workflow-from-failed.ts @@ -1,4 +1,5 @@ const CIRCLE_TOKEN = process.env.API_V2_TOKEN; +const GITHUB_DEFAULT_BRANCH = 'main'; interface Actor { login: string; @@ -177,7 +178,7 @@ async function rerunWorkflowById(workflowId: string) { } /** - * Re-runs failed CircleCI workflows from main branch. + * Re-runs failed CircleCI workflows from default branch. * The workflow will only be re-runed if: * 1. It has the status of 'failed' * 2. It has only been run once @@ -186,9 +187,9 @@ async function rerunWorkflowById(workflowId: string) { * * @throws Will throw an error if fetching the workflows or re-running a workflow fails. */ -async function rerunFailedWorkflowsFromDevelop() { +async function rerunFailedWorkflowsFromDefaultBranch() { console.log('Getting Circle Ci workflows from main branch...'); - const workflows = await getCircleCiWorkflowsByBranch('main'); + const workflows = await getCircleCiWorkflowsByBranch(GITHUB_DEFAULT_BRANCH); console.log('Assessing if any of the workflows needs to be rerun...'); for (const item of workflows) { @@ -204,7 +205,7 @@ async function rerunFailedWorkflowsFromDevelop() { console.log('Task completed successfully!'); } -rerunFailedWorkflowsFromDevelop() +rerunFailedWorkflowsFromDefaultBranch() .catch((error) => { console.error(error); process.exitCode = 1; diff --git a/package.json b/package.json index 803853059703..7d346d40cd0a 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,8 @@ "update-mock-cdn": "node test/e2e/mock-cdn/update-mock-cdn-files.js", "attributions:check": "./development/attributions-check.sh", "attributions:generate": "./development/generate-attributions.sh", - "ci-rerun-from-failed": "tsx .circleci/scripts/rerun-ci-workflow-from-failed.ts" + "ci-rerun-from-failed": "tsx .circleci/scripts/rerun-ci-workflow-from-failed.ts", + "git-diff-default-branch": "tsx .circleci/scripts/git-diff-default-branch.ts" }, "resolutions": { "chokidar": "^3.6.0",