Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix status check comment for timed out or failed checks #565

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

Merged
merged 7 commits into from
Sep 1, 2022
Merged

Fix status check comment for timed out or failed checks #565

merged 7 commits into from
Sep 1, 2022

Conversation

DanielNoord
Copy link
Contributor

Closes #564.

Split out the "succes" check from the timed out check so we can record both states.

@codecov
Copy link

codecov bot commented Jul 11, 2022

Codecov Report

Merging #565 (00cf6d3) into main (3e3588b) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #565   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         1012      1025   +13     
  Branches        71        72    +1     
=========================================
+ Hits          1012      1025   +13     
Impacted Files Coverage Δ
miss_islington/status_change.py 100.00% <100.00%> (ø)
tests/test_check_run.py 100.00% <100.00%> (ø)
tests/test_status_change.py 100.00% <100.00%> (ø)

elem in [None, "failure", "timed_out"]
for elem in all_check_run_conclusions
)
success = result["state"] == "success" and not failure
Copy link
Member

Choose a reason for hiding this comment

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

I would like to understand better what's going on here, and possibly capture this in a comment.
result["state"] seems to be the final outcome of all the checks combined. I assume that some of the optional checks might fail or timeout without affecting this final result. I'm also guessing that all_check_run_conclusions might include the optional checks, even though I'm not sure in which case the result is None.

If this assumptions are right, we have a few different possible outcomes:

  • the status check is done, and it's a success
  • the status check is done, it's a success, but some optional tests failed/timed out
  • the status check is done, but it's a failure
  • the status check is (not?) done, but it's a failure because of a timeout

We could therefore keep reporting the result["state"], and then elaborate as described above. We could also create two variables for failures and timeouts if we want a more accurate message.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Best example is python/cpython@40ccf13 from python/cpython#94734 where I originally spotted this bug.

The result['state'] comes from:
https://api.github.com/repos/python/cpython/commits/40ccf1321b819ce383d23841868004c18d368eb0/status

This refers to all checks from bedevere such as issue number and CLA signing.

failure is based on:
https://api.github.com/repos/python/cpython/commits/40ccf1321b819ce383d23841868004c18d368eb0/check-runs

These are all the Github Actions that get triggered. These do not include the checks that bedevere sets.

Thus, it is not so much about checks are required or optional, but rather about the source of the type of check.

Do we want to handle those differently?

Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason why the bedevere checks are listed separately from the other GitHub actions? Are they not considered checks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bedevere creates statutes, see https://docs.github.com/en/rest/commits/statuses

Since they are not triggered by a GitHub Action directly they need to be recovered from another endpoint. Honestly, the amount of different types of checks GitHub provides is quite long and their documentation is not optimal. Of the top of my head I can think of the terms actions, check suites, check runs, checks, statutes. There are probably more 😅

},
}
]
}
Copy link
Member

Choose a reason for hiding this comment

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

This object seem duplicated several time. Can it be defined once and reused? If not, could the "message" be trimmed and the object made more compact so that it takes 3 lines instead of several?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The pattern in these tests seems to be redefining. Objects like items could also be re-used.

Do you want me to refactor? Or follow the current style with a shorter message?

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we could refactor in a separate PR.

@ezio-melotti ezio-melotti merged commit 38b814f into python:main Sep 1, 2022
Comment on lines 109 to +117
if success:
emoji = "✅"
status = "it's a success"
if failure:
emoji = "❌"
status = "it's a failure or timed out"
else:
emoji = "❌"
message = f"Status check is done, and it's a {result['state']} {emoji} ."
status = "it's a failure"
Copy link
Contributor Author

@DanielNoord DanielNoord Sep 5, 2022

Choose a reason for hiding this comment

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

@ezio-melotti Now that I think about this, this seem to be faulty if ... if logic.

If success is True failure is None and thus we will always go into the third path.

I'll open a PR to address this tomorrow. I'll tag you for a review so we can fix this and remove confusion from the cpython repo.

@DanielNoord
Copy link
Contributor Author

Follow up PR in #576 😄

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.

Islington reports status check being a success but also reports ❌ when checks fail
2 participants