Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup on some names and scripts in ci #28844

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ workflows:
branches:
ignore:
- master
requires:
- prep-deps
- test-deps-audit:
requires:
- prep-deps
Expand Down Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better practice - and for that we need deps

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, great catch

- persist_to_workspace:
root: .
paths:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -48,7 +48,7 @@ async function getPrInfo(): Promise<PRInfo | null> {
*/
async function fetchWithDepth(depth: number): Promise<boolean> {
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}"`,
);
Expand Down Expand Up @@ -84,7 +84,7 @@ async function fetchUntilMergeBaseFound() {
}
}
}
await exec(`git fetch --unshallow origin "${MAIN_BRANCH}"`);
await exec(`git fetch --unshallow origin "${GITHUB_DEFAULT_BRANCH}"`);
}

/**
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions .circleci/scripts/rerun-ci-workflow-from-failed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const CIRCLE_TOKEN = process.env.API_V2_TOKEN;
const GITHUB_DEFAULT_BRANCH = 'main';

interface Actor {
login: string;
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -204,7 +205,7 @@ async function rerunFailedWorkflowsFromDevelop() {
console.log('Task completed successfully!');
}

rerunFailedWorkflowsFromDevelop()
rerunFailedWorkflowsFromDefaultBranch()
.catch((error) => {
console.error(error);
process.exitCode = 1;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading