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

fix(workflow-hook): multiline output formatting #3425

Merged
merged 5 commits into from
May 30, 2023

Conversation

X-Guardian
Copy link
Contributor

what

  • In the pre and post workflow hook runners, the OutputHandler.SendWorkflowHook out parameter has the line feeds (\n) replaced with carriage return then line feed (\r\n).

why

  • So that the pre and post workflow hook multiline output is formatted correctly.

tests

repos.yaml

repos:
- id: /.*/
  pre_workflow_hooks:
    - run: |
        echo "pre workflow test line 1a" && echo "pre workflow test line 1b"
        echo "pre workflow test line 2a" && echo "pre workflow test line 2b"
  post_workflow_hooks:
    - run: |
        echo "post workflow test line 1a" && echo "post workflow test line 1b"
        echo "post workflow test line 2a" && echo "post workflow test line 2b"

Output Screenshots

Pre Workflow Hook

image

Post Workflow Hook

image

Logs

Logs
{"level":"info","ts":"2023-05-21T16:27:55.106+0100","caller":"runtime/pre_workflow_hook_runner.go:77","msg":"successfully ran \"echo \\\"pre workflow test line 1a\\\" && echo \\\"pre workflow test line 1b\\\"\\necho \\\"pre workflow test line 2a\\\" && echo \\\"pre workflow test line 2b\\\"\\n\" in \"/root/.atlantis/repos/X-Guardian/atlantis-test/1/default\"","json":{"repo":"X-Guardian/atlantis-test","pull":"1"}}
{"level":"info","ts":"2023-05-21T16:27:56.381+0100","caller":"events/project_command_builder.go:399","msg":"found no atlantis.yaml file","json":{"repo":"X-Guardian/atlantis-test","pull":"1"}}
{"level":"info","ts":"2023-05-21T16:27:56.382+0100","caller":"events/project_command_builder.go:403","msg":"automatically determined that there were 0 projects modified in this pull request: []","json":{"repo":"X-Guardian/atlantis-test","pull":"1"}}
{"level":"info","ts":"2023-05-21T16:27:57.851+0100","caller":"runtime/post_workflow_hook_runner.go:77","msg":"successfully ran \"echo \\\"post workflow test line 1a\\\" && echo \\\"post workflow test line 1b\\\"\\necho \\\"post workflow test line 2a\\\" && echo \\\"post workflow test line 2b\\\"\\n\" in \"/root/.atlantis/repos/X-Guardian/atlantis-test/1/default\"","json":{"repo":"X-Guardian/atlantis-test","pull":"1"}}

references

@X-Guardian X-Guardian requested a review from a team as a code owner May 21, 2023 15:40
@github-actions github-actions bot added the go Pull requests that update Go code label May 21, 2023
@nitrocode nitrocode added this to the v0.24.0 milestone May 22, 2023
@nitrocode nitrocode added the needs tests Change requires tests label May 22, 2023
@nitrocode nitrocode changed the title fix: Workflow Hook Scripts Multiline Output Formatting fix(workflow-hook): multiline output formatting May 22, 2023
@nitrocode nitrocode modified the milestones: v0.24.0, v0.25.0 May 22, 2023
@X-Guardian X-Guardian requested a review from nitrocode May 22, 2023 17:31
Copy link
Member

@nitrocode nitrocode left a comment

Choose a reason for hiding this comment

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

Thank you for adding tests. Please see the last comment regarding changing sh to bash

@nitrocode nitrocode removed the needs tests Change requires tests label May 23, 2023
@X-Guardian X-Guardian requested a review from nitrocode May 23, 2023 07:34
nitrocode
nitrocode previously approved these changes May 23, 2023
@nitrocode nitrocode modified the milestones: v0.25.0, v0.24.1 May 23, 2023
jamengual
jamengual previously approved these changes May 23, 2023
@nitrocode
Copy link
Member

Please resolve conflicts @X-Guardian

@nitrocode nitrocode modified the milestones: v0.24.1, v0.25.0 May 24, 2023
@X-Guardian X-Guardian dismissed stale reviews from jamengual and nitrocode via f994f67 May 24, 2023 08:19
@X-Guardian X-Guardian force-pushed the workflow-multiline-output-fix branch from 050db7d to f994f67 Compare May 24, 2023 08:19
@nitrocode nitrocode modified the milestones: v0.25.0, v0.24.2 May 25, 2023
@nitrocode nitrocode merged commit 50b1e48 into runatlantis:main May 30, 2023
mtavaresmedeiros pushed a commit to mtavaresmedeiros/atlantis that referenced this pull request Jul 3, 2023
* Fix Workflow Hool Scripts Multiline Output

* Update unit tests

* revert bash cmd

* Fix tests
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* Fix Workflow Hool Scripts Multiline Output

* Update unit tests

* revert bash cmd

* Fix tests
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* Fix Workflow Hool Scripts Multiline Output

* Update unit tests

* revert bash cmd

* Fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiline Output in pre and post Workflow Hook Scripts is not Correctly Formatted
3 participants