Skip to content

Commit

Permalink
fix: log batch trigger (#13748)
Browse files Browse the repository at this point in the history
* chore: log batch trigger at all wait-for-all-codebuild

* chore: log codebuildWebhookTrigger name

* chore: log process.argv 6

* chore: add echo RUNNING RUNNING for debug

* chore: test default value for CODEBUILD_WEBHOOK_TRIGGER

* chore: clean up console log

* chore: remove echo

---------

Co-authored-by: 0.618 <[email protected]>
  • Loading branch information
0618 and 0.618 authored Apr 29, 2024
1 parent b8c8e5e commit 769211a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
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

0 comments on commit 769211a

Please sign in to comment.