Service for managing comments on GitHub
Go to file
dependabot[bot] 0931525f87
Bump minimist from 1.2.5 to 1.2.8
Bumps [minimist](https://github.com/minimistjs/minimist) from 1.2.5 to 1.2.8.
- [Release notes](https://github.com/minimistjs/minimist/releases)
- [Changelog](https://github.com/minimistjs/minimist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/minimistjs/minimist/compare/v1.2.5...v1.2.8)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-04 04:50:16 +00:00
src helpers: add more icons for different artifacts 2022-11-23 16:10:43 +01:00
test helpers: add more icons for different artifacts 2022-11-23 16:10:43 +01:00
.dockerignore upgrade Dockerfile to use Node.js 14.17 2021-08-16 20:05:18 +02:00
.gitignore upgrade most nodejs dependencies 2021-08-16 20:16:54 +02:00
Dockerfile upgrade Dockerfile to use Node.js 14.17 2021-08-16 20:05:18 +02:00
LICENSE add MIT license 2018-12-22 12:04:50 +01:00
README.md update README with new API paths and examples 2020-07-07 13:04:53 +02:00
gulpfile.js upgrade most nodejs dependencies 2021-08-16 20:16:54 +02:00
index.js redirect root to status.im site 2021-08-16 20:16:55 +02:00
package.json bump version to 0.5.0 2021-08-16 20:23:25 +02:00
yarn.lock Bump minimist from 1.2.5 to 1.2.8 2023-03-04 04:50:16 +00: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 (UTC) Duration Platform Result
a088572b #3 2018-12-21 12:13:18 ~12 min android 📄log
✔️ a088572b #3 2018-12-21 12:13:53 ~12 min ios 📦api
✔️ a088572b #3 2018-12-21 12:13:34 ~12 min android 📦apk 📲
✔️ a088572b #3 2018-12-21 12:14:44 ~12 min windows 📦exe
⁉️ a088572b #3 2018-12-21 12:15:37 ~13 min macos 📄log
✖️ a088572b #3 2018-12-21 12:16:40 ~12 min linux 📦pkg

API

It exposes 3 calls:

  • GET /builds/:repo/:pr - Return all known builds for given PR in repo.
  • POST /builds/:repo/:pr - Add a new build result and update the PR comment.
  • POST /builds/:repo/:pr/refresh - Re-render the comment for given PR ID.
  • DELETE /builds/:repo/:pr - Delete all known builds for given PR ID in repo.
  • POST /comments - Show currently managed comments in PRs.

By default it listens on localhost:8000.

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 http://localhost:8000/builds/my-repo/7123 -d@/tmp/body.json -H 'Content-Type: application/json'
{ "status": "ok" }

$ curl -s -XPOST http://localhost:8000/builds/my-repo/7123/refresh
{ "status": "ok" }

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 - Self explanatory. (Default: 8000)
  • DB_SAVE_INTERVAL - How often database is written to disk. (Default: 5000)
  • DB_PATH - Path where the LokiJS DB file is stored. (Default: /tmp/builds.db)
  • GH_TOKEN - Required for GitHub API access.
  • GH_REPO_OWNER - Name of owner of repo to manage.
  • GH_REPO_NAMES - Whitelist of names of GitHub repos to manage. (Empty means all)

Building

  • yarn run start - For production use.
  • yarn run devel - For development use.
  • yarn run default - For building use.
  • yarn run release - To create and push the docker image use.