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

fix: log batch trigger #13748

Merged
merged 7 commits into from
Apr 29, 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
11 changes: 6 additions & 5 deletions scripts/wait-for-all-codebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const main = async () => {
const codeBuildProjectName = process.argv[4];
const codebuildWebhookTrigger = process.argv[5];
const accountForFailures: boolean = process.argv.length >= 7 && process.argv[6] === 'requirePrevJobsToSucceed';

let jobsDependedOn: string[];
if (fs.existsSync(jobsDependedOnFilepathOrId)) {
const jobsDependedOnRaw = fs.readFileSync(jobsDependedOnFilepathOrId, 'utf8');
Expand Down Expand Up @@ -80,14 +81,14 @@ const main = async () => {
let intersectingIncompleteJobs: string[];
do {
await new Promise((resolve) => setTimeout(resolve, 180 * 1000)); // sleep for 180 seconds
const failedJobsInBatch = await getFailedJobIdsFromBatchId(cb, batchId);
const intersectingFailedJobs = failedJobsInBatch.filter((jobId) => jobsDependedOn.includes(jobId));
const batchFailed = failedJobsInBatch.length || intersectingFailedJobs.length;
console.log(`Batch triggered by ${codebuildWebhookTrigger} ${batchFailed ? 'failed' : 'succeeded'}.`);

if (accountForFailures) {
const failedJobsInBatch = await getFailedJobIdsFromBatchId(cb, batchId);
const intersectingFailedJobs = failedJobsInBatch.filter((jobId) => jobsDependedOn.includes(jobId));
console.log(`failedJobsInBatch: ${JSON.stringify(failedJobsInBatch)}`);
console.log(`intersectingFailedJobs: ${JSON.stringify(intersectingFailedJobs)}`);
if (failedJobsInBatch.length || intersectingFailedJobs.length) {
console.log(`Batch triggered by ${codebuildWebhookTrigger} failed.`);
}
if (intersectingFailedJobs.length > 0) {
console.log(`${jobsDependedOn[0]} failed. Exiting.`);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion shared-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ function _waitForJobs {
cd ./scripts
npm install -g ts-node
npm install aws-sdk
ts-node ./wait-for-all-codebuild.ts $CODEBUILD_RESOLVED_SOURCE_VERSION $file_path $PROJECT_NAME $CODEBUILD_WEBHOOK_TRIGGER $account_for_failures
ts-node ./wait-for-all-codebuild.ts $CODEBUILD_RESOLVED_SOURCE_VERSION $file_path $PROJECT_NAME ${CODEBUILD_WEBHOOK_TRIGGER:-empty} $account_for_failures
cd ..
}
function _verifyPkgCLI {
Expand Down
Loading