-
Notifications
You must be signed in to change notification settings - Fork 69
feat(toolkit): add typed return to bootstrap action #249
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #249 +/- ##
==========================================
+ Coverage 85.26% 85.40% +0.14%
==========================================
Files 220 220
Lines 36619 36619
Branches 4448 4461 +13
==========================================
+ Hits 31222 31275 +53
+ Misses 5297 5244 -53
Partials 100 100
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: github-actions <[email protected]>
| environment: environment.name, | ||
| status: bootstrapResult.noOp ? 'no-op' : 'success', | ||
| message: bootstrapResult.noOp ? 'No changes required' : 'Successfully bootstrapped', | ||
| duration: Date.now() - envStartTime, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duration can be access from the return value of await bootstrapSpan.end();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I've removed this field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have it, let's just don't time twice and instead do
const envTime = await bootstrapSpan.end();
// ...
{ duration: envTime.asMs }There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I had misunderstood what you meant, I'll use the time from bootstrapSpan.
| const result: EnvironmentBootstrapResult = { | ||
| environment: environment.name, | ||
| status: 'failed', | ||
| error: e, | ||
| message: formatErrorMessage(e), | ||
| duration: Date.now() - envStartTime, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we throw an exception three lines further down, so this will just never be returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, removed this code. I also removed 'failed' as a status case because it throws an error.
| environment: string; | ||
| status: 'success' | 'failed' | 'no-op'; | ||
| message?: string; | ||
| error?: Error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comment, this will just never be returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still there
mrgrain
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Let's do a little less and re-use what's already there.
| } | ||
|
|
||
| export interface EnvironmentBootstrapResult { | ||
| environment: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be better types as ?
| environment: string; | |
| environment: cxapi.Environment; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced and updated tests as well.
|
|
||
| return { | ||
| environments: results, | ||
| summary, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think let's just loose the summary. If we return, it's successful. If someone really cares about the counts for success vs. no-op, they can do that themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, makes sense. Removed the summary.
…d of string environment
| export interface EnvironmentBootstrapResult { | ||
| environment: cxapi.Environment; | ||
| status: 'success' | 'no-op'; | ||
| error?: Error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| error?: Error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this, it will never be used.
| export interface EnvironmentBootstrapResult { | ||
| environment: cxapi.Environment; | ||
| status: 'success' | 'no-op'; | ||
| duration: Number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| duration: Number; | |
| duration: number; |
| }, | ||
| ); | ||
|
|
||
| const envTime = await bootstrapSpan.end(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you now have bootstrapSpan.end(); twice, causing the message to be printed twice. your reporting block needs to move to where the original end message was.
Fixes #192
Description
The
bootstrapaction in the Toolkit Library currently does not have a returned value. Although there is logged output, theToolkitinstance does not get any information about the result of the bootstrap action.Solution
Make
Toolkit.bootstrap()Return an instance of typePromise<BootstrapResult>, which also uses new typeEnvironmentBootstrapResultwith metrics for each environment.Testing
Added unit tests.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license