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

[CI-217] Step started event #825

Merged
merged 7 commits into from
Oct 25, 2022
Merged

[CI-217] Step started event #825

merged 7 commits into from
Oct 25, 2022

Conversation

tothszabi
Copy link
Contributor

Changes

  • Extracted the related step started logging bits from the print.go file and moved to the new log package
    • Refactored the whole thing because there was a lot of duplicated logic
    • Removed the old test because some of them was just printing the step header and was not asserting on anything
  • Added the possibility of logging this new step started event to the logger
    • Luckily the old step log only consisted from log lines with the same level. So the new implementation just generates the log lines and then the logger iterates over the array and prints them line by line.
    • Extended the existing integration test to handle the new event

cli/run_util.go Outdated
params := log.StepStartedParams{
ExecutionId: stepExcutionId,
Position: idx,
IdVersion: idVersion,
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we don't need both idVersion and title.
We should have one filed, which stores the Step Title to present. The value should follow this precedence:

  • override Step title (defined in the bitrise.yml)
  • original Step title (defined in the step.yml)
  • stepIDVersionComposite

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a great idea. I will update the code.

Copy link
Contributor Author

@tothszabi tothszabi Oct 21, 2022

Choose a reason for hiding this comment

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

The header title is much better now.

This was before:

+------------------------------------------------------------------------------+
| (0) script                                                                   |
+------------------------------------------------------------------------------+

+------------------------------------------------------------------------------+
| (1) git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone... |
+------------------------------------------------------------------------------+

+------------------------------------------------------------------------------+
| (2) certificate-and-profile-installer@1                                      |
+------------------------------------------------------------------------------+

And this is after the change:

+------------------------------------------------------------------------------+
| (0) Clear step outputs                                                       |
+------------------------------------------------------------------------------+

+------------------------------------------------------------------------------+
| (1) git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone... |
+------------------------------------------------------------------------------+

+------------------------------------------------------------------------------+
| (2) Certificate and profile installer                                        |
+------------------------------------------------------------------------------+

@@ -0,0 +1,58 @@
package log
Copy link
Contributor

Choose a reason for hiding this comment

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

so few codes compared to the previous implementation 😍

log/models.go Outdated
Title string `json:"title"`
Collection string `json:"collection"`
Toolkit string `json:"toolkit"`
StartTime string `json:"-"` // This value is only needed for the console logging.
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't we still need this for the log conversion (json->console)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No we do not because every json log will have a timestamp by default. We can use that time and print it as the step start time because the step execution starts after the step header is printed.

cli/run_util.go Outdated
}

// The composite step id is not useful for the user. So let's replace it with the original step title defined in the step.yml file.
if strings.HasPrefix(title, stepInfo.ID) && step.Title != nil && *step.Title != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it working if the step ID composite has the collection part too?

  • git::<repo_utrl>
  • https://github.com/bitrise-io/bitrise-steplib.git::script@1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch. Pushed a new commit with the updated logic.

@tothszabi tothszabi merged commit c4945d2 into master Oct 25, 2022
@tothszabi tothszabi deleted the CI-217-step-started-event branch October 25, 2022 08:28
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