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

feat: add alwaysPrintInCI option #76

Merged
merged 3 commits into from
Dec 16, 2024
Merged

Conversation

cristiand391
Copy link
Member

@cristiand391 cristiand391 commented Dec 12, 2024

Found this bug while working on https://github.com/salesforcecli/plugin-deploy-retrieve/pull/1215/files

Adds new alwaysPrintInCI option suggested here:
#76 (comment)

it only affects CI output, if an info block sets it to true then all updates will be rendered (to avoid possible duplicates consumers need to handle that in the info block getter).

@W-17203886@

The `CIMultiStageOutput` class was caching dynamic blocks by their
label, then calculating wether or not to print new info based on the
throttle time and causing it to miss printing new dynamic stage data if the
throttle time is bigger than the time new data arrives.
@cristiand391 cristiand391 marked this pull request as ready for review December 12, 2024 21:52
@@ -294,7 +294,7 @@ class CIMultiStageOutput<T extends Record<string, unknown>> {

const formattedData = info.get ? info.get(this.data as T) : undefined
if (!formattedData) continue
const key = info.type === 'message' ? formattedData : info.label
const key = info.type === 'message' ? formattedData : `${info.label}: ${formattedData}`
Copy link
Member Author

Choose a reason for hiding this comment

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

key will include dynamic data so new output based on updated data will always be printed

Copy link
Contributor

Choose a reason for hiding this comment

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

The key is only the label for dynamic data because, otherwise, it will print on every single update - which is what we wanted to avoid

Run OCLIF_CI_UPDATE_FREQUENCY_MS=500 CI=true tsx examples/sf-specific/deploy.ts before and after your change to get an idea of the difference

Copy link
Contributor

Choose a reason for hiding this comment

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

Just thinking out loud here: I wonder if our best option is to add a new option to InfoBlock that will tell the CI output to always print - regardless of it the update timeout has been met or not.

So something like this:

{
  label: 'Successful',
  get: (data): string | undefined => {
     // formatting stuff here
  }
},
{
  label: 'Failed',
  alwaysPrintInCI: true,
  get: (data): string | undefined => {
     // formatting stuff here
  }
}

That way customers always get updates Failed but only intermittently get updates to Successful

Copy link
Member Author

Choose a reason for hiding this comment

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

Run OCLIF_CI_UPDATE_FREQUENCY_MS=500 CI=true tsx examples/sf-specific/deploy.ts before and after your change to get an idea of the difference

ohh I see now.

Just thinking out loud here: I wonder if our best option is to add a new option to InfoBlock that will tell the CI output to always print - regardless of it the update timeout has been met or not.

I like that option, I was struggling in PDR trying to find why updates were missing til I found about the throttle env affected it (which lead me to make this change first).
With the new option, the InfoBlock getters would need explicitly handle possible duplicates like this:
https://github.com/salesforcecli/plugin-deploy-retrieve/blob/fcc83af585eca9fc8f47db48a827a645e7fed116/src/utils/deployStages.ts#L161C1-L168C16

I'll add it in a bit 👍🏼

@@ -294,7 +294,7 @@ class CIMultiStageOutput<T extends Record<string, unknown>> {

const formattedData = info.get ? info.get(this.data as T) : undefined
if (!formattedData) continue
const key = info.type === 'message' ? formattedData : info.label
const key = info.type === 'message' ? formattedData : `${info.label}: ${formattedData}`
Copy link
Contributor

Choose a reason for hiding this comment

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

The key is only the label for dynamic data because, otherwise, it will print on every single update - which is what we wanted to avoid

Run OCLIF_CI_UPDATE_FREQUENCY_MS=500 CI=true tsx examples/sf-specific/deploy.ts before and after your change to get an idea of the difference

@cristiand391 cristiand391 changed the title fix(ci-output): properly cache dynamic info frames feat: add alwaysPrintInCI option Dec 13, 2024
@mdonnalley mdonnalley merged commit a23bf81 into main Dec 16, 2024
13 checks passed
@mdonnalley mdonnalley deleted the cd/fix-missing-dynamic-info-stage branch December 16, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants