Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

EVG-20983: Improve deploy script error handling and remove duplicate tag push #2108

Merged
merged 15 commits into from
Nov 1, 2023

Conversation

SupaJoon
Copy link
Contributor

@SupaJoon SupaJoon commented Oct 17, 2023

EVG-20983
Adds error handling and exit codes to evergreenDeploy, ciDeploy, localDeploy and the postversion hook (push-version.sh) and removes a duplicate tag push when force deploying.

@SupaJoon SupaJoon requested a review from a team October 17, 2023 18:49
@cypress
Copy link

cypress bot commented Oct 17, 2023

Passing run #13521 ↗︎

0 601 7 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

update mock
Project: Spruce Commit: 2e6a8951ff
Status: Passed Duration: 19:15 💡
Started: Oct 31, 2023 4:32 PM Ended: Oct 31, 2023 4:52 PM

Review all test suite changes for PR #2108 ↗︎

console.log("Creating new tag...");
createNewTag();
console.log("Pushing tags...");
pushTags();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the duplicate tag push. createNewTag calls the postversion hook which runs scripts/push-version.sh

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there might be a space in the name of this file? Either that or the github UI is playing tricks.
image

Comment on lines 10 to 20
try {
execSync("yarn version --new-version patch", {
encoding: "utf-8",
stdio: "inherit",
});
} catch (err) {
console.log("Creating new tag failed.");
console.log("output", err);
return false;
}
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this composition is pretty confusing. Some util functions return these booleans indicating the status while others throw errors. What criteria is used to determine what should do what? Could we be a little more consistent in how we error?
How do you feel about treating errors the way we do in go and wrapping them?
https://stackoverflow.com/questions/42754270/re-throwing-exception-in-nodejs-and-not-losing-stack-trace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sweet, wrapping and re-throwing helps a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What criteria is used to determine what should do what? Could we be a little more consistent in how we error?

I wanted to throw and handle errors closer to the GH api functions so they are easier to track down and debug. Wrapping the error and including a message and then propagating that error to a top level try/catch is better though because 1) we get the benefit of adding help text to a specific code block and 2) have all of the errors collected in the same part of the program so the exit point is consolidated.

@SupaJoon SupaJoon requested a review from khelif96 October 20, 2023 15:12
Comment on lines +19 to +24
const { value: shouldForceDeploy } = await prompts({
type: "confirm",
name: "value",
message: `No new commits. Do you want to trigger a deploy on the most recent existing tag? (${latestTag})`,
initial: false,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

We ran into an issue last week when the deployer just hit enter and breezed through this message. Could we maybe have it default to false so that a user needs to be a little more careful to go through with this action?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good idea but I'll like to complete it in a separate ticket: https://jira.mongodb.org/browse/EVG-21115

@SupaJoon SupaJoon requested a review from sophstad October 20, 2023 18:07
} catch (err) {
throw new Error("Creating new tag failed.", { cause: err });
}
console.log("Pushed to remote. Should be deploying soon...");
Copy link
Contributor Author

@SupaJoon SupaJoon Oct 31, 2023

Choose a reason for hiding this comment

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

I moved logging to the helper function so the api request and followup messaging stay together. This also keeps the calling script clean.

Copy link
Contributor

@khelif96 khelif96 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

😍

@SupaJoon SupaJoon merged commit 1d33a16 into evergreen-ci:main Nov 1, 2023
2 checks passed
@SupaJoon SupaJoon deleted the EVG-20983 branch November 1, 2023 14:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants