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
Use danger to report test results in PR comment #19436
base: trunk
Are you sure you want to change the base?
Conversation
43e9f00
to
8485a7b
Compare
👋 Just leaving a note that I was pinged as a reviewer because the PR touches a UI tests related file. I guess this is a temporary change in the tests to make them fail for easier testing of the PR. I won't be marking the PR as reviewed by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth validating with the rest of the team if Danger
is the right tool for that —especially after @jkmassel 's recent post in paaHJt-3NR-p2 — as opposed to have the CI step run a script to parse the .junit
file (similar to what is already done using this annotate_test_failures
action from bash-cache-buildkite-plugin
), and expend said action if we want to use comment_to_pr
to do the PR comment (in addition to the buildkite-agent annotate
that it already does)
My gut would be that we might want to prefer using our existing annotate_test_failures
, and consider expanding / improving it, to also support optionally doing a comment_on_pr
in addition to just the Buildkite annotation, rather than rely on Danger.
Especially given annotate_test_failures
is already called by this repo's pipeline during our various unit test .sh scripts, so expanding that action to just add comment_on_pr
will likely be a trivial change. And it doesn't require all three test steps (unit-tests
, ui-tests-iphone
and ui-tests-ipad
) to finish before annotating, nor to re-download the artefacts after the fact, as each annotation is done at the end of the respective CI step 💪
To be fair, using Danger-junit
has its merits (including the fact that the logic of the parsing and comment rendering is already made and we don't have to reinvent the wheel); but Jeremy's arguments on when to use Danger vs a CI custom step would make me tend to use the latter for this situation (especially since we already have a bash-cache action for that mostly ready), and also the odd thing with using Danger is that it will do multiple things at once as the Dangerfile
evolves, as opposed to having dedicated and isolate-able steps for each aspect we'd want to check (Rubocop, Junit, …), which would allow us to do more fine-grained step dependencies (e.g. not having to wait for the Unit tests steps to finish to have Rubocop being able to run). As can be seen by your changes that had to rename rubocop-via-danger.sh
into danger.sh
because it now does more than one thing. 🤷
Dangerfile
Outdated
junit.parse "#{file}.junit" | ||
junit.report |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a risk that each junit.report
could override the comment made by a previous report? e.g. if unit-tests
have failures and thus make Danger generate a comment to report those, but ui-tests-iphone
also have failures, will the Danger comment for those override the previous comment made for unit-tests
? Or will it append to it? Or will it report it in a separate comment each time?
You can test the changes in Jetpack from this Pull Request by:
|
You can test the changes in WordPress from this Pull Request by:
|
Good point. I see this as a big downside of current setup, it's always good to get a faster feedback from PR checks. We probably need to use multiple Dangerfiles. But I'm keen to hear @jkmassel 's thoughts on this. I had read the P2 post about danger, I don't see there is any recommendation around this kind of reporting feature. |
1254ff7
to
096eeac
Compare
@@ -6,6 +6,7 @@ gem 'cocoapods', '~> 1.11' | |||
gem 'commonmarker' | |||
gem 'danger', '~> 8.6' | |||
gem 'danger-rubocop', '~> 0.10' | |||
gem 'danger-junit', '~> 1.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 | Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem danger-junit should appear before danger-rubocop . |
Tests:
Generated by 🚫 Danger |
Tests:
Generated by 🚫 Danger |
Tests:
Generated by 🚫 Danger |
To me it's more like:
Imho, this is also one of the reasons why things like "zipping test result and attaching them as artefacts", "reporting test failures as Buildkite annotations" and the likes are already commands that are part of the And reporting those test failures as a PR comment feels very similar, feature- and goal-wise, to reporting those test failures as Buildkite Annotations, so that's why I'd suggest to do them in a similar manner, either by having a separate dedicated In fact, the message in the PR comment we'd want… can actually be the exact same message that Alternatively, the Whatever the solution, generating the comment directly from the That said, that's only my own and personal opinion 😛 so let's see what @jkmassel thinks 🙂 |
Yeah, I agree that execution and reporting should be in the same place, which would simplify the scripts and give us faster feedback during the CI run. And I've updated this PR to use this approach. But I would argue that it's not necessary to rule out using a thirdparty tool like danger to do the reporting. That's what I most curious about: when should we implement it ourselves and when should we use a thirdparty tool. DIY vs using thirdparty tools is probably a too broad question to answer (unless there are some principles that we would want to adhere to), I feel like it's more easy to answer this question when thinking about a concrete problem. Like this one here, if we'd like to report test failures in PRs, how do we want it to look like? Can we implement this ideal result using a tool like danger? If not, maybe we should build it ourselves so that we get to have full control on the result. But on the other side, does the cost of building our solution outweighs using a thirdparty solution and having a less than ideal result? I don't think the result we see here in this PR(test failures are reported in three separate comments) is ideal. I'd want just one single comment containing all test failures, but at the same time the reporting should be done along with the test execution, not in a dedicated danger step. If that's the result we'd want, probably we have no choice but implementing it ourselves.
Agreed. This step already parses the test result, might as well add a option like
There is a small issue here. What we want is having one single comment to report test failures. The script either adds a new comment or update an existing one since we don't want to keep adding comments to report failures in new test runs. Danger uses a |
That's totally fair and a good point.
Yeah, I think that if our
Good point. That's why I mentioned using the
But I can see how that can then become more convoluted as using Danger directly, so… ⚖️ |
Oh I see, sorry I missed that. Got it confused with the one in the bash-cache repo 🥲 |
@crazytonyli I'm going to bump this to the next release because we'll be code freezing 21.0 today and it seems like this needs a bit more touches. Besides, it's a GitHub tooling PR, so it doesn't really matter which release it lands in 😄 |
I wonder whether we could benefit from a dedicated milestone for this kind of PRs, or if it's simpler to stick to the standard process and to do a milestone bump in edge-case scenario like this one. 🤔 ... currently leaning towards "stick to the standard" process, so we have one less question to answer when choosing the milestone. I.e. we won't have to ask "is this a PR that doesn't affect the user-facing application code". |
What I also like in having a milestone even for Tooling and Core PRs is that:
|
Use danger-junit to report test failures in GitHub PRs, which can save us a couple of clicks to view the test failures if there is any. Let me know if you think this is not a good idea.
Regression Notes
Potential unintended areas of impact
None.
What I did to test those areas of impact (or what existing automated tests I relied on)
None.
What automated tests I added (or what prevented me from doing so)
None.
PR submission checklist:
RELEASE-NOTES.txt
if necessary.