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

Create Github Action #67

Open
atifsyedali opened this issue Nov 21, 2019 · 16 comments
Open

Create Github Action #67

atifsyedali opened this issue Nov 21, 2019 · 16 comments

Comments

@atifsyedali
Copy link

Would be great if we could use a Github Action instead of the app to push checks.

@SimenB
Copy link

SimenB commented Nov 22, 2019

Yes please! I'm playing around with using the built in problem matchers for tsc and eslint, and it works swimmingly: jestjs/jest#9223. Would be awesome to just stick an action in for test results as well 👍

@stefanbuck
Copy link

@SimenB are you aware of any existing Problem Matcher for Jest? The Jest output isn't really suitable for parsing using a RegExp or at least not that simple. I was thinking about writing a custom reporter to print a parser friendly output. How does this sound to you?

@SimenB
Copy link

SimenB commented Jan 7, 2020

The default jest output is certainly not suited. It should be a separate reporter (an idea might be that GitHub parses junit output?). Could probably reach out to GitHub about it - the js and ts templates they provide use Jest for testing so should be possible to work something out 🙂

@stefanbuck
Copy link

stefanbuck commented Jan 8, 2020

I proposed a similar idea using a json output and xpath actions/toolkit#260.

Internal we use Danger.js to attach the jest output as a PR comment, but using a Problem Matcher would be a much nicer solution

DangerJS screenshot

image

@stefanbuck
Copy link

Problem matchers are for parsing console output and are run line by line. In you case you want a file and the runner won't when to process the file. One option would be to write an action to process the file and create annotations.

actions/toolkit#260 (comment)

Mhhh I'm undecided wether a GitHub Action or a jest reporter that produces a parsable output is the way to go. @SimenB what's your thoughts on this?

@SimenB
Copy link

SimenB commented Jan 10, 2020

There shouldn't be an issue to create a reporter that outputs something a problem matcher can parse. I think that's a good idea, as we could ship it by default in Jest and automatically activate it if we detect we're running in github actions? If not, I think GitHub should provide some other built in thing to support lint/test tools etc to just output a file in a given format to a given place, and have GH itself deal with reporting it to the user without having to write a full action

@stefanbuck
Copy link

I tend to prefer a new reporter mainly because it doesn't involve GitHub roadmap prioritization 😉 I'll look into this and keep you updated.

@stefanbuck
Copy link

I started working on this and the first issue I'm facing is the limitation to a single line for the message field actions/toolkit#319. I guess there is not much we can do from our side to make the output useful in a single line!? Btw, should I raise a feature request in facebook/jest so we can continue the discussion there?

@SimenB
Copy link

SimenB commented Feb 20, 2020

@stefanbuck sorry, missed your last message. I still think a dedicated reporter makes more sense than a problem matcher.
However, we could probably output some json on a single line per test failure or something - would that be parseable?

@stefanbuck
Copy link

To be honest I think we need both. A reporter which produces a single log line for each failing test and a problem matcher which is able to consume this log format. A problem matcher is just a really slick wrapper around the Checks API which integrates really well into the GitHub UI. What's the alternative to Checks/Problem matchers?

@mattallty
Copy link

@SimenB @atifsyedali @stefanbuck
FWIW, I've been using another solution in https://github.com/mattallty/jest-github-action
The way it works is:

  • run jest with --testLocationInResults --json --outputFile=jest.results.json
  • then parsing jest.results.json to get failed tests location as well as generating a markdown table of coverage
  • Using the Check API to create annotations, and Issue Comments API to create a comment with coverage data

Seems to work great - I can't just get coverage data when some tests are failing.

@stefanbuck
Copy link

I do something similar with danger.js, but I really want to see this happening with problem matcher so I don't have to maintain another service.

Isn't the check API limited to GitHub Apps?

The Checks API functionality is available exclusively to your GitHub Apps.
https://developer.github.com/v3/checks/

@hipstersmoothie
Copy link
Owner

Any GitHub action has access to an app token so they can make checks. Doesn't that work?

@mattallty
Copy link

I can confirm it's working

@stefanbuck
Copy link

Looks like the multiline issue I was facing can be solved by url encoding \n actions/toolkit#193 (comment)

@stefanbuck
Copy link

stefanbuck commented Apr 24, 2020

@SimenB I finally made it working

image

I ended up writing a custom reporter which produces an output which is follows a certain pattern. Please checkout this PR for details https://github.com/stefanbuck/jest-matcher/pull/2/files

How should we proceed with this? Do you think it's suitable to make this reporter part of the Jest core and active it whenever a GitHub Action env is detected?

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

5 participants