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

[terraform] No error on failed github comment #155

Open
mccall114 opened this issue Aug 27, 2020 · 0 comments
Open

[terraform] No error on failed github comment #155

mccall114 opened this issue Aug 27, 2020 · 0 comments

Comments

@mccall114
Copy link

If a terraform plan fails to post a comment to github, it doesn't return an error code, so CircleCI does not recognize this as a failed job:

Plan: 1 to add, 114 to change, 6 to destroy.
Traceback (most recent call last):
  File "/tmp/github.py", line 178, in <module>
    comment.plan = sys.stdin.read().strip()
  File "/tmp/github.py", line 136, in plan
    self._update_comment()
  File "/tmp/github.py", line 164, in _update_comment
    response.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://api.github.com/repos/<redacted>
CircleCI received exit code 0

Without an error returned, a reviewer may approve the PR without realizing a plan is missing from the PR comments. With an error returned, a github status check for the CircleCI job could show that the plan failed to post, ensuring the output is reviewed.

Would like to add exit 1 here:

    if ! python3 /tmp/github.py plan <plan.txt; then
        echo "Error adding comment to PR"
    fi
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

No branches or pull requests

1 participant