Commit Graph
56 Commits
Author SHA1 Message Date
Paul MelnikowandGitHub bb66a99a66 [GitHub] Issue and pull request detail and check state (#1114)
This adds badges for Github issues and pull requests. You can display the state, title, username, number of comments, age, time since last update, and state of checks.

Provides an endpoint the Shields CI can use to fetch PR titles for #979 and resolves #1011.
2017-10-02 13:26:42 -04:00
Paul MelnikowandGitHub 8e08b374a4 [Github] Last commit date and commit activity (#1112)
Reopen of #928 by mskonovalov. Closes #897.
2017-10-02 10:47:14 -04:00
Paul MelnikowandGitHub c62534b5fd Move remaining helper functions to lib/ (#1109)
- Clear the regular update cache between unit tests
2017-10-01 22:08:30 -04:00
Paul MelnikowandGitHub f271b82670 Nudge forward style checks a la eslint-config-standard (#1082)
Because I despise nitpicking stuff like indentation and spacing in pull request comments, I'd like to nudge forward our automated style checking, at least for new files being added.

I don't want to totally rewrite server.js just to get automated style checking… the blame tracking is just too useful. So let's it's just take care of that when we start splitting it out.

More discussion in #948.
2017-10-01 21:09:43 -04:00
Paul MelnikowandGitHub 820b72c4c4 Always allow overriding the label (#1108)
Audit all the badges with test coverage, looking for badges which assign `badgeData.text[0]`.
2017-10-01 20:20:13 -04:00
Ritwick DeyandPaul Melnikow 79174d4cfc [waffle] colorB fixes & test added (#1110)
Close #1008
2017-09-29 12:49:46 -04:00
Paul Melnikow 47ba81a007 Support named logos and omit logos by default (#1092)
- Except for social badges, omit logos by default (#983)
- Omit the logo from a social badge using the query string: `?logo=`
  (#983)
- Opt in to named logos using the query string: `?logo=appveyor`
- Provide custom logo data as before: `?logo=data:image/png;base64,...`
- Rewrite badge data functions, with unit tests

Unit tests are covering the new code very well, though the underlying
functionality (logos) is untested.

Close #983
2017-09-28 10:47:39 -04:00
un.defandPaul Melnikow 4104f822fd [LuaRocks] package version badge (#1087) 2017-09-25 20:28:14 -04:00
Paul MelnikowandThaddée Tyl 8e6fe01d20 Add test for measure-text 2017-09-24 22:36:14 +02:00
Christophe BliardandPaul Melnikow cafb66bd93 Add fallback font and missing libs for .png generation
If Verdana.ttf can't be loaded, the font file pointed by the
FALLBACK_FONT_PATH environment variable will be loaded.

This fixes width computation errors that can occur with non-latin
characters when running with Docker.
2017-09-22 13:27:59 -04:00
Thaddee Tyl fc6c5852b2 Use a ternary statement in logging code
See https://github.com/badges/shields/pull/1040#discussion_r136196343.

Closes #1040.
2017-09-03 20:04:41 +02:00
Thaddee Tyl d032090038 Use a custom logging mechanism
This mechanism eases knowing when a message was logged while keeping the
simplicity of the logging mechanism.
2017-08-30 22:03:30 +02:00
Adriaan GroenenboomandDaniel Lo Nigro 15f24fbcce Improve Docker run (envsubst, Alpine, documented env file) (#870)
* Add template for secret.json

- Move to faster and lighter Alpine base image

* Update documentation

* Update documentation

* Fix Github token config for secret.json

* Extend env file for Docker runtime configuration

- Update documentation
- Add gh_token for GH personal access token to secret template

* Change http to https in infoSite

* Update .dockerignore

* Update .gitignore

* Update dockerignore

* Remove ENV directive from Dockerfile

- Environment is needed at runtime, not at buildtime

* Docker: contain secret.json in private/

- Incorporates fix from 7c8b0e3d

* Use localhost in example env

* Use baseUrl in GitHub redirect

* Move GH personal token retrieval up

- To remove duplicate Promise.then()

* Typo in shields.example.env
2017-05-07 11:13:02 -07:00
Paul MelnikowandGitHub 653f79fbde Tests: Convert to ES6, use node-fetch, refactor, and clean up style (#971) 2017-04-30 10:51:18 -04:00
anatoly techtonikandPaul Melnikow 6c34191fcf Add logo to AppVeyor badge and change logo color (#812)
Fixes #507
2017-04-28 01:35:19 -04:00
Paul MelnikowandGitHub f47aa968cd Prepare to modify / refactor analytics (#970)
- Move analytics into their own file
- Add test of analytics endpoint
2017-04-28 01:06:06 -04:00
Paul MelnikowandGitHub c3ef232bf7 Place tests alongside their code (#969)
Reorg of the tests: move them just alongside their code. The principle relates to grouping by coupling, not by function and is established in best-practice documents (e.g. https://github.com/focusaurus/express_code_structure#underlying-principles-and-motivations), despite its break from the tradition of a separate `test/` tree. All of today's tools can handle tests spread through the repository.

There are some good, if subtle consequences of this change:

- Since files are close at hand, friction is reduced at development time, which encourages that new tests are written to cover new behaviors.
- It's easier to find the tests that cover a particular piece of functionality.
- It's easier to see which code has tests and which doesn't.
2017-04-28 00:55:15 -04:00
Daniel Lo NigroandPaul Melnikow ccbdad69ba Split various utilities into standalone files (#952) 2017-04-24 18:37:22 -04:00
Paul MelnikowandThaddée Tyl c7c92f12fd Clarify that secrets are optional
- Quit witih an error when secrets can’t be loaded
- Refactor duplicated code

Resolves #894
2017-04-13 00:02:18 +02:00
Paul MelnikowandThaddee Tyl 64e9d13e76 Disallow unused variables and turn on a few recommended rules 2017-04-12 23:55:13 +02:00
Paul MelnikowandThaddee Tyl de18dce94a Add more test helpers
While working on some tests, I was having a tricky problem in a test suite. Eventually I tracked it down to an interaction between tests. I suspected the test library, but once I tried to make an isolated test case, I realized the test library was working fine. It turns out it was the server’s request cache. The fix is to clear the cache between tests.

Not needed for this PR, though I’m adding it to this branch because it conflicts with this change.
2017-04-12 23:13:16 +02:00
Paul MelnikowandThaddee Tyl 5a45003bc3 Test server logic for img2svg error, and run the server in-process
Running the server in process is necessary for the mock to work. This is an approach I’ve taken in the past. I experimented with this setup quite a bit when I was playing around with a test suite, and it seemed to work well enough. Setting `process.argv` is a admitedly a bit gross, though a cleaner approach would require more involved changes to `server.js`.
2017-04-12 23:13:16 +02:00
Paul MelnikowandThaddee Tyl 8b77d16a72 Always call the callback + reliable erroring
Fixes #914
2017-04-12 23:13:16 +02:00
Paul MelnikowandThaddee Tyl 0760d17d82 Return data from svg2img via callback
Given the chunks coming from imagemagick are getting stored memory and
then tucked into a cache, this function could as easily return a buffer
via callback. Streaming is just making it more complex. (And trickier to
test!)
2017-04-12 23:13:16 +02:00
Paul MelnikowandThaddee Tyl ad1e419d42 Add tests for svgToImg 2017-04-12 23:13:16 +02:00
Thaddee Tyl 2d71e844a2 Store raster badges in the LRU cache
In ef1a5159, the switch to using imagemagick made a faulty use of the library by
listening for an 'end' event that is never raised. As a result, the cache was
never populated.

In d985f81f, a fix that takes care of the fact that the previously mentioned
dead code relies on a non-existent variable caused it to kill the server when a
raster badge is requested twice, as what it stored in the cache was the pipe
transmitting chunks, not the chunks themselves, and the pipe (a Socket object)
cannot be subsequently sent through a pipe. The following error occured instead:

    events.js:163
          throw er; // Unhandled 'error' event
          ^

    TypeError: Invalid non-string/buffer chunk
        at chunkInvalid (_stream_readable.js:395:10)
        at readableAddChunk (_stream_readable.js:150:12)
        at DataStream.Readable.push (_stream_readable.js:136:10)
        at DataStream._read (/home/m/shields/lib/svg-to-img.js:45:21)
        at DataStream.Readable.read (_stream_readable.js:350:10)
        at resume_ (_stream_readable.js:739:12)
        at _combinedTickCallback (internal/process/next_tick.js:80:11)
        at process._tickDomainCallback (internal/process/next_tick.js:128:9)
2017-04-12 23:13:16 +02:00
Thaddee TylandPaul Melnikow a0e6a6aeba Use new Buffer() instead of Buffer()
The following warning is emitted by Node.js:

> DeprecationWarning: Using Buffer without `new` will soon stop working. Use `new
> Buffer()`, or preferably `Buffer.from()`, `Buffer.allocUnsafe()` or
> `Buffer.alloc()` instead.

This patch removes this warning.
2017-03-29 18:28:48 -04:00
Paul MelnikowandThaddee Tyl d985f81f8e Disallow undefined variables 2017-03-29 20:09:30 +02:00
Frode KnutsenandPaul Melnikow 2133ff9d1f fix default value for githubUserTokens 2017-03-27 16:56:58 -04:00
Thaddee Tyl 5dd58142cb Fix LRU cache index stalling
The old LRU implementation stored a list's indices to reference items in that
list, but deletions from the list made indices point to the wrong slot.

Functionally, it meant that deleted slots were not guaranteed to be the oldest
slot.

Using a linked list fixes that.
2017-03-26 23:00:31 +02:00
Thaddee Tyl 11b6e06f2f Organize local modules in lib 2017-03-26 22:57:55 +02:00
Paul Melnikow 47a8bf51dc First pass for linting on PRs 2017-03-20 16:54:27 -04:00
Thaddee Tyl 076cb14b3b Perform constant equal comparison for shared Shields secret
This should prevent timing attacks.
2017-02-25 18:20:07 +01:00
Thaddee Tyl 7c8b0e3d32 Contain all private files in private/ 2017-02-05 16:24:35 +01:00
Thaddee Tyl 0684c25b94 Remove todo for GitHub auth documentation
It was accidentally done by 56746d4a38.
2016-07-02 12:14:34 +02:00
Thaddee Tyl 71bb291f40 Remove verbose logs for GitHub auth 2016-07-02 10:39:57 +02:00
Thaddee Tyl a7cfac6e93 GitHub auth: use token with the most remaining requests
Part of #529.
2016-06-27 20:07:15 +02:00
Thaddee Tyl bfc6e7d863 GitHub auth: use up to 3/4 of the user's rate limit 2016-06-27 19:38:01 +02:00
Thaddee Tyl 56746d4a38 GitHub auth: rely on cache if no tokens remain 2016-06-27 19:37:19 +02:00
Thaddee Tyl 12b0ded4a3 GitHub auth: use UTC epoch seconds instead of milliseconds 2016-06-26 18:41:32 +02:00
Thaddee Tyl 63e25b29eb GitHub auth: no longer rely on buggy rate limit cache 2016-06-26 18:30:27 +02:00
Thaddee Tyl a3ba53a0d8 GitHub auth: user token selection supports remaining requests 2016-06-26 18:01:48 +02:00
Thaddee Tyl 2b849b2b7f GitHub auth: log token requests 2016-06-26 17:21:00 +02:00
Thaddee Tyl 014753a736 GitHub auth: better messages 2016-06-26 16:45:44 +02:00
Thaddee Tyl 14d436084b GitHub auth: log token rate limits and unauthorization 2016-06-25 20:32:30 +02:00
Thaddee Tyl 997e6a6f43 GitHub auth: maintain rate limit reset information, track token with highest remaining requests 2016-06-23 19:28:56 +02:00
Thaddee Tyl fe279e4a75 GitHub auth: removal of unauthorized user tokens 2016-06-22 10:12:07 +02:00
Thaddee Tyl a54a247f16 GitHub auth: only use user tokens if over rate limit 2016-06-21 09:26:52 +02:00
Thaddee Tyl 58cbb18c1d GitHub auth: query parameter, don't shadow request() 2016-06-20 22:30:51 +02:00
Thaddee Tyl 3564e4474b GitHub auth: set up lowest available rate limit 2016-06-19 23:30:21 +02:00