26 Commits

Author SHA1 Message Date
Paul Melnikow
5dd4ee078b Start on the Github rewrite, with [GithubPullRequestCheckState] (#2253)
The GitHub service family is the largest, and as yet untouched by our service rewrite. I thought I would start the process by tackling one service.

This pull request has a few things going on:

1. Rename pull-request-status to pull-request-check-state. We have another badge called pull request status. It seems like the checks are called one thing in the UI and another thing in the API, which is unfortunate. If other folks have strong feelings about the name, I’ll defer.
2. Move its tests and tighten up the syntax.
3. Move its badge examples including the doc string.
4. Add a new helper `errorMessagesFor` to use in the new services in place of `githubCheckErrorResponse`. It seems like we didn’t really use the `errorMessages` parameter to `githubCheckErrorResponse`, so I pared this down. I’m not sure if this is the function we’ll ultimately want, but it seems like a good place to start.
5. Pull fetch code I _know_ we use in other places into `github-common-fetch`. As in the PR I just opened for azure-devops, this takes a functional approach to the shared code, which is more direct, nimble, and easy to reason about than inheritance.
6. Create `GithubAuthService` which functions identically to BaseJsonService, except for one thing, which is that it uses the token pool. I accomplished this by adding a `_requestFetcher` property to BaseService, which is initialized to `sendAndCacheRequest` in the constructor, and can be overridden in subclasses. Since we weren’t using `_sendAndCacheRequest` directly except in BaseService and tests, I removed that property. I like this approach to patching in the GitHub auth because it’s very simple and creates no new API exposure. However, the way we’re doing the dependency injection feels a bit odd. Maybe the eventual refactor of request-handler would be a godo time to revisit this.

The GitHub requests go through many, many layers of indirection at this point. Later on it would be good to shave some of these off, perhaps once the legacy GitHub services have been converted, or when all the services are done and we can take another look at the base service hierarchy. The work in #2021 and #1205 is also related.
2018-11-09 16:22:48 -05:00
Paul Melnikow
3eac8ebbfb Rework GitHub acceptor and move to its own module (#2021)
Continue to merge the work from #1205.
2018-11-09 15:14:01 -05:00
Paul Melnikow
611e58e43e Make a few github tests more reliable (#2292)
The version test is failing because the shields repo version is not a dotted version.
2018-11-08 14:48:44 -05:00
dependabot[bot]
e240409033 Bump prettier from 1.14.3 to 1.15.1 (#2289)
* Bump prettier from 1.14.3 to 1.15.1

Bumps [prettier](https://github.com/prettier/prettier) from 1.14.3 to 1.15.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/1.14.3...1.15.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Run prettier
2018-11-08 14:39:00 -05:00
Paul Melnikow
83ac6ff1b3 Enforce use of template literals (#2242)
This is consistent with what we're pretty much already doing, and saves us from making the request during code review.

These were all autofixed and most of them seem easier to read. Some in the legacy services should be rewritten in more legible forms during refactor (ie using intermediate variables, or using request’s qs option). There are some in helper functions and elsewhere that should get rewritten separately. I don't want to change them in this PR because the changes will get lost in this diff, though we could identify them here and fix them before or just after.
2018-11-02 17:11:44 -04:00
Lentil Sun
88f10f8079 Fix: colorB override not working for Github Stars (#2171) 2018-10-21 14:33:12 +01:00
chris48s
a74db34853 Allow [GitHub] tag badge to sort by date (#2157)
* add test for tag-pre
* support /releases-pre (but also allow /all for BC)
* allow GH tags to be sorted by date instead of semver
* fix license badge
2018-10-08 18:29:02 +01:00
Pyves
3e69873930 [aur packagist php-eye travis vaadin-directory github david jitpack twitter] Enforced lowercase badge labels (#2058) 2018-09-09 11:41:10 +01:00
Paul Melnikow
bedba47d77 Move legacy services from server.js into services/ (#1958)
This builds on the work of #1931 by moving the legacy services into `services/`.
2018-08-27 13:29:54 -04:00
Paul Melnikow
a16d436602 Optionally persist [Github] tokens in Redis (#1939)
This is a fairly simple addition of a Redis-backed TokenPersistence. When GithubConstellation is initialized, it will create a FsTokenPersistence or a RedisTokenPersistence based on configuration. Have added tests of the Redis backend as an integration test, and ensured the server starts up correctly when a `REDIS_URL` is configured.

Ref: #1848
2018-08-19 10:27:23 -04:00
Paul Melnikow
b10a6a4aa7 Refactor [github] token persistence, again (#1906)
Instead of saving tokens on a timer, save them when they change. Use EventEmitter to keep the components loosely coupled.

This is easier to reason about, much easier to test, and better supports adapting to backends which support atomic operations.

This replaces json-autosave, which was a bit difficult to read and also hard to test, with fsos, the lower-level utility it’s built on.

Ref: #1848
2018-08-18 23:54:53 -04:00
Pyves
b0070ff861 [GitHub] Error message customisation for all status codes (#1888) 2018-08-14 18:57:24 +01:00
Paul Melnikow
66d444aa40 Clean up our callback style and enforce no exclusive tests and remove an exclusive test (#1900)
We use arrow functions in most places; this enforces it.

Passing arrow functions to Mocha is discouraged: https://mochajs.org/#arrow-functions

This was a mix of autofixes and hand adjustments.
2018-08-12 20:45:43 -04:00
Danial
b2af8f7a04 [GitHub] support issue tags with "/" character (#1902)
* support tags with "/" character
2018-08-12 15:20:30 +12:00
Paul Melnikow
9007658fd0 Refactor and test [github] token persistence (#1863)
Ref #1848 #1205
2018-08-11 20:13:40 -04:00
Paul Melnikow
39d393028d Fix and test the github admin route (#1886)
Fix regressions in the github admin and token acceptor endpoints, introduced in #1813.
2018-08-11 19:48:43 -04:00
Paul Melnikow
ada1dec815 Lengthen timeout on a flaky service test (#1885) 2018-08-10 15:10:31 -04:00
Paul Melnikow
8af48c0a21 Minor tweaks in [github] auth code (#1862)
* Move / rework is-valid-token

* TokenPool: Add allValidTokenIds method

* Minor cleanup in server.js
2018-08-09 07:22:54 -04:00
Paul Melnikow
c11d97a192 Refactor [github] initialization (#1861)
This creates a new convenience class which consolidates all the Github initialization. It supports dependency injection and facilitates refactoring the persistence along the lines of #1205.

Also ref #1848
2018-08-09 07:20:57 -04:00
Paul Melnikow
7a664ca3e8 Run prettier (#1866)
Merging this separately so the commit with the tooling change is readable. This is a follow-on to #1167 which turned prettier on.
2018-08-08 17:57:14 -04:00
Pyves
e1affea266 [GitHub] Fix undefined badges (#1816) 2018-08-08 20:57:57 +01:00
Paul Melnikow
56fcb2e5ba GithubApiProvider: injectible interface for code that calls github (#1812) 2018-08-07 16:46:12 -04:00
Paul Melnikow
2ff71dab6a Start cleaning up github auth routes (#1813)
- Move github token debug route to separate module
- Use crypto.timingSafeEqual
- Rename getTokenDebugInfo -> serializeDebugInfo
2018-08-01 21:58:11 -04:00
Marcin Mielnicki
9d90bd1f95 [github] Commit merge status badge (#1709)
* Basic version of commit-status badge added

* Support for case with no common ancestor

* Handle unknown branch

* Service tests with error responses

* Handle unexpected 404 responses from github

* Branch is a base

* Tests reordered

* Using not the newest commit in tests

* Test for checked commit identical with the newest commit in branch

* Code refactoring

* Example for Github commit merge status
2018-05-30 18:51:52 +02:00
chris48s
714df8fac5 change CC0 example in GH service tests (#1634) 2018-04-28 20:59:27 +01:00
Paul Melnikow
ea4b758612 Move service tests alongside code (#1563)
Per discussion in #1543
2018-03-20 18:32:48 -07:00