Skip to content

Commit

Permalink
ci: add flags.circleci.timeoutMinutes
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardBraham authored and ccharly committed Dec 12, 2024
1 parent 50035f3 commit 4a58972
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ workflows:
- test-api-specs:
requires:
- prep-build-test
- get-changed-files-with-git-diff
- test-e2e-chrome-multiple-providers:
requires:
- prep-build-test
Expand Down
13 changes: 8 additions & 5 deletions .circleci/scripts/git-diff-default-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ async function storeGitDiffOutputAndPrBody() {
// even if we want to skip this step.
fs.mkdirSync(CHANGED_FILES_DIR, { recursive: true });

console.log(
`Determining whether to run git diff...`,
);
console.log(`Determining whether to run git diff...`);
if (!PR_NUMBER) {
console.log('Not a PR, skipping git diff');
return;
Expand All @@ -141,7 +139,9 @@ async function storeGitDiffOutputAndPrBody() {
console.log(`This is for a PR targeting '${baseRef}', skipping git diff`);
writePrBodyToFile(prInfo.body);
return;
} else if (prInfo.labels.some(label => label.name === 'skip-e2e-quality-gate')) {
} else if (
prInfo.labels.some((label) => label.name === 'skip-e2e-quality-gate')
) {
console.log('PR has the skip-e2e-quality-gate label, skipping git diff');
return;
}
Expand All @@ -164,4 +164,7 @@ async function storeGitDiffOutputAndPrBody() {
}
}

storeGitDiffOutputAndPrBody();
// If main module (i.e. this is the TS file that was run directly)
if (require.main === module) {
storeGitDiffOutputAndPrBody();
}
23 changes: 19 additions & 4 deletions .circleci/scripts/test-run-e2e-timeout-minutes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
import { fetchManifestFlagsFromPRAndGit } from '../../development/lib/get-manifest-flag';
import { filterE2eChangedFiles } from '../../test/e2e/changedFilesUtil';

const changedOrNewTests = filterE2eChangedFiles();
fetchManifestFlagsFromPRAndGit().then((manifestFlags) => {
let timeout;

// 20 minutes, plus 3 minutes for every changed file, up to a maximum of 30 minutes
const extraTime = Math.min(20 + changedOrNewTests.length * 3, 30);
if (manifestFlags.circleci?.timeoutMinutes) {
timeout = manifestFlags.circleci?.timeoutMinutes;
} else {
const changedOrNewTests = filterE2eChangedFiles();

console.log(extraTime);
// 20 minutes, plus 3 minutes for every changed file, up to a maximum of 30 minutes
timeout = Math.min(20 + changedOrNewTests.length * 3, 30);
}

// If this is the Merge Queue, add 10 minutes
if (process.env.CIRCLE_BRANCH?.startsWith('gh-readonly-queue')) {
timeout += 10;
}

// This is an essential log, that feeds into a bash script
console.log(timeout);
});
4 changes: 4 additions & 0 deletions app/scripts/lib/manifestFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export type ManifestFlags = {
job?: string;
nodeIndex?: number;
prNumber?: number;
/**
* The number of minutes to allow the E2E tests to run before timing out
*/
timeoutMinutes?: number;
};
sentry?: {
tracesSampleRate?: number;
Expand Down

0 comments on commit 4a58972

Please sign in to comment.