Skip to content

aneksamun/github-contributors-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

[
  {
    "name": "user1",
    "contributions": 2017
  },
  {
    "name": "user2",
    "contributions": 1650
  },
  {
    "name": "user3",
    "contributions": 731
  }
]

How to build?

  • Clone project
  • Build the project
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

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

About

Computes top contributors over the organisation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages