Any Travis experts? Trying to improve library PRs


#1

I think it might help to speed up review of PRs to the offical libs if there was a graphical preview of the PRs.

I’ve modified cpavlina’s script [1] which generates image for components, so that it could be used to generate images of changed components (added or modified) in the Travis check.

I think I can see how to adapt comparelibs.py [2] to call the schlib-render script, and output a png.

The question is, is there a server accessible to Travis which could be used to store the images? Then we automatically add the image to pull requests.

The OpenSCAD project does a similar thing, they even compare the images to verify code changes have not broken anything and produce an HTML report. Example [3]

[1] https://github.com/cpavlina/kicad-schlib/blob/master/scripts/schlib-render.py
[2] https://github.com/KiCad/kicad-library-utils/blob/master/schlib/comparelibs.py
[3] http://files.openscad.org/tests/travis-1333_report.html


#2

It appears OpenSCAD upload to one of their servers - “files.openscad.org” (see https://github.com/openscad/openscad/blob/master/.travis.yml), via a secure mechanism (I guess no one wants files being transferred just anywhere, would be a gift for hackers).

I can’t see where the openscad test scripts do an upload, it’s buried somewhere.

Travis also support Amazon S3 (cloud service), it appears you have to pay for that (after free trial expires).

Here is a sample file from sch-render.py


#3

Great idea!

Is there any way to upload the image to GitHub somehow? For example when you embed an image into a comment it auto-uploads.

Perhaps Travis could make a comment on the PR page itself, and upload the image there?


#4

This might be worth looking into - https://developer.github.com/v3/issues/comments/


#5

One possible solution that does not require configuring a server, is to upload the images to a free service like imgur (unlimited API uploads for open-source projects) using credential stored in a “Travis secret”, see https://docs.travis-ci.com/user/encryption-keys/.

The main problem with this solution is that these secrets are not accessible during Travis builds that are caused by pull requests generated from forks. Only pull requests from the same repository (but from a non-master branch, naturally) can use these secrets. (See https://docs.travis-ci.com/user/pull-requests#Pull-Requests-and-Security-Restrictions.)

If testing only post-merge commits or pull requests from the main fork is OK, then that Travis secrets + imgur is a viable option.

@SchrodingersGat: Unfortunately the GitHub API does not allow you to upload images. GitHub internally receives the images, uploads them on the fly and then the brower-side interface inserts a link into the message.


#6

Total out of the box here, but why go for an image if you can use the code of the internet itself to create the image on the fly - not just for the PRs?
There should be a couple of javascript or php libs out there, which are capable of this, no?

example:


#7

Interesting idea, not sure how to tie that in with Travis.

Currently Travis CI adds a link to PRs, which looks like
https://travis-ci.org/KiCad/kicad-library/builds/249441746?utm_source=github_status&utm_medium=notification

The Travis script is limited to text output, I think.


#8

I found where OpenSCAD do their upload in


They use scp (secure copy with SSH). The process is

  1. run the tests
  2. Create an HTML report local to Travis
  3. Copy the report file to files.openscad.org/
  4. Print the link e.g. http://files.openscad.org/tests/travis-2722_report.html

This doesn’t update the PR, but at least the report is available. The link could be pasted manually until we find a better way. I wonder if we could use kicad-pcb.org to host report files?


#9

I think I found a server to upload files to
http://www.micro-wizard.co.uk/static/7400_modified.html

So the plan is

  1. Modify comparelibs.py to output a list of changed components
  2. Modify library-check.sh to call new script schlib-render.py with library name
  3. schlib-render.py creates an html file containing a report (with embedded images)
  4. The report file is uploaded via sftp to micro-wizard.co.uk (for now)
  5. somehow the link is posted in the PR that kicked off the Travis build (not sure about that step)

I think I have done most of the first 3 steps, I’ll need to experiment with 4.