Skip to content

Fix run view --log when steps have slashes#3445

Merged
samcoe merged 4 commits intocli:trunkfrom
adamslc:log_fix
Apr 20, 2021
Merged

Fix run view --log when steps have slashes#3445
samcoe merged 4 commits intocli:trunkfrom
adamslc:log_fix

Conversation

@adamslc
Copy link
Contributor

@adamslc adamslc commented Apr 17, 2021

Closes #3444, which incorrectly diagnosed the issue.

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix! Good catch 🌟

for j, step := range job.Steps {
filename := fmt.Sprintf("%s/%d_%s.txt", job.Name, step.Number, step.Name)
filename := fmt.Sprintf("%s/%d_%s.txt", job.Name, step.Number,
strings.ReplaceAll(step.Name, "/", ""))
Copy link
Contributor

@mislav mislav Apr 19, 2021

Choose a reason for hiding this comment

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

This looks good as a fix! I have a couple of additional asks:

  1. Could the step-to-filename–generating logic be extracted into a separate method?
  2. Could we have some tests exercising that method?
  3. There are possibly some characters other than / that don't translate well to filenames (for example: the : character). @vilmibm do you think it would be possible/worthwhile to take a look at how our platform generates filenames and match that logic in our codebase? Or, could we somehow avoid guessing filename names altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(1) is done. (2) I don't speak go, so you will have to guide me through the testing framework. Or feel free add the tests yourself. (3) Slashes in particular are a quite serious bug because any step of the form uses: some-org/some-action@v1 will fail unless a name is specified. For example, run view --log is useless for reviewing test failures on virtually every Julia lang repo because of this issue. So, my preference is that this is merged and tagged quickly.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mislav @adamslc I think we can avoid special character handling all together by just matching on job name and step number. The job name only allows -, _, and alphanumeric characters and the step number is an integer so we shouldn't have to recreate the filename generating logic that actions uses and what characters it strips out. I wrote some code that changes this logic and adds tests that I will commit to this PR if that is okay with everyone?

Copy link
Contributor

Choose a reason for hiding this comment

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

@adamslc No worries; thanks for taking us this far.
@samcoe Looks great! Thanks for devising the new approach

@samcoe samcoe requested review from a team and mislav April 19, 2021 19:25
@vilmibm vilmibm mentioned this pull request Apr 19, 2021
6 tasks
@samcoe samcoe merged commit aea6163 into cli:trunk Apr 20, 2021
@adamslc adamslc deleted the log_fix branch April 20, 2021 15:14
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.

run view --log fails for certain step names

3 participants