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

Add GitHub status formatter #144

Merged
merged 9 commits into from
Apr 17, 2016
Merged

Add GitHub status formatter #144

merged 9 commits into from
Apr 17, 2016

Conversation

mknapik
Copy link
Contributor

@mknapik mknapik commented Apr 14, 2016

Solves #121.

The formatter creates one commit status per runner with information about issue counts.
Issues in status description are ordered by severity.

By default all Pronto Messages with level :warning or higher are considered a failed state for GitHub status (red status).
GithubStatusFormatter allows to override this behaviour by accepting :level_mapping option in the initializer (which is not supported when running the formatter directly with command line, e.g. pronto run -f github_pr_status).
There is no README info yet but I'll provide it once we agree on the interface and the way this formatter should work.

The result of running Pronto with the new formatter:
GithubStatusFormatter

@mmozuras Please let me know whether the PR adheres to the project conventions.
I got some RuboCop line to long warnings in specs, should I fix those?
Also I'm going to squash refactoring commits before merging.

module Formatter
class GithubStatusFormatter
def initialize(opts = {})
@level_mapping ||= opts.fetch(:level_mapping, {})
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it's worth having a way to override it. Let's leave it off for now 😄

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 reason for implementing this was that Reek was returning only warnings even though stuff like Doesn't depend on instance state (maybe move it to another class?) (UtilityFunction) sound pretty subjective to me. Now when I think about it, it'd probably be better to address the issue at mmozuras/pronto-reek than here.

I'll get rid of opts parameter for now.

@mmozuras
Copy link
Member

@mknapik amazing, thank you, honestly 👏 😄

Just address a couple of comments, add info to README and CHANGELOG and it's gonna get merged! 😄

@mknapik
Copy link
Contributor Author

mknapik commented Apr 16, 2016

@mmozuras Apart from adhering to your remarks I've also did some refactoring.
Additionally I renamed formatter cli name from github_pr_status to github_status.
Let me know what do you think.
I haven't squashed everything yet so you can review the changes easily.

Use `GithubStatusFormatter` to submit [commit status](https://github.com/blog/1227-commit-status-api):

```sh
$ GITHUB_ACCESS_TOKEN=token pronto run -f github_status -c origin/master
Copy link
Member

@mmozuras mmozuras Apr 16, 2016

Choose a reason for hiding this comment

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

I think that it's worth showing that multiple formatters can be used here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll add one more example.
Although I believe using multiple formatters is not documented anywhere else.

@mmozuras
Copy link
Member

mmozuras commented Apr 16, 2016

@mknapik looks good, just address my one last comment 😄

@aergonaut
Copy link
Member

@mknapik @mmozuras would it be too much to ask to have the status contexts formatted more like how other services format them? i.e. instead of "Pronto::Rubocop", something like "pronto/rubocop" or "lint/pronto/rubocop" to be more similar to how Travis CI uses "continuous-integration/travis-ci/pr"

@mknapik
Copy link
Contributor Author

mknapik commented Apr 17, 2016

@aergonaut Actually I had no idea what was the convention.
The docs use continuous-integration/jenkins and security/brakeman as examples.
I guess I can change it to pronto/$runner.

@mknapik
Copy link
Contributor Author

mknapik commented Apr 17, 2016

@mmozuras @aergonaut Regarding context names:
Do you think a simple function like runner.class.downcase.gsub('::', '/') is enough or should I implement something like ActiveSupport::Inflector#underscore?

The difference:

Pronto Runner downcase underscore
Pronto::Brakeman pronto/brakeman pronto/brakeman
Pronto::RailsBestPractices pronto/railsbestpractices pronto/rails_best_practices

@aergonaut
Copy link
Member

@mknapik looks good to me 😄

@mmozuras
Copy link
Member

@mknapik looks good, amazing contribution 👍 🙇

@mmozuras mmozuras merged commit 89219d4 into prontolabs:master Apr 17, 2016
@mknapik mknapik deleted the feature/github_status_formatter branch April 17, 2016 20:19
@mknapik
Copy link
Contributor Author

mknapik commented Apr 17, 2016

@mmozuras Thanks!
The gem is well written and contributing was a pleasure!

@kevinjalbert
Copy link
Contributor

This is awesome. Was trying to make it work using version 0.6.0, then realized that this isn't released yet 😉 .

I look forward to using it in the next version bump.

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

4 participants