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

Show sample citations & bib entries for PRs that validate #13

Open
adam3smith opened this issue Apr 26, 2019 · 44 comments

Comments

Projects
None yet
3 participants
@adam3smith
Copy link
Member

commented Apr 26, 2019

Just going to do a simple mock-up:
Currently Sheldon posts this when a PR gets opened:

Awesome! You just created a pull request to the Citation Styles Language styles repository. One of our human volunteers will try to get in touch soon (usually within a week). In the meantime, I will run some automated checks. You should be notified of the results in a few minutes.

If you haven't done so yet, please make sure your style validates and follows all our other Style Requirements.

To update this pull request, visit the "Files changed" tab above, and click on the pencil icon (see below) in the top-right corner of your style to start editing.

If you have any questions, please leave a comment and we'll get back to you. While we usually respond in English, feel free to write in whatever language you're most comfortable.

Followed by this when the PR passes our tests:

😃 Your submission passed all our automated tests.

I'd suggest leaving the first message as is, but would like the second one to be something like:

😃 Your submission passed all our automated tests.

Your style will produce the following output:
Citations: (Campbell & Pedersen, 2007; Mares, 2001)

Bibliography:
Campbell, J. L., & Pedersen, O. K. (2007). The varieties of capitalism and hybrid success. Comparative Political Studies, 40(3), 307–332. https://doi.org/10.1177/0010414006286542
Mares, I. (2001). Firms and the welfare state: When, why, and how does social policy matter to employers? In P. A. Hall & D. Soskice (Eds.), Varieties of capitalism. The institutional foundations of comparative advantage (pp. 184–213). New York: Oxford University Press.

Where citations and bibliography are generated from the new style (I was thinking we could have the data in a public Zotero group and simply use API calls to Zotero, but agnostic about the method to be used.

@rmzelle

This comment has been minimized.

Copy link
Member

commented Apr 26, 2019

(and, as a second optional layer on top, a diff versus an appropriate comparison style could also be very useful, e.g. using something like https://github.com/kpdecker/jsdiff, which can generate output such as

image
)

@retorquere

This comment has been minimized.

Copy link

commented May 6, 2019

What would be the benefit to pulling the data from a public group vs having it in the text fixtures?

@adam3smith

This comment has been minimized.

Copy link
Member Author

commented May 6, 2019

This was purely pragmatic -- having them in the fixture is fine too. I was thinking of going through the Zotero API as one option, and for that purpose having them items available in a group makes getting the bib possible with a single GET call.

@retorquere

This comment has been minimized.

Copy link

commented May 6, 2019

Alright, no major difference between the two anyhow. So, the main ask here is to

  1. Render a citation/bibliography with the PR
  2. Render a citation/bibliography from master
  3. Diff them

(with the rendering done using citeproc-js I assume)

?

@adam3smith

This comment has been minimized.

Copy link
Member Author

commented May 9, 2019

Yes, I think that's basically it. I think we'll only want to do this when the other tests pass, though.

@retorquere

This comment has been minimized.

Copy link

commented May 9, 2019

Right. I'm making some headway, but citeproc is a little sparsely documented, so I'm going through their test cases to piece things together.

@retorquere

This comment has been minimized.

Copy link

commented May 9, 2019

What is the relation between the spec tests in the styles repo and the test-suite repo?

@retorquere

This comment has been minimized.

Copy link

commented May 11, 2019

Alright, I have diffs rendering, but citeproc in its various incarnations could really do with better documentation. Oy vey. I've stuck to citeproc-ruby because the output really shouldn't differ from citeproc-js and the existing tests used Ruby.

@adam3smith

This comment has been minimized.

Copy link
Member Author

commented May 12, 2019

Sorry, hadn't seen the question above: the test-suite tests correct citeproc behavior and has no relationship to the styles repo. Every test includes its own style.

@retorquere

This comment has been minimized.

Copy link

commented May 13, 2019

Any thoughts on what to use as the items to render?

@adam3smith

This comment has been minimized.

Copy link
Member Author

commented May 13, 2019

Here's a set of four that I like (recycled from the CSL editor) https://gist.github.com/adam3smith/7f0c65f116d5e17df0c23901198f42c7

@retorquere

This comment has been minimized.

Copy link

commented May 16, 2019

It's been a while since I used Ruby -- how are describe et al brought into the current namespace in styles_spec.rb? I intended to use an after(:all) hook, but rspec complains it can't find after.

@retorquere

This comment has been minimized.

Copy link

commented May 16, 2019

Ah never mind, I can just use travis hooks.

@retorquere

This comment has been minimized.

Copy link

commented May 16, 2019

I'm still not happy with the way things look when added as a comment. I've put up a sample here (apologies for the junk PR I accidentally opened on the actual styles repo)

@adam3smith

This comment has been minimized.

Copy link
Member Author

commented May 16, 2019

What are you not happy with? You could maybe quote it as in the examples above, but I think functionally this is very nice already

@retorquere

This comment has been minimized.

Copy link

commented May 16, 2019

I've added a 2nd sample that quotes it. It still looks a little crowded to me, but if it's good enough for you guys, that's what counts.

I'm still playing with diffy to output decent looking diffs, but GH comments are pretty narrow and it gets unreadable fast. Differ does inline colored diffs which are easier to read, but the library hasn't seen updates in 8 years, and issues on the repo don't get picked up. I'm hesitant to bake in a tech debt, OTOH, it does work.

@retorquere

This comment has been minimized.

Copy link

commented May 16, 2019

Can anyone point me to a style that changed in a way that the sample references might show a difference in rendering? The random samples I looked at did stuff like et-al fixes that wouldn't trigger on the number of authors in the samples, or for other reasons showed no differences.

@adam3smith

This comment has been minimized.

Copy link
Member Author

commented May 16, 2019

Here are two that would show up in diffs, though I think only for the journal article in both cases:
citation-style-language/styles#4037
citation-style-language/styles#4064

@adam3smith

This comment has been minimized.

Copy link
Member Author

commented May 16, 2019

I like the quoted look -- once we add some surrounding text, I think that'll be great.

@retorquere

This comment has been minimized.

Copy link

commented May 16, 2019

Alright - you could start thinking about what you want to show when the render differs and when not.

I could perhaps have the rspec tests only test the changed files in a PR, but there are two sets of styles being tested, and I don't understand the difference between them.

@retorquere

This comment has been minimized.

Copy link

commented May 16, 2019

Alright, I've added a new sample with 3 changes; one where a style changed but the output did not, one where the style changed and the output also changed, and one where a new style was added.

Old or not, differ is the only one that I could find that did char-by-char coloration of diffs. Thoughts? Also thoughts on what the diff should diff? Text diffs are going to be more readable than markup diffs, but then markup changes would be lost in the report.

@retorquere

This comment has been minimized.

Copy link

commented May 16, 2019

I mean I see tests on "dependents" and "independents" but I don't know what those terms mean in this context.

@rmzelle

This comment has been minimized.

Copy link
Member

commented May 18, 2019

there are two sets of styles being tested, and I don't understand the difference between them.
...
I mean I see tests on "dependents" and "independents" but I don't know what those terms mean in this context.

Are you familiar with dependent CSL styles at all (like https://github.com/citation-style-language/styles/blob/master/dependent/nature-biotechnology.csl)? Dependent CSL styles inherit their style format from the referenced "independent-parent", and are heavily used for large publishers like Elsevier and Springer Nature that have thousands of journals that only use a handful of distinct citation formats. They're stored in the "dependent" directory of the "styles" repo. See also https://docs.citationstyles.org/en/stable/specification.html#file-types.

differ is the only one that I could find that did char-by-char coloration of diffs.

jsdiff does too (although it currently can't diff markup differences). See http://incaseofstairs.com/jsdiff/.

@rmzelle

This comment has been minimized.

Copy link
Member

commented May 18, 2019

It still looks a little crowded to me

Especially if we envision rendering citations for every commit in a pull request, we might also want to collapse things a bit, e.g.:

Changed: apa.csl

(“CSL search by example,” 2012; Hancké, Rhodes, & Thatcher, 2007)
(Fenner et al., 2019; Mares, 2001)

CSL search by example. (2012). Retrieved December 15, 2012, from Citation Style Editor website: http://editor.citationstyles.org/searchByExample/
Fenner, M., Crosas, M., Grethe, J. S., Kennedy, D., Hermjakob, H., Rocca-Serra, P., … Clark, T. (2019). A data citation roadmap for scholarly data repositories. Scientific Data, 6(1), 28. https://doi.org/10.1038/s41597-019-0031-8
Hancké, B., Rhodes, M., & Thatcher, M. (Eds.). (2007). Beyond varieties of capitalism : Conflict, contradiction, and complementarities in the European economy. Oxford and New York: Oxford University Press.
Mares, I. (2001). Firms and the welfare state: When, why, and how does social policy matter to employers? In P. A. Hall & D. Soskice (Eds.), Varieties of capitalism. The institutional foundations of comparative advantage (pp. 184–213). New York: Oxford University Press.

(using <details/> per https://gist.github.com/joyrexus/16041f2426450e73f5df9391f7f7ae5f and dear-github/dear-github#166)

@retorquere

This comment has been minimized.

Copy link

commented May 18, 2019

Are you familiar with dependent CSL styles at all?

Nope.

jsdiff does too (although it currently can't diff markup differences). See http://incaseofstairs.com/jsdiff/.

Turns out GH comments don't allow coloration. It's possible to do line-by-line coloration by using the diff format, but from my experience that's only of limited use for CSL styles, because I figure you'd generally want to know what changed in the line. But it's all we're going to get.

@retorquere

This comment has been minimized.

Copy link

commented May 18, 2019

I've put up two new samples, one which does line-by-line diffs of html, the other of markdownified html.

@retorquere

This comment has been minimized.

Copy link

commented May 18, 2019

Still working on getting the rspec failure output

@rmzelle

This comment has been minimized.

Copy link
Member

commented May 19, 2019

I like the line-by-line diffs of HTML best. HTML tags are easier to spot than markdown markup.

Maybe you could tweak the summary labels a little as well? E.g.:

apa.csl (modified style; unchanged output for sample items)
international-journal-of-climatology.csl (modified style; changed output)
junk.csl (new style)

(@adam3smith, let me know if you think that's an improvement)

@rmzelle

This comment has been minimized.

Copy link
Member

commented May 19, 2019

And did you already put a limit on the number of styles you're rendering? It's not uncommon to have the occasional pull request that touches several hundred or even thousands of styles, so limiting the render to e.g. no more than 10 styles would be a good idea.

And assuming you'll be handling dependent CSL styles as well, it might be good to:

  1. if you reach the limit of styles to render (per above), give preference to independent CSL styles over dependent styles for the styles you do render.
  2. We also sometimes replace an independent style by a dependent one, and vice versa. So it would be good if e.g. a replacement of https://github.com/citation-style-language/styles/blob/master/dependent/nature-biotechnology.csl by https://github.com/citation-style-language/styles/blob/master/nature-biotechnology.csl would be recognized as a modified style (the style ID and file name would stay the same in these cases).
@retorquere

This comment has been minimized.

Copy link

commented May 19, 2019

I've put up a new sample.

It turns out it is possible to do inline diffs using <del> and <ins> (which GH does render) but they cannot be colorized and I found them really hard to spot in the output.

There's currently no limit; all changed styles are rendered. WRT dependents/independents:

  • How do I get Independents and Dependents into my script? What should I require?
  • Will they pick up new styles on disk, or do they only list items from whatever gem that hosts them?
  • If an independent style changes, should I be checking all its dependents?

I will look at your point 2.

@retorquere

This comment has been minimized.

Copy link

commented May 19, 2019

Does anyone here know what R099 means in git --name-status? I know R means renamed, but I don't know what the numbers mean; they're significant because a simple rename gave me R100 and a rename + mod gave me R099, but I'd rather know rather than guess how to interpret these numbers.

@retorquere

This comment has been minimized.

Copy link

commented May 19, 2019

I've just taken (in)dependence from the path names.

@retorquere

This comment has been minimized.

Copy link

commented May 19, 2019

Currently set up so that if the tests fail, it will post the failure, if they pass, at most 10 styles are rendered, with independents taking precedence, and it will tell you how many there actually were.

@retorquere

This comment has been minimized.

Copy link

commented May 19, 2019

The current script lives on https://github.com/retorquere/styles/tree/reporting; the files of interest are:

  • .rspec (adds file output for the rspec runner)
  • .travis.yml (calls the script to post to github)
  • spec/post-to-github.rb
  • spec/items.json (the sample items)
@adam3smith

This comment has been minimized.

Copy link
Member Author

commented May 19, 2019

Does anyone here know what R099 means in git --name-status?

from https://stackoverflow.com/a/35142442/1483360

Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy). Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites.

So makes perfect sense that a pure rename is 100% similar and a rename&mod is some number <100% similar.

@adam3smith

This comment has been minimized.

Copy link
Member Author

commented May 19, 2019

I'm really happy with this as is -- we'd obviously want to add brief messages for the contributors to make sense of this, but in terms of the output I would just take this as in the last example. @rmzelle -- are you good to go with the current version?

I think just adding explanatory text during the merge process might be easiest so Rintze and I can debate the details there..

@rmzelle

This comment has been minimized.

Copy link
Member

commented May 20, 2019

I'm really happy with this as is

@adam3smith, I agree this looks great. With a few more changes it looks like we can retire Sheldon entirely, right? I think the only thing we're missing right now is the welcome comment after a PR is opened (and support for the "locales" repo).

@retorquere, with regard to the failed tests, it would be very nice if we could clean up the rspec output a little. I don't know if this can be configured directly within rspec, but the following lines should ideally be stripped from the output as they're not informative to the typical contributors of CSL styles:

 Shared Example Group: "style" called from ./spec/styles_spec.rb:223
 # ./spec/styles_spec.rb:169:in `block (2 levels) in '

The final block can also be deleted:

> Finished in 1 minute 28.2 seconds (files took 41.24 seconds to load)
> 156043 examples, 8 failures
> 
> Failed examples:
> 
> rspec ./spec/repository_spec.rb:21 # The CSL Style Repository may not contain any duplicate style titles
> rspec ./spec/styles_spec.rb[1388:6] # developing-world-bioethics: "template" link must point to an existing independent style
> rspec ./spec/styles_spec.rb[1625:15] # junk: style ID must be of the form "http://www.zotero.org/styles/" + style file name (without ".csl" extension, e.g. "http://www.zotero.org/styles/apa")
> rspec ./spec/styles_spec.rb[3567:4] # dependent/apa-cv: must be a dependent style (independent styles must be placed in the root directory)
> rspec ./spec/styles_spec.rb[3567:5] # dependent/apa-cv: "independent-parent" link must point to an existing independent style
> rspec ./spec/styles_spec.rb[3567:6] # dependent/apa-cv: may not have , , or  elements
> rspec ./spec/styles_spec.rb[3567:7] # dependent/apa-cv: may not have a "template" link
> rspec ./spec/styles_spec.rb[3567:9] # dependent/apa-cv: must have the same citation-format as its independent-parent

This would reduce retorquere/styles#1 (comment) to:

Tests failed

1) The CSL Style Repository may not contain any duplicate style titles
   Failure/Error: expect(TITLES.select { |_, styles| styles.length > 1 }).to eq({})
   
     expected: {}
          got: {"american psychological association 6th edition"=>["apa", "junk"]}
   
     (compared using ==)
   
     Diff:
     @@ -1 +1,2 @@
     +"american psychological association 6th edition" => ["apa", "junk"],

2) developing-world-bioethics: "template" link must point to an existing independent style
   Failure/Error: expect(INDEPENDENTS_BASENAMES).to include(template_ID)
     expected ["vancouver-brackets-only-year-no-issue", "orthopedic-clinics-of-north-america", "asa-cssa-sssa", "ac...nschaften-und-landschaftsarchitektur", "revista-noesis", "haute-ecole-de-gestion-de-geneve-iso-690"] to include "apa-cv"

3) junk: style ID must be of the form "http://www.zotero.org/styles/" + style file name (without ".csl" extension, e.g. "http://www.zotero.org/styles/apa")
   Failure/Error: expect(style.id).to eq("http://www.zotero.org/styles/#{basename}")
   
     expected: "http://www.zotero.org/styles/junk"
          got: "http://www.zotero.org/styles/apa"
   
     (compared using ==)

4) dependent/apa-cv: must be a dependent style (independent styles must be placed in the root directory)
   Failure/Error: expect(style).to be_dependent
     expected `#.dependent?` to return true, got nil

5) dependent/apa-cv: "independent-parent" link must point to an existing independent style
   Failure/Error: expect(parent_ID_link).to match(%r{^#{link_prefix}})
     expected nil to match /^http:\/\/www.zotero.org\/styles\//

6) dependent/apa-cv: may not have , , or  elements
   Failure/Error: expect(style).not_to have_macro
     expected #has_macro? to return false, got true

7) dependent/apa-cv: may not have a "template" link
   Failure/Error: expect(style).not_to have_template_link
     expected #has_template_link? to return false, got true

8) dependent/apa-cv: must have the same citation-format as its independent-parent
   Failure/Error: parent = style.independent_parent_link[/[^\/]+$/]
   
   NoMethodError:
     undefined method `[]' for nil:NilClass

Finally, a link to the build report would also be handy, and I see that some HTML/XML tags are currently not being escaped properly: 6) dependent/apa-cv: may not have , , or elements.

@retorquere

This comment has been minimized.

Copy link

commented May 20, 2019

The script can also post the welcome message, and I currently see a few ways to go about this; the script would scan the PR comments upon start

  1. for a fixed template, and if not found, post it. This would mean the welcome gets repeated if the template changes.
  2. for a given flair to be added to the welcome comment. It's sort of unlikely that the opening comment would have any flair. I think I can see flair in the API.
  3. for a given user to have posted on the issue comments. This assumes the script would get a github token tied to a bot account, not a personal account. I would recommend this in any case, because it gets confusing if bots post under personal accounts.

As to trimming the output, I am looking at the rspec json logger to see if I can make sense of its output. It's possible to write a custom formatter to do whatever we want directly (such as generating markdown), but I could not find any documentation on this saying anything else than "it's possible".

@retorquere

This comment has been minimized.

Copy link

commented May 20, 2019

New sample of test failure log is up.

@rmzelle

This comment has been minimized.

Copy link
Member

commented May 23, 2019

@retorquere, I think (3) makes the most sense. We currently use https://github.com/csl-bot to post the Sheldon comments (which is actually under control of Zotero), and we might be able to co-opt that account.

And where did you make the changes that resulted in retorquere/styles#1 (comment)? https://github.com/retorquere/styles/tree/reporting hasn't seen an update since 5/19.

Would you also be open to supporting the "locales" repo? We use Sheldon in very similar capacity there (just with separate templates: https://github.com/citation-style-language/Sheldon/tree/master/templates). We probably wouldn't need any citation rendering there, but it would e.g. be nice to have the GitHub comments with test failure, and it would allow us to retire Sheldon altogether.

@retorquere

This comment has been minimized.

Copy link

commented May 23, 2019

I forgot to push the latest changes, they're now up. Yeah sure, I haven't looked at the locales repo, but if it substantially does the same thing, that seems sensible. I'll have a look.

I'll add the scanning code for point 3.

@retorquere

This comment has been minimized.

Copy link

commented May 24, 2019

Turns out it's not too hard to make a github-installable gem to share the code. Would you guys prefer the test-assets (like items.json) to live with the gem or in the respective repos (styles/locales)?

@adam3smith

This comment has been minimized.

Copy link
Member Author

commented May 24, 2019

Turns out it's not too hard to make a github-installable gem to share the code. Would you guys prefer the test-assets (like items.json) to live with the gem or in the respective repos (styles/locales)?

I don't have a strong opinion but my first reaction would be to leave them in the respective repos because Rintze and I have those cloned locally already, so easier to update. But if there's any reason to keep them in the gem (speed, some other best practice reason), this is a minor consideration and I'd be happy with that, too.

@retorquere

This comment has been minimized.

Copy link

commented May 24, 2019

There's no real benefit, but I saw that Sheldon also had local assets for styles and locales, and perhaps the items.json could be shared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.