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

initial implementation of a github actions reporter #1678

Merged
merged 15 commits into from Mar 30, 2022

Conversation

devoncarew
Copy link
Member

Creating as a draft PR for now - I want to play with the output some.

@devoncarew
Copy link
Member Author

devoncarew commented Mar 22, 2022

OK, I think this is ready for review now. Here's the current output:

  • everything (tests, loading diagnostics (loadSuite), setUpAll and tearDownAll methods) gets wrapped in groups
  • if there's no content (errors or messages) in the synthetic (non-test) groups, they're not emitted
  • test successes have ✅ icons; failures have ❌ icons
  • synthetic groups that pass use icons that are different from tests so they're not confused with user authored tests; ⏺
  • skipped tests have ❎ icons; I played with many different available icons here - this seemed like the best; many others were false starts - (on github were rendered w/ a red color - indicating a failure, in a different width than the other icons, making the left edge of the output ragged, ...)
  • we print a success message at the end with 🎉; if a failure, we use the github ::error:: output

Some pics for the output below; others can be examined from the 'Checks' tab.

The tests for this were adopted from the ones for the other reporters. Some common ones were removed - ones that tested other functionality but that used the reporter to do that (the expanded and compact reporters still have these tests). And tests added for the github specific UI.

One thing likely to address before landing is that because of the way we collect output until a test is complete, we can re-sequence the order of stdout and error messages.

Screen Shot 2022-03-20 at 10 23 49 AM

Screen Shot 2022-03-20 at 10 23 13 AM

Screen Shot 2022-03-20 at 10 22 48 AM

Screen Shot 2022-03-17 at 9 30 11 AM

@devoncarew devoncarew marked this pull request as ready for review March 22, 2022 21:50
@devoncarew
Copy link
Member Author

This reporter also doesn't have the:

Consider enabling the flag chain-stack-traces to receive more detailed exceptions.
For example, 'dart test --chain-stack-traces'.

message at the end of every run (I'm not quite sure what that is, or if there's not some other way to let users know).


class _GithubHelper {
// Char sets avilable at https://www.compart.com/en/unicode/.
static const String passed = '✅';
Copy link
Member

Choose a reason for hiding this comment

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

[nit] I have a slight preference for '\u2705', but I'm also curious what other folks think.

@grouma @jakemac53 @lrhn ?

Copy link
Member

Choose a reason for hiding this comment

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

'\u2705' is NOT super readable 🤷 – why the preference?

Copy link
Member

Choose a reason for hiding this comment

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

Historically they've not worked well in some editors and they aren't easy to type.
Mostly we just haven't used them in source strings that I recall, and I've only seen the \u version used.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed these to use the unicode escaping form.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the late response. I think I prefer \u2705 as a constant variable with an appropriate name, e.g. _checkMark. That way it's readable and will work with all tools / editors.

Copy link
Member

Choose a reason for hiding this comment

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

One point against the '\u' form is that the Java and JavaScript style guides at google both seem to encourage it when it's "easier to read", which I think does apply here.
https://google.github.io/styleguide/javaguide.html#s2.3.3-non-ascii-characters
https://google.github.io/styleguide/jsguide.html#non-ascii-characters

C++ mentions that no user facing strings should be in source, which isn't really a practice for us, but they do still specifically allow non-ascii in source.
https://google.github.io/styleguide/cppguide.html#Non-ASCII_Characters

I'm very willing to accept that my preference is old-fashioned and choose a more modern style for our source code if that's the consensus - I mostly just wanted to double check that we weren't introducing a new pattern that would become standard without thinking it through.

@munificent - do you think this is something we should cover in Effective Dart?

Copy link
Contributor

Choose a reason for hiding this comment

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

Fwiw for me having the actual characters is better, I have no idea what \u2705 is and would have to look it up. I don't really see any downside to using the actual character and you have the advantage of seeing it visually.

Copy link
Member

Choose a reason for hiding this comment

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

@munificent - do you think this is something we should cover in Effective Dart?

Seems pretty nit-picky to me, but if you think it's worth it, I'm persuadable.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think - for readability of this particular piece of code - I'm going to switch back to having the actual char in the string. It's not causing issues w/ tooling, and makes it much easier to read this bit od code.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, I'm generally comfortable with having non-ASCII characters inside Dart comments and string literals. It's entirely well-specified by the language and there's nothing intrinsically better about Unicode codepoints whose value happens to be less than 128. (I, of course, avoid homoglyphs and other nasty ones.)

Copy link
Member

@kevmoo kevmoo left a comment

Choose a reason for hiding this comment

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

Should update the changelog describing the change

Should also add something to the readme explaining how GitHub CI detection is handled – so folks aren't confused.

Looks like it's just auto-magically changed default (👍 ), so it'd be good to document that the user can override the behavior by being explicit w/ the --reporter option

@devoncarew
Copy link
Member Author

Should update the changelog describing the change

Should also add something to the readme explaining how GitHub CI detection is handled – so folks aren't confused.

Looks like it's just auto-magically changed default (👍 ), so it'd be good to document that the user can override the behavior by being explicit w/ the --reporter option

Makes sense - I updated the changelog and added a section about test reporters to the readme.

I also rev'd the version of package:test to a pre-release version.

@devoncarew
Copy link
Member Author

In terms of the package:test version, I rev'd this from 1.20.2 to 1.21.0-dev.

pkgs/test/README.md Outdated Show resolved Hide resolved
@devoncarew
Copy link
Member Author

In terms of the package:test version, I rev'd this from 1.20.2 to 1.21.0-dev.

cc @natebosch, @jakemac53 re: the version we should use here

@jakemac53
Copy link
Contributor

Minor version bump SGTM.

}
}

class _GithubHelper {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just make this a abstract class w/ everything static?

Planning on having state at some point?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or just make these top level private members

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to keep these grouped with the other github markup code (startGroup(), error(), ...) as they're related. No real opinions other than that; static members works for me.

tearDownAll(() { print('two'); });
test('test 1', () {});
});''', '''
::group::⏺ one (setUpAll)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use ✅ for these as well? This looks to me like a warning indicator.

I would consider using this icon for skipped tests actually?

Copy link
Member Author

Choose a reason for hiding this comment

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

There's some (incomplete) discussion of the icons here: #1678 (comment). I did play around w/ a lot of different icons, including just editing the dom of the 'checks' page to see how things would look.

For this icon, I don't want to use the same icon as for a regular test; I think it's valuable for 6 users test ==> 6 test icons in the output. I'd like the additional test plumbing to have distinct icons from the passed tests. Additionally, the icon should be the same width as the other icons - so the LHS isn't ragged - and shouldn't use a color which users already attach some meaning to (red, yellow, ...).

Other similar unicode chars can be found here: https://www.compart.com/en/unicode/.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about ☑? That way it is different but still indicates success (it is a test that can fail). And it isn't a color that indicates a warning. My main complaint about the current choice is the orange color indicates a warning to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've been checking the rendering in-line in the test results, just so we're getting the font that github uses there. What I see for the current 'non-test' group char (⏺) is:

Screen Shot 2022-03-29 at 9 45 09 AM

Which - for me - is a gray color, not an orange color. I do agree that orange (or red, or yellow) would indicate a failure or problem of some kind to the user - something we should avoid unless there's an actual issue.

Here's what the ☑ char looks like in-line in test results (note the different size and style):

Screen Shot 2022-03-29 at 9 40 14 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh weird... ya its orange on a chromebook :(. I am on my mac now and I see it as a greyish blue. These were both looking at the github UI, so the color is still different based on the platform and not the terminal.

That is pretty unfortunate. @munificent was suggesting using an older check mark symbol that is just the check mark (no background) and then coloring the check mark explicitly?

Copy link
Contributor

Choose a reason for hiding this comment

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

The green checkmark seems to be fairly consistent so I would suggest just rendering using that. Yes you will see a different number of lines with green checkmarks than passed tests reported at the bottom, but personally that doesn't bother me (the text can still make it obvious that it is a setUpAll).

Copy link
Contributor

Choose a reason for hiding this comment

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

I also think we can definitely launch this with any of the suggested choices, and revist later.

Copy link
Member Author

Choose a reason for hiding this comment

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

that is just the check mark (no background) and then coloring the check mark explicitly?

That would be great if we could do it :) From experimentation, we can't use ansi colors in the summary line of a group here.

I also think we can definitely launch this with any of the suggested choices, and revist later.

Let's do that then; I don't think there's an idea set of icons unfortunately - I've experimented w/ many. I'll change to the green checkmark, and we can iterate as needed.

}
}

class _GithubHelper {
Copy link
Contributor

Choose a reason for hiding this comment

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

Or just make these top level private members

pkgs/test_core/lib/src/util/io.dart Outdated Show resolved Hide resolved
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.

None yet

6 participants