Service for managing comments on GitHub
Go to file
Jakub Sokołowski 07145a6e92
use loglevel module for logging
Signed-off-by: Jakub Sokołowski <jakub@status.im>
2018-12-20 22:17:13 +01:00
src use loglevel module for logging 2018-12-20 22:17:13 +01:00
test add check for id field 2018-12-20 18:51:19 +01:00
.babelrc add tests for postComment 2018-12-20 16:10:01 +01:00
.gitignore ignore yarn.lock 2018-12-13 23:16:17 +01:00
Dockerfile use loglevel module for logging 2018-12-20 22:17:13 +01:00
README.md add usage examples 2018-12-18 11:47:19 +01:00
gulpfile.js add basic app sources and gulpfile.js 2018-12-12 16:22:15 +01:00
package.json use loglevel module for logging 2018-12-20 22:17:13 +01:00

README.md

Description

This is a minimal REST API intended for use with a Continuous Integration system for managing comments on GitHub.

The problem this solves is posting comments in a PR from multiple builds without spamming the comment section. Instead we post just one comment with a table and continue to update it.

Example Comment


Jenkins Builds

Commit #️⃣ Finished Duration Platform Result
a088572b #3 12:12:55 AM ~12 min android 📄 build log
a088572b #3 12:13:18 AM ~12 min android 📄 build log
✔️ a088572b #3 12:13:53 AM ~12 min ios 📦 package
✔️ a088572b #3 12:13:34 AM ~12 min ios 📦 package
✔️ a088572b #3 12:14:44 AM ~12 min ios 📦 package

API

It exposes just 1 call:

  • POST /builds/:id - Post a comment for PR with given ID.
  • POST /builds/:id/refresh - Update the comment for PR with given ID.
  • POST /comments - Show currently managed comments in PRs.

By default it listens on localhost:8080.

Usage

$ cat << EOF
{
  "id": 1,
  "commit": "7367f3d5",
  "success": true,
  "platform": "linux",
  "duration": "~15 min",
  "url": "https://ci.status.im/job/status-react/job/prs/job/linux/job/PR-7123/1/",
  "pkg_url": "https://status-im-prs.ams3.digitaloceanspaces.com/StatusIm-181212-211210-5157d2-pr.AppImage"
}
EOF >> /tmp/body/json

$ curl -s -XPOST https://localhost:8000/builds/7123 -d@/tmp/body.json -H 'Content-Type: application/json'
{
  "status": "ok"
}                                                                                                                                                                                     sochan@lilim: infra-misc% curl https://clicks.status.im/click                                                                                                    [10/17/18 11:22:50]
$ curl -s -XPOST https://localhost:8000/builds/7123/refresh
{
  "status": "ok"
}                                                                                                                                                                                     sochan@lilim: infra-misc% curl https://clicks.status.im/click                                                                                                    [10/17/18 11:22:50]

You can also check all PRs the application knows about:

$ curl -s http://localhost:8000/comments
{
  "count": 2,
  "comments": [
    {
      "pr": "7000",
      "comment_id": 446940840
    },
    {
      "pr": "7084",
      "comment_id": 446779864
    }
  ]
}

Configuration

There are few environment variables you can set:

  • LISTEN_PORT - Default: 8000

Building

For development use:

npm run start

For building use:

npm run build

To create the docker image use:

npm run image

To push the image use:

npm run push