项目作者: aneksamun

项目描述 :
Computes top contributors over the organisation
高级语言: Scala
项目地址: git://github.com/aneksamun/github-contributors-api.git
创建时间: 2021-02-11T18:29:05Z
项目社区:https://github.com/aneksamun/github-contributors-api

开源协议:

下载


GitHub Contributors API

Build status

Given organisation calculates the top contributors by counting thier total contributions over the repositories. The contributors are sorted in descending order to have most active on top.

  1. [
  2. {
  3. "name": "user1",
  4. "contributions": 2017
  5. },
  6. {
  7. "name": "user2",
  8. "contributions": 1650
  9. },
  10. {
  11. "name": "user3",
  12. "contributions": 731
  13. }
  14. ]

How to build?

  • Clone project
  • Build the project
    1. sbt compile

    How to run locally?

    An API is built on top of GitHub REST API v3. First you must create a personal access token if you do not have one and assign it to environment variable with the name GH_TOKEN. The complete list of variables can be found in table.

Table 1: The list of available variables.
|Variable name |Description |Required|Default |
|———————————|———————————————————-|————|———————————-|
|SERVER_HTTP_PORT |Server port |No |8080 |
|SERVER_CACHE_EXPIRY |Cached result expiry |No |30 minutes |
|SERVER_IDLE_TIMEOUT |Server response wait timeout |No |5 minutes |
|SERVER_CLIENT_TIMEOUT |Client response wait timeout |No |1 minute |
|GH_API_URL |GitHub API URL |No |https://api.github.com |
|GH_MAX_CONCURRENT |Max concurrent requests to gather data |No |100 |
|GH_TOKEN |Personal access token |Yes | |
|CIRCUIT_MAX_FAILURES |Circuit opening threshold |No |5 |
|CIRCUIT_RESET_TIMEOUT |Circuit drop timeout |No |10 seconds |

To start service run

  1. sbt run

Once service is running use an address http://localhost:8080/org/{org_name}/contributors where {org_name} is some organisation name.

Technology stack

  • scala 2.13.4 as the main application programming language
  • http4s typeful, functional, streaming HTTP for Scala
  • cats to write more functional and less boilerplate code
  • cats-effect The Haskell IO monad for Scala
  • pureconfig for loading configuration files
  • refined for type constraints avoiding unnecessary testing and biolerplate
  • scalatest and ScalaCheck for unit and property based testing
  • wiremock to mock GitHub server