Commit Graph

159 Commits

Author SHA1 Message Date
Jacob Tomlinson
d56b6961da Add [dynamic-yaml] badge (#1623)
* Add dynamic yaml badge

* Forgot package lock

* Switch tests to yaml data source

* Add yaml to the dynamic badge maker options

* Reorder to match documentation examples

* Reordered dynamic types to be alphabetical

* Removed regex as pinend commit makes it unnecessary and fixed url

* Removed unused import

* Add more YAML MIME types

* Removed duplicate tests which don't differ between data types
2018-04-08 21:47:28 +02:00
Paul Melnikow
416d433fa0 [appveyor] Error handling in BaseService (#1590)
Make a clear distinction between programmer errors ("internal errors") and runtime errors, and allow configuring the server to let the programmer errors bubble up in development and unit testing. This saves a huge amount of time because it generates ordinary stack traces when things go wrong. And, if these errors occur in production, we'll catch them, and display **shields | internal error** which is the equivalent of a 500 error.
2018-04-01 22:04:22 -05:00
greenkeeper[bot]
724abd06dc Update svgo to the latest version 🚀 (#1473)
* fix(package): update svgo to version 1.0.5
* Update package-lock
* Update invocation for SVGO 1.x
* Remove helper
2018-04-01 21:57:20 -05:00
Danial
57008d28a3 Test path escaping - mocha windows fix (#1627) 2018-04-01 08:28:30 +02:00
Paul Melnikow
ac7c418222 Extract examples from new-style services (#1582)
Instead of centralizing examples, specify them from within a service.

* Avoid duplication in service loading + refactor
* Avoid duplication in URLs, rename uri -> url in BaseService
2018-03-30 03:07:44 -05:00
Philip I. Thomas
01646ded72 upgrade glob to be a prod dependency (#1619) 2018-03-28 08:40:25 -07:00
greenkeeper[bot]
7e239f78c0 chore(package): update semver-regex to version 2.0.0 (#1596) 2018-03-27 17:13:15 -07:00
Marcin Mielnicki
fe4ac0bf1c Log errors to Sentry (#1422) 2018-03-24 20:30:51 +01:00
Paul Melnikow
ea4b758612 Move service tests alongside code (#1563)
Per discussion in #1543
2018-03-20 18:32:48 -07:00
Paul Melnikow
7d90391b05 Housekeeping after upgrade to Node 8 (#1564) 2018-03-18 13:34:15 -04:00
Paul Melnikow
3a47bb38ac Searches with regex control characters should not crash (#1579)
Fix #1578
2018-03-17 16:52:41 -04:00
greenkeeper[bot]
2adb0e7d52 Update request to the latest version 🚀 (#1566)
* fix(package): update request to version 2.84.0

* fix(package): update request to version 2.85.0

Closes #1566

* update package-lock
2018-03-14 22:57:24 -04:00
greenkeeper[bot]
3a5563d27f Update query-string to the latest version 🚀 (#1572)
* fix(package): update query-string to version 6.0.0

* update package-lock
2018-03-14 22:57:05 -04:00
Paul Melnikow
2d651533aa New API for registering services: #963 #1423 #1425 #1450 #1451 #1544 #1543
This merges the `node-8` branch. The heavy lift was by @Daniel15 with refactoring from me and a patch by @RedSparr0w.

* New API for registering services (#963)
* Disable Node 6 tests on node-8 branch (#1423)
* BaseService: Factor out methods _regex and _namedParamsForMatch (#1425)
    - Adjust test grouping
    - Rename data -> queryParams, text -> message
* BaseService tests: Use Chai (#1450)
* BaseService: make serviceData and badgeData explicit and declarative (#1451)
* fix isValidStyle test (#1544)
* Run tests in Node 9, not Node 6 (#1543)
2018-03-11 17:53:01 -07:00
Paul Melnikow
ae848f38f4 Add snapshot tests for SVG and JSON (#1557)
These tests should fail if something is accidentally changed that affects the SVG or JSON files. In the case of deliberate changes, we can update the snapshots.
2018-03-11 09:07:03 -07:00
greenkeeper[bot]
dd90d2aced Update sinon-chai to the latest version 🚀 (#1547)
* chore(package): update sinon-chai to version 3.0.0

* Update package-lock
2018-03-08 09:24:38 -08:00
greenkeeper[bot]
2d5a088d6f Update next to the latest version 🚀 (#1490)
* chore(package): update next to version 5.0.0

* Update package-lock

* Get build + tests passing
2018-03-08 09:18:52 -08:00
Danial
be09cee1f2 User defined XML source badge [dynamic-xml dynamic-json] (#1494)
* add dynamic xml badge support

* add tests

* dynamic badge add tests for query param

* remove try catch

* use `checkErrorResponse()`

* update tests

* [dynamic json] add test for multiple items

* Rebase, [dynamic xml] Add support for multiple items

* 404 response -> resource not found

* multiple results test less greedy regex

still alot of room for improvement to this test

* update dynamic badge gen

* add dynamic xml gen tests

* update tests id & path

* datalist -> select

* uri -> url

kept support for uri, incase of any already existing badges.

* split dynamic gen uri

* update query placeholder
2018-03-06 22:43:02 +01:00
greenkeeper[bot]
22ff288eac Update eslint, eslint-config-standard, and friends to the latest versions 🚀 (#1512) 2018-03-03 20:45:12 -05:00
greenkeeper[bot]
ab5514651f Update eslint-plugin-node to the latest version 🚀 (#1489) 2018-03-03 20:36:46 -05:00
greenkeeper[bot]
4a3f1eda9a Update fetch-ponyfill to the latest version 🚀 (#1488) 2018-03-03 20:25:18 -05:00
greenkeeper[bot]
af04068ffa chore(package): update node-fetch to version 2.0.0 (#1486) 2018-03-03 19:55:13 -05:00
greenkeeper[bot]
4e5669d2eb Update prettier to the latest version 🚀 (#1528) 2018-03-03 19:44:03 -05:00
greenkeeper[bot]
ef038b8049 Update mocha to the latest version 🚀 (#1459)
* chore(package): update mocha to version 5.0.0

* Update package-lock
2018-02-02 14:58:14 -08:00
greenkeeper[bot]
4ffdd85177 Update semver to the latest version 🚀 (#1457)
* fix(package): update semver to version 5.5.0

* Update package-lock
2018-02-02 14:54:26 -08:00
greenkeeper[bot]
1314258913 Update is-svg to the latest version 🚀 (#1483)
* chore(package): update is-svg to version 3.0.0

* Update package-lock
2018-02-02 14:44:29 -08:00
Paul Melnikow
e6de92c6ba Upgrade to next.js patched for CVE-2018-6184 (#1485)
This clears the GitHub warning for the vulnerability that shows up for maintainers. Note the vulnerability does not affect our deployment, which is static, using `next export`.

https://github.com/zeit/next.js/releases/tag/4.2.3
https://nvd.nist.gov/vuln/detail/CVE-2018-6184
2018-02-02 14:40:59 -08:00
greenkeeper[bot]
b422e880c1 Update prettier to the latest version 🚀 (#1434) 2018-01-15 14:14:08 -05:00
Paul Melnikow
864b194e5c Add Joi to greenkeeper ignore (#1430) 2018-01-09 11:50:43 -05:00
Thaddee Tyl
ac8935cecb Add rate limiting
We now rate limit IPs, referers and badge type.
2018-01-09 02:35:51 +01:00
Thaddee Tyl
0da212b7de Upgrade to camp 17.2.1 2018-01-09 01:25:10 +01:00
Paul Melnikow
7c1a3fef69 Adopt Chai for assertions (#1419) 2018-01-08 14:18:07 -07:00
greenkeeper[bot]
2013968990 Update danger to the latest version 🚀 (#1414) 2018-01-05 22:09:25 -07:00
Paul Melnikow
cc9a6db853 Speed up font-width computation in most cases (#1390)
Ref: #1379

This takes a naive approach to font-width computation, the most compute-intensive part of rendering badges.

1. Add the widths of the individual characters.
    - These widths are measured on startup using PDFKit.
2. For each character pair, add a kerning adjustment
    - The difference between the width of each character pair, and the sum of the characters' separate widths.
    - These are computed for each character pair on startup using PDFKit.
3. For a string with characters outside the printable ASCII character set, fall back to PDFKit.

This branch averaged 0.041 ms in `makeBadge`, compared to 0.144 ms on master, a speedup of 73%. That was on a test of 10,000 consecutive requests (using the `benchmark-performance.sh` script, now checked in).

The speedup applies to badges containing exclusively printable ASCII characters. It wouldn't be as dramatic on non-ASCII text. Though, we could add some frequently used non-ASCII characters to the cached set.
2017-12-26 23:57:46 -05:00
greenkeeper[bot]
31fb96e4ac chore(package): update prettier to version 1.9.2 (#1367) 2017-12-11 22:47:38 -05:00
Paul Melnikow
b35cb71ed6 Upgrade IcedFrisby (#1360)
IcedFrisby/IcedFrisby#71 will allow us to set a per-test `timeout()` and per-test `retry()`, which should allow us to keep flaky tests green most of the time.

A slough of service tests are failing locally, though they are also failing in master and seem unrelated to these changes. (#1359)

IcedFrisby is maturing toward a 2.0 API. There's been one breaking change to the way dependencies are installed, and probably more changes to come in the API itself. Shields uses such a small part of that API that 2.0, when it's released, may not even affect us.
2017-12-09 12:03:57 -05:00
Paul Melnikow
d97f07c263 Install Danger (#1352)
… so we can stop saying "you forgot to…" in code review. 😀

This idea has come up a number of times. If we can write code to detect a contributor guideline, this tool will message the contributor automatically in a pull request. This lets people fix their own problems, relieves maintainers and reviewers from nagging, and keeps anyone from having to constantly ask for more tests.

For futher reading:

- [How to use Danger well](http://danger.systems/js/usage/culture.html)
- [Examples of the kind of thing it can do](http://danger.systems/js/)
- [Dangerfile reference](http://danger.systems/js/reference.html)
2017-12-08 10:38:41 -05:00
Paul Melnikow
81560cb0c6 Set up CircleCI (including [github] tests) (#1338)
I don’t like that our build goes red on master all the time due to flaky service tests. I thought I’d look into other CI services that would make it possible to run the scheduled tests nightly without causing those messages to show up.

CircleCI, Heroku CI, and Codeship were obvious choices. Heroku CI wasn’t free and I didn’t have any experience with Codeship, so I looked into CircleCI. I’ve used their 1.0 system a lot though this was my first time on their 2.0 system. As with earlier versions, they’ve put a lot of work into making the build fast – perhaps more than any other CI system I’ve seen.

I had such good results, my goal shifted from scheduled daily builds (that don’t litter our commit history with red builds) to improving the CI experience as a whole.

This change made a big impact:

- Build logs load much, much faster. In the test I just ran, 22 seconds to < 2 seconds, a 90% improvement.
- Status of each step shows up right in the GitHub UI, which makes it much faster to see exactly what’s failed.
- Builds run about 50-75% faster on account of parallelism.
- GitHub service tests are fixed. This has been a long-standing issue.
- Ability to ssh into a build container to debug failures.

Here’s what I did:

- Created custom Docker images with our dependencies. To be honest, I’m not even sure these are necessary, only to install the greenkeeper-lockfile. We could get dejavu from npm. They make startup very fast.
- Created an npm-install stage which loads all dependencies into node_modules and caches them.
- Created separate stages for our main tests, service tests, and frontend tests, and stages to run the main tests and service tests in Node 6. These run in parallel, up to four at a time.
- Separated service test ID output from the service test results themselves. (I check these often during the PR process, when I confirm that service tests actually ran. Because the production Shields server caches the title, after updating it you can’t tell whether the update is taking effect.)
- Added a personal access token for the shields-ci user. This should actually fix the long-standing issue #979. CircleCI provides an option to “Pass secrets to builds from forked pull requests,” which means unlike Travis, they’ll give us enough rope to shoot ourselves in the foot.
- Schedule a daily build, which runs all the service tests.
2017-12-06 15:45:09 -05:00
Paul Melnikow
5527d9d642 Fix validateDOMNesting warning (#1342)
Using fix from mapbox/react-click-to-select#15.

From #1273
2017-12-06 13:04:03 -05:00
Peter Gribanov
962cf61b82 PHP version from .travis.yml (#1258)
Reference: #819
2017-12-06 11:04:24 -05:00
greenkeeper[bot]
8bdd5b90d2 chore(package): update prettier to version 1.9.1 (#1335) 2017-12-05 19:22:18 -05:00
Marcin Mielnicki
0570a9e920 License badge colour corresponding to license type (#1190) 2017-12-05 16:43:29 -05:00
greenkeeper[bot]
58437ec72e Update dependencies to enable Greenkeeper 🌴 (#1328) 2017-12-05 11:49:12 -05:00
Paul Melnikow
8014aa351a Upgrade jsonpath (#1327) 2017-12-05 11:23:58 -05:00
Paul Melnikow
9882a44e56 Configure for deployment with zeit now (#1308)
I'm experimenting with Zeit Now as another hosting option. These changes enable a working deployment.
2017-12-04 18:25:16 -05:00
Paul Melnikow
1eedd458b8 Fix and refactor front-end URL generation (#1322)
- Fix issue in Firefox 57 when run from static build
- Fix color parameter in dynamic badge maker
- Correctly apply maxAge in usage badges
- Follow the WHATWG lead and begin to standardize on URL, not URI (https://url.spec.whatwg.org/#goals)
2017-12-04 10:08:54 -05:00
Danial
ad00f5cde5 Fix depcheck's in Windows (#1320)
Both of the depcheck's are throwing errors

OS: `Windows 10`
Node: `v8.7.0`

Current Output:
```cmd
npm run frontend-depcheck

> gh-badges@1.3.0 frontend-depcheck C:\Users\Dan\Documents\GitHub\shields
> check-node-version --node '>= 8.0'

C:\Users\Dan\Documents\GitHub\shields\node_modules\semver\semver.js:678
    throw new TypeError('Invalid comparator: ' + comp);
    ^

TypeError: Invalid comparator: '
    at Comparator.parse (C:\Users\Dan\Documents\GitHub\shields\node_modules\semver\semver.js:678:11)
    at new Comparator (C:\Users\Dan\Documents\GitHub\shields\node_modules\semver\semver.js:662:8)
    at C:\Users\Dan\Documents\GitHub\shields\node_modules\semver\semver.js:828:12
    at Array.map (<anonymous>)
    at Range.parseRange (C:\Users\Dan\Documents\GitHub\shields\node_modules\semver\semver.js:827:13)
    at Range.<anonymous> (C:\Users\Dan\Documents\GitHub\shields\node_modules\semver\semver.js:769:17)
    at Array.map (<anonymous>)
    at new Range (C:\Users\Dan\Documents\GitHub\shields\node_modules\semver\semver.js:768:40)
    at C:\Users\Dan\Documents\GitHub\shields\node_modules\check-node-version\index.js:119:32
    at module.exports (C:\Users\Dan\Documents\GitHub\shields\node_modules\map-values\index.js:9:18)

npm ERR! Windows_NT 10.0.16299
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Dan\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "frontend-depcheck"
npm ERR! node v8.7.0
npm ERR! npm  v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gh-badges@1.3.0 frontend-depcheck: `check-node-version --node '>= 8.0'`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gh-badges@1.3.0 frontend-depcheck script 'check-node-version --node '>= 8.0''.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the gh-badges package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     check-node-version --node '>= 8.0'
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs gh-badges
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls gh-badges
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Dan\AppData\Roaming\npm-cache\_logs\2017-12-04T00_30_04_974Z-debug.log
```

```cmd
npm run server-depcheck

> gh-badges@1.3.0 server-depcheck C:\Users\Dan\Documents\GitHub\shields
> check-node-version --node '>= 6.0 < 9.0'

The system cannot find the file specified.

npm ERR! Windows_NT 10.0.16299
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Dan\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "server-depcheck"
npm ERR! node v8.7.0
npm ERR! npm  v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gh-badges@1.3.0 server-depcheck: `check-node-version --node '>= 6.0 < 9.0'`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gh-badges@1.3.0 server-depcheck script 'check-node-version --node '>= 6.0 < 9.0''.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the gh-badges package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     check-node-version --node '>= 6.0 < 9.0'
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs gh-badges
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls gh-badges
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Dan\AppData\Roaming\npm-cache\_logs\2017-12-04T00_32_13_243Z-debug.log
```

Looks like its due to `'` being used around the version rather than `"`.

This PR Output:
```cmd
npm run frontend-depcheck

> gh-badges@1.3.0 frontend-depcheck C:\Users\Dan\Documents\GitHub\shields
> check-node-version --node ">= 8.0"
```
```cmd
npm run server-depcheck

> gh-badges@1.3.0 server-depcheck C:\Users\Dan\Documents\GitHub\shields
> check-node-version --node ">= 6.0 < 9.0"
```
2017-12-03 19:46:52 -05:00
Paul Melnikow
33690c5555 Fix missing whitespace in usage + footer
Use Fragment support added in React 16.2:

https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-support.html
2017-12-03 15:12:22 -05:00
Paul Melnikow
2be271c22b Frontend: Allow BASE_URL to be unset (#1306)
- Do not use bogus `'undefined'` as base URI
2017-12-01 16:34:31 -05:00
Paul Melnikow
8fa751d0c5 Activating Open Collective (#1295)
See comments in #1250. Gratipay is shutting down.
2017-11-30 14:19:50 -05:00