Skip to content

Commit 649cdf0

Browse files
committed
Big bang refactoring 💣
1 parent 9af577a commit 649cdf0

30 files changed

+748
-9475
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GITHUB_USER_NAME=facebook
2+
GITHUB_REPO_NAME=react
3+
GITHUB_TOKEN=create a new token here https://github.com/settings/tokens/new
4+
DATABASE_PATH=path to your sqlite3 database

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.idea/jsLibraryMappings.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.idea/misc.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.idea/modules.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10.13.0

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
language: node_js
33
node_js:
4-
- '10.15.3'
4+
- '10.13.0'
55
script:
66
- npm install
77
- npm test

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:10.13.0-alpine
2+
3+
ENV APP_PATH /opt/github-metrics
4+
5+
RUN apk add --no-cache bash make gcc g++ python && \
6+
rm -rf /var/cache/apk/*
7+
8+
RUN mkdir -p $APP_PATH
9+
WORKDIR $APP_PATH
10+
11+
COPY . $APP_PATH
12+
RUN rm -rf node_modules/
13+
RUN npm install

README.md

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,56 @@
11
[![Build Status](https://travis-ci.org/matchilling/github-metrics-graphite-exporter.svg?branch=master)](https://travis-ci.org/matchilling/github-metrics-graphite-exporter)
22

3-
# Github PR Metrics Graphite Exporter
3+
# Github Pull Request Metrics
44

55
[![Grafana Example](./data/github-pr-metrics.png)](./data/github-pr-metrics.png)
66

7-
This exporter converts raw GitHub pull request data to time series. The exported data points represent the number of seconds (⏰ business hours only, Mon-Fri 09:00 - 17:00) elapsed between the creation of the pull request and the merging of the pull request.
7+
This exporter converts raw GitHub pull request data to time series. The exported data points represent the number of seconds elapsed between the creation of the pull request and the merging of the pull request.
88

99
The timestamp is the creation time of the PR.
1010

11-
Exposed metrics name: `github.{USER_NAME}.{REPO_NAME}.pull_requests.time_to_merge`
11+
Exposed metrics name: `github.{GITHUB_USER_NAME}.{GITHUB_REPO_NAME}.pull_requests.time_to_merge`
1212

1313
## Usage
1414

1515
```sh
16-
$ npm install
16+
# The user and repo name you want to collect and display metrics
17+
# e.g. https://github.com/facebook/react
18+
# GITHUB_USER_NAME=facebook
19+
# GITHUB_REPO_NAME=react
20+
$ export GITHUB_USER_NAME=github-user-name
21+
$ export GITHUB_REPO_NAME=github-repo-name
22+
23+
# Create a personal access tokens (https://github.com/settings/tokens/new)
24+
$ export GITHUB_TOKEN=github-token
25+
26+
# Path to the SQLite db file to store the collected data
27+
$ export DATABASE_PATH=data/github.db
1728

18-
# At the moment the user name & repo name are only used to build up the metrics path
19-
$ export USER_NAME=github-user-name
20-
$ export REPO_NAME=repository-name
29+
$ npm install
2130

22-
# Path to the SQLite db file containing the PR data retrieved from GitHub.
23-
$ export PULL_REQUESTS_DATABASE_PATH=data/example.db
31+
# Collect data from GitHub
32+
$ npm start collect
2433

2534
# Push data to graphite
26-
$ npm start | nc localhost 2003
35+
$ npm start export | nc localhost 2003
2736

2837
# The generated time series will be written to `stdout`.
2938
# github.github-user-name.repository-name.pull_requests.time_to_merge 3450 1554125772
3039
# github.github-user-name.repository-name.pull_requests.time_to_merge 935617 1553187544
3140
# ...
3241
```
3342

34-
## Todo
43+
You can run the complete stack using [Docker Compose](https://docs.docker.com/compose/), just set your environment variables in the `.env` file in the root project according to the example `.env.example` and run `docker-compose up`.
3544

36-
- [x] Exclude non-business hours from calculation
37-
- [ ] Exclude public holidays from calculation
45+
For example:
46+
```sh
47+
# Note that the `./data` directory is mounted to the docker container, to keep your data persistent place your sqlite database in here
48+
$ cat > .env <<EOL
49+
GITHUB_USER_NAME=facebook
50+
GITHUB_REPO_NAME=react
51+
GITHUB_TOKEN=create a new token here https://github.com/settings/tokens/new
52+
DATABASE_PATH=path to your sqlite3 database e.g. data/github.db
53+
EOL
54+
55+
$ docker-compose up
56+
```

0 commit comments

Comments
 (0)