Merge pull request #1684 from 0xProject/pull-github-data

Pull Github data
This commit is contained in:
Alex Svanevik 2019-03-22 18:33:40 +08:00 committed by GitHub
commit bca44bf9e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 5321 additions and 0 deletions

View File

@ -0,0 +1,31 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';
const table = new Table({
name: 'raw.github_repo',
columns: [
{ name: 'observed_timestamp', type: 'numeric', isPrimary: true },
{ name: 'full_name', type: 'varchar', isPrimary: true },
{ name: 'created_at', type: 'numeric', isNullable: false },
{ name: 'updated_at', type: 'numeric', isNullable: false },
{ name: 'pushed_at', type: 'numeric', isNullable: false },
{ name: 'size', type: 'numeric', isNullable: false },
{ name: 'stargazers', type: 'numeric', isNullable: false },
{ name: 'watchers', type: 'numeric', isNullable: false },
{ name: 'forks', type: 'numeric', isNullable: false },
{ name: 'open_issues', type: 'numeric', isNullable: false },
{ name: 'network', type: 'numeric', isNullable: false },
{ name: 'subscribers', type: 'numeric', isNullable: false },
],
});
export class CreateGithubRepo1552016339539 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.createTable(table);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropTable(table);
}
}

View File

@ -0,0 +1,29 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';
const table = new Table({
name: 'raw.github_pull_request',
columns: [
{ name: 'observed_timestamp', type: 'numeric', isPrimary: true },
{ name: 'repo_full_name', type: 'varchar', isPrimary: true },
{ name: 'pull_request_number', type: 'numeric', isPrimary: true },
{ name: 'title', type: 'varchar', isNullable: false },
{ name: 'state', type: 'varchar', isNullable: false },
{ name: 'user_login', type: 'varchar', isNullable: false },
{ name: 'created_at', type: 'numeric', isNullable: false },
{ name: 'updated_at', type: 'numeric', isNullable: false },
{ name: 'closed_at', type: 'numeric', isNullable: true },
{ name: 'merged_at', type: 'numeric', isNullable: true },
],
});
export class CreateGithubPullRequest1552024155243 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.createTable(table);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropTable(table);
}
}

View File

@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';
const table = new Table({
name: 'raw.github_fork',
columns: [
{ name: 'observed_timestamp', type: 'numeric', isPrimary: true },
{ name: 'full_name', type: 'varchar', isPrimary: true },
{ name: 'owner_login', type: 'varchar', isPrimary: true },
{ name: 'created_at', type: 'numeric', isNullable: false },
{ name: 'updated_at', type: 'numeric', isNullable: false },
{ name: 'pushed_at', type: 'numeric', isNullable: false },
{ name: 'size', type: 'numeric', isNullable: false },
{ name: 'stargazers', type: 'numeric', isNullable: false },
{ name: 'watchers', type: 'numeric', isNullable: false },
{ name: 'forks', type: 'numeric', isNullable: false },
{ name: 'open_issues', type: 'numeric', isNullable: false },
{ name: 'network', type: 'numeric', isNullable: true },
{ name: 'subscribers', type: 'numeric', isNullable: true },
{ name: 'default_branch', type: 'varchar', isNullable: false },
{ name: 'status', type: 'varchar', isNullable: true },
{ name: 'ahead_by', type: 'numeric', isNullable: true },
{ name: 'behind_by', type: 'numeric', isNullable: true },
{ name: 'total_commits', type: 'numeric', isNullable: true },
],
});
export class CreateGithubFork1552044685566 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.createTable(table);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropTable(table);
}
}

View File

@ -0,0 +1,33 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';
const table = new Table({
name: 'raw.github_issue',
columns: [
{ name: 'observed_timestamp', type: 'numeric', isPrimary: true },
{ name: 'repo_full_name', type: 'varchar', isPrimary: true },
{ name: 'issue_number', type: 'numeric', isPrimary: true },
{ name: 'title', type: 'varchar', isNullable: false },
{ name: 'state', type: 'varchar', isNullable: false },
{ name: 'locked', type: 'boolean', isNullable: false },
{ name: 'user_login', type: 'varchar', isNullable: false },
{ name: 'user_type', type: 'varchar', isNullable: false },
{ name: 'user_site_admin', type: 'boolean', isNullable: false },
{ name: 'assignee_login', type: 'varchar', isNullable: true },
{ name: 'comments', type: 'numeric', isNullable: false },
{ name: 'created_at', type: 'numeric', isNullable: false },
{ name: 'updated_at', type: 'numeric', isNullable: false },
{ name: 'closed_at', type: 'numeric', isNullable: true },
],
});
export class CreateGithubIssue1552457956065 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.createTable(table);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropTable(table);
}
}

View File

@ -0,0 +1,152 @@
import { fetchAsync, logUtils } from '@0x/utils';
import Bottleneck from 'bottleneck';
const ONE_SECOND = 1000;
export interface GithubRepoResponse {
full_name: string;
created_at: string;
updated_at: string;
pushed_at: string;
size: number;
stargazers_count: number;
watchers_count: number;
forks: number;
open_issues: number;
network_count: number;
subscribers_count: number;
}
export interface GithubPullRequestResponse {
number: number;
title: string;
state: string;
created_at: string;
updated_at: string;
closed_at: string;
merged_at: string;
user: {
login: string;
};
base: {
repo: {
full_name: string;
};
};
}
export interface GithubForkResponse extends GithubRepoResponse {
owner: {
login: string;
};
default_branch: string;
}
export interface GithubComparisonResponse {
status: string;
ahead_by: number;
behind_by: number;
total_commits: number;
}
export interface GithubIssueResponse {
number: number;
title: string;
state: string;
locked: boolean;
assignee?: {
login?: string;
};
created_at: string;
updated_at: string;
closed_at: string;
user: {
login: string;
type: string;
site_admin: boolean;
};
comments: number;
}
// tslint:disable:prefer-function-over-method
// ^ Keep consistency with other sources and help logical organization
export class GithubSource {
// rate-limit for all API calls through this class instance
private readonly _limiter: Bottleneck;
private readonly _urlBase: string = 'https://api.github.com';
private readonly _owner: string;
private readonly _repo: string;
private readonly _branch: string;
private readonly _accessToken: string;
constructor(owner: string, repo: string, branch: string, accessToken: string, maxReqsPerSecond: number) {
this._owner = owner;
this._repo = repo;
this._branch = branch;
this._accessToken = accessToken;
this._limiter = new Bottleneck({
minTime: ONE_SECOND / maxReqsPerSecond,
});
}
/**
* Call Github API for repo and return result.
*/
public async getGithubRepoAsync(): Promise<GithubRepoResponse> {
const url = `${this._urlBase}/repos/${this._owner}/${this._repo}?access_token=${this._accessToken}`;
const resp = await this._limiter.schedule(() => fetchAsync(url));
const respJson: GithubRepoResponse = await resp.json();
return respJson;
}
/**
* Call Github API for pull requests and return result - paginated.
*/
public async getGithubPullsAsync(page: number): Promise<GithubPullRequestResponse[]> {
const url = `${this._urlBase}/repos/${this._owner}/${this._repo}/pulls?access_token=${
this._accessToken
}&state=all&per_page=100&page=${page}`;
const resp = await this._limiter.schedule(() => fetchAsync(url));
const respJson: GithubPullRequestResponse[] = await resp.json();
return respJson;
}
/**
* Call Github API for forks of repo and return result - paginated.
*/
public async getGithubForksAsync(page: number): Promise<GithubForkResponse[]> {
const url = `${this._urlBase}/repos/${this._owner}/${this._repo}/forks?access_token=${
this._accessToken
}&per_page=100&page=${page}`;
const resp = await this._limiter.schedule(() => fetchAsync(url));
const respJson: GithubForkResponse[] = await resp.json();
return respJson;
}
/**
* Call Github API to get commit status of a fork vs repo's main branch.
*/
public async getGithubComparisonAsync(forkOwner: string, forkBranch: string): Promise<GithubComparisonResponse> {
const url = `${this._urlBase}/repos/${this._owner}/${this._repo}/compare/${
this._branch
}...${forkOwner}:${forkBranch}?access_token=${this._accessToken}`;
const resp = await this._limiter.schedule(() => fetchAsync(url));
const respJson: GithubComparisonResponse = await resp.json();
return respJson;
}
/**
* Call Github API for pull requests and return result - paginated.
*/
public async getGithubIssuesAsync(page: number): Promise<GithubIssueResponse[]> {
const url = `${this._urlBase}/repos/${this._owner}/${this._repo}/issues?access_token=${
this._accessToken
}&state=all&per_page=100&page=${page}`;
const resp = await this._limiter.schedule(() => fetchAsync(url));
const respJson: GithubIssueResponse[] = await resp.json();
if (!respJson[0]) {
logUtils.log(respJson);
}
return respJson;
}
}

View File

@ -0,0 +1,60 @@
import { Column, Entity, PrimaryColumn } from 'typeorm';
import { numberToBigIntTransformer } from '../utils';
@Entity({ name: 'github_fork', schema: 'raw' })
export class GithubFork {
@PrimaryColumn({ name: 'observed_timestamp', type: 'bigint', transformer: numberToBigIntTransformer })
public observedTimestamp!: number;
@PrimaryColumn({ name: 'full_name' })
public fullName!: string;
@PrimaryColumn({ name: 'owner_login' })
public ownerLogin!: string;
@Column({ name: 'created_at', type: 'bigint', transformer: numberToBigIntTransformer })
public createdAt!: number;
@Column({ name: 'updated_at', type: 'bigint', transformer: numberToBigIntTransformer })
public updatedAt!: number;
@Column({ name: 'pushed_at', type: 'bigint', transformer: numberToBigIntTransformer })
public pushedAt!: number;
@Column({ name: 'size', transformer: numberToBigIntTransformer })
public size!: number;
@Column({ name: 'stargazers', transformer: numberToBigIntTransformer })
public stargazers!: number;
@Column({ name: 'watchers', transformer: numberToBigIntTransformer })
public watchers!: number;
@Column({ name: 'forks', transformer: numberToBigIntTransformer })
public forks!: number;
@Column({ name: 'open_issues', transformer: numberToBigIntTransformer })
public openIssues!: number;
@Column({ name: 'network', transformer: numberToBigIntTransformer, nullable: true })
public network?: number;
@Column({ name: 'subscribers', transformer: numberToBigIntTransformer, nullable: true })
public subscribers?: number;
@Column({ name: 'default_branch' })
public defaultBranch!: string;
@Column({ name: 'status', nullable: true })
public status?: string;
@Column({ name: 'ahead_by', transformer: numberToBigIntTransformer, nullable: true })
public aheadBy?: number;
@Column({ name: 'behind_by', transformer: numberToBigIntTransformer, nullable: true })
public behindBy?: number;
@Column({ name: 'total_commits', transformer: numberToBigIntTransformer, nullable: true })
public totalCommits?: number;
}

View File

@ -0,0 +1,48 @@
import { Column, Entity, PrimaryColumn } from 'typeorm';
import { numberToBigIntTransformer } from '../utils';
@Entity({ name: 'github_issue', schema: 'raw' })
export class GithubIssue {
@PrimaryColumn({ name: 'observed_timestamp', type: 'bigint', transformer: numberToBigIntTransformer })
public observedTimestamp!: number;
@PrimaryColumn({ name: 'repo_full_name' })
public repoFullName!: string;
@PrimaryColumn({ name: 'issue_number', transformer: numberToBigIntTransformer })
public issueNumber!: number;
@Column({ name: 'title' })
public title!: string;
@Column({ name: 'state' })
public state!: string;
@Column({ name: 'locked', type: 'boolean' })
public locked!: boolean;
@Column({ name: 'assignee_login', type: 'varchar', nullable: true })
public assigneeLogin?: string;
@Column({ name: 'user_login' })
public userLogin!: string;
@Column({ name: 'user_type' })
public userType!: string;
@Column({ name: 'user_site_admin', type: 'boolean' })
public userSiteAdmin!: boolean;
@Column({ name: 'comments', transformer: numberToBigIntTransformer })
public comments!: number;
@Column({ name: 'created_at', type: 'bigint', transformer: numberToBigIntTransformer })
public createdAt!: number;
@Column({ name: 'updated_at', type: 'bigint', transformer: numberToBigIntTransformer })
public updatedAt!: number;
@Column({ name: 'closed_at', type: 'bigint', transformer: numberToBigIntTransformer, nullable: true })
public closedAt?: number;
}

View File

@ -0,0 +1,36 @@
import { Column, Entity, PrimaryColumn } from 'typeorm';
import { numberToBigIntTransformer } from '../utils';
@Entity({ name: 'github_pull_request', schema: 'raw' })
export class GithubPullRequest {
@PrimaryColumn({ name: 'observed_timestamp', type: 'bigint', transformer: numberToBigIntTransformer })
public observedTimestamp!: number;
@PrimaryColumn({ name: 'repo_full_name' })
public repoFullName!: string;
@PrimaryColumn({ name: 'pull_request_number', transformer: numberToBigIntTransformer })
public pullRequestNumber!: number;
@Column({ name: 'created_at', type: 'bigint', transformer: numberToBigIntTransformer })
public createdAt!: number;
@Column({ name: 'updated_at', type: 'bigint', transformer: numberToBigIntTransformer })
public updatedAt!: number;
@Column({ name: 'closed_at', type: 'bigint', transformer: numberToBigIntTransformer })
public closedAt?: number | null;
@Column({ name: 'merged_at', type: 'bigint', transformer: numberToBigIntTransformer })
public mergedAt?: number | null;
@Column({ name: 'state' })
public state!: string;
@Column({ name: 'title' })
public title!: string;
@Column({ name: 'user_login' })
public userLogin!: string;
}

View File

@ -0,0 +1,42 @@
import { Column, Entity, PrimaryColumn } from 'typeorm';
import { numberToBigIntTransformer } from '../utils';
@Entity({ name: 'github_repo', schema: 'raw' })
export class GithubRepo {
@PrimaryColumn({ name: 'observed_timestamp', type: 'bigint', transformer: numberToBigIntTransformer })
public observedTimestamp!: number;
@PrimaryColumn({ name: 'full_name' })
public fullName!: string;
@Column({ name: 'created_at', type: 'bigint', transformer: numberToBigIntTransformer })
public createdAt!: number;
@Column({ name: 'updated_at', type: 'bigint', transformer: numberToBigIntTransformer })
public updatedAt!: number;
@Column({ name: 'pushed_at', type: 'bigint', transformer: numberToBigIntTransformer })
public pushedAt!: number;
@Column({ name: 'size', transformer: numberToBigIntTransformer })
public size!: number;
@Column({ name: 'stargazers', transformer: numberToBigIntTransformer })
public stargazers!: number;
@Column({ name: 'watchers', transformer: numberToBigIntTransformer })
public watchers!: number;
@Column({ name: 'forks', transformer: numberToBigIntTransformer })
public forks!: number;
@Column({ name: 'open_issues', transformer: numberToBigIntTransformer })
public openIssues!: number;
@Column({ name: 'network', transformer: numberToBigIntTransformer })
public network?: number;
@Column({ name: 'subscribers', transformer: numberToBigIntTransformer })
public subscribers?: number;
}

View File

@ -8,6 +8,10 @@ export { EtherscanTransaction } from './etherscan_transaction';
export { ExchangeCancelEvent } from './exchange_cancel_event'; export { ExchangeCancelEvent } from './exchange_cancel_event';
export { ExchangeCancelUpToEvent } from './exchange_cancel_up_to_event'; export { ExchangeCancelUpToEvent } from './exchange_cancel_up_to_event';
export { ExchangeFillEvent } from './exchange_fill_event'; export { ExchangeFillEvent } from './exchange_fill_event';
export { GithubFork } from './github_fork';
export { GithubIssue } from './github_issue';
export { GithubRepo } from './github_repo';
export { GithubPullRequest } from './github_pull_request';
export { GreenhouseApplication } from './greenhouse_application'; export { GreenhouseApplication } from './greenhouse_application';
export { NonfungibleDotComTrade } from './nonfungible_dot_com_trade'; export { NonfungibleDotComTrade } from './nonfungible_dot_com_trade';
export { OHLCVExternal } from './ohlcv_external'; export { OHLCVExternal } from './ohlcv_external';

View File

@ -13,6 +13,10 @@ import {
ExchangeCancelEvent, ExchangeCancelEvent,
ExchangeCancelUpToEvent, ExchangeCancelUpToEvent,
ExchangeFillEvent, ExchangeFillEvent,
GithubFork,
GithubIssue,
GithubPullRequest,
GithubRepo,
GreenhouseApplication, GreenhouseApplication,
NonfungibleDotComTrade, NonfungibleDotComTrade,
OHLCVExternal, OHLCVExternal,
@ -38,6 +42,11 @@ const entities = [
ExchangeCancelEvent, ExchangeCancelEvent,
ExchangeCancelUpToEvent, ExchangeCancelUpToEvent,
ExchangeFillEvent, ExchangeFillEvent,
ERC20ApprovalEvent,
GithubFork,
GithubIssue,
GithubPullRequest,
GithubRepo,
GreenhouseApplication, GreenhouseApplication,
NonfungibleDotComTrade, NonfungibleDotComTrade,
OHLCVExternal, OHLCVExternal,

View File

@ -0,0 +1,43 @@
import { GithubComparisonResponse, GithubForkResponse } from '../../data_sources/github';
import { GithubFork } from '../../entities';
/**
* Converts a Github response from the API into a GithubFork entity.
* @param response A Github response from the API.
*/
export function parseGithubForks(response: GithubForkResponse[], observedTimestamp: number): GithubFork[] {
const result: GithubFork[] = response.map(fork => {
const parsedFork = new GithubFork();
parsedFork.observedTimestamp = observedTimestamp;
parsedFork.fullName = fork.full_name;
parsedFork.ownerLogin = fork.owner.login;
parsedFork.createdAt = Date.parse(fork.created_at);
parsedFork.updatedAt = Date.parse(fork.updated_at);
parsedFork.pushedAt = Date.parse(fork.pushed_at);
parsedFork.size = fork.size;
parsedFork.stargazers = fork.stargazers_count;
parsedFork.watchers = fork.watchers_count;
parsedFork.forks = fork.forks;
parsedFork.openIssues = fork.open_issues;
parsedFork.network = fork.network_count;
parsedFork.subscribers = fork.subscribers_count;
parsedFork.defaultBranch = fork.default_branch;
return parsedFork;
});
return result;
}
/**
* Extends a GithubFork object with additional comparison fields.
*/
export function enrichGithubForkWithComparisonDetails(
githubFork: GithubFork,
comparisonResponse: GithubComparisonResponse,
): GithubFork {
const enrichedGithubFork = { ...githubFork }; // clone object
enrichedGithubFork.status = comparisonResponse.status;
enrichedGithubFork.aheadBy = comparisonResponse.ahead_by;
enrichedGithubFork.behindBy = comparisonResponse.behind_by;
enrichedGithubFork.totalCommits = comparisonResponse.total_commits;
return enrichedGithubFork;
}

View File

@ -0,0 +1,4 @@
export { enrichGithubForkWithComparisonDetails, parseGithubForks } from './forks';
export { parseGithubIssues } from './issues';
export { parseGithubRepo } from './repo';
export { parseGithubPulls } from './pulls';

View File

@ -0,0 +1,35 @@
import { GithubIssueResponse } from '../../data_sources/github';
import { GithubIssue } from '../../entities';
/**
* Converts a Github response from the API into an array GithubIssue entity.
* @param response A Github response from the API.
* @param observedTimestamp The timestamp to record for the observation of the entities.
*/
export function parseGithubIssues(
response: GithubIssueResponse[],
observedTimestamp: number,
repoFullName: string,
): GithubIssue[] {
const emptyResponse: GithubIssue[] = [];
return response && response[0]
? response.map(issue => {
const parsedIssue = new GithubIssue();
parsedIssue.observedTimestamp = observedTimestamp;
parsedIssue.repoFullName = repoFullName;
parsedIssue.issueNumber = issue.number;
parsedIssue.title = issue.title;
parsedIssue.state = issue.state;
parsedIssue.locked = issue.locked;
parsedIssue.assigneeLogin = issue.assignee ? issue.assignee.login : undefined;
parsedIssue.userLogin = issue.user.login;
parsedIssue.userType = issue.user.type;
parsedIssue.userSiteAdmin = issue.user.site_admin;
parsedIssue.comments = issue.comments;
parsedIssue.createdAt = Date.parse(issue.created_at);
parsedIssue.updatedAt = Date.parse(issue.updated_at);
parsedIssue.closedAt = issue.closed_at ? Date.parse(issue.closed_at) : undefined;
return parsedIssue;
})
: emptyResponse;
}

View File

@ -0,0 +1,26 @@
import { GithubPullRequestResponse } from '../../data_sources/github';
import { GithubPullRequest } from '../../entities';
/**
* Converts a Github response from the API into an GithubRepo entity.
* @param rawRepo A Github response from the API into an GithubRepo entity.
*/
export function parseGithubPulls(
response: GithubPullRequestResponse[],
observedTimestamp: number,
): GithubPullRequest[] {
return response.map(pull => {
const parsedPullRequest = new GithubPullRequest();
parsedPullRequest.observedTimestamp = observedTimestamp;
parsedPullRequest.repoFullName = pull.base.repo.full_name;
parsedPullRequest.createdAt = Date.parse(pull.created_at);
parsedPullRequest.updatedAt = Date.parse(pull.updated_at);
parsedPullRequest.closedAt = pull.closed_at ? Date.parse(pull.closed_at) : null;
parsedPullRequest.mergedAt = pull.merged_at ? Date.parse(pull.merged_at) : null;
parsedPullRequest.pullRequestNumber = pull.number;
parsedPullRequest.state = pull.state;
parsedPullRequest.title = pull.title;
parsedPullRequest.userLogin = pull.user.login;
return parsedPullRequest;
});
}

View File

@ -0,0 +1,23 @@
import { GithubRepoResponse } from '../../data_sources/github';
import { GithubRepo } from '../../entities';
/**
* Converts a Github response from the API into an GithubRepo entity.
* @param rawRepo A Github response from the API into an GithubRepo entity.
*/
export function parseGithubRepo(rawRepo: GithubRepoResponse, observedTimestamp: number): GithubRepo {
const parsedRepo = new GithubRepo();
parsedRepo.observedTimestamp = observedTimestamp;
parsedRepo.fullName = rawRepo.full_name;
parsedRepo.createdAt = Date.parse(rawRepo.created_at);
parsedRepo.updatedAt = Date.parse(rawRepo.updated_at);
parsedRepo.pushedAt = Date.parse(rawRepo.pushed_at);
parsedRepo.size = rawRepo.size;
parsedRepo.stargazers = rawRepo.stargazers_count;
parsedRepo.watchers = rawRepo.watchers_count;
parsedRepo.forks = rawRepo.forks;
parsedRepo.openIssues = rawRepo.open_issues;
parsedRepo.network = rawRepo.network_count;
parsedRepo.subscribers = rawRepo.subscribers_count;
return parsedRepo;
}

View File

@ -0,0 +1,109 @@
import { Connection, ConnectionOptions, createConnection } from 'typeorm';
import { logUtils } from '@0x/utils';
import { GithubSource } from '../data_sources/github';
import { GithubFork, GithubIssue, GithubPullRequest, GithubRepo } from '../entities';
import * as ormConfig from '../ormconfig';
import {
enrichGithubForkWithComparisonDetails,
parseGithubForks,
parseGithubIssues,
parseGithubPulls,
parseGithubRepo,
} from '../parsers/github';
import { handleError } from '../utils';
const GITHUB_OWNER = '0xProject';
const GITHUB_REPO = '0x-monorepo';
const GITHUB_BRANCH = 'development';
const RECORDS_PER_PAGE = 100;
const MAX_REQUESTS_PER_SECOND = 1;
let connection: Connection;
(async () => {
connection = await createConnection(ormConfig as ConnectionOptions);
const accessToken = process.env.GITHUB_ACCESS_TOKEN;
if (accessToken === undefined) {
throw new Error('Missing required env var: GITHUB_ACCESS_TOKEN');
}
const githubSource = new GithubSource(
GITHUB_OWNER,
GITHUB_REPO,
GITHUB_BRANCH,
accessToken,
MAX_REQUESTS_PER_SECOND,
);
const observedTimestamp = Date.now();
// get repo and save
const GithubRepoRepository = connection.getRepository(GithubRepo);
logUtils.log('Fetching Github repo from API.');
const rawRepo = await githubSource.getGithubRepoAsync();
const repo = parseGithubRepo(rawRepo, observedTimestamp);
logUtils.log('Saving Github repo to database.');
await GithubRepoRepository.save(repo);
// get pull requests and save
const GithubPullRequestRepository = connection.getRepository(GithubPullRequest);
let numberOfRecords = RECORDS_PER_PAGE;
let page = 1;
while (numberOfRecords === RECORDS_PER_PAGE) {
logUtils.log(`Fetching Github pull requests from API, page: ${page}.`);
const rawPulls = await githubSource.getGithubPullsAsync(page);
const pulls = parseGithubPulls(rawPulls, observedTimestamp);
numberOfRecords = pulls.length;
page++;
logUtils.log(`Saving ${pulls.length} pull requests to database.`);
await GithubPullRequestRepository.save(pulls);
}
// get forks and save
const GithubForkRepository = connection.getRepository(GithubFork);
numberOfRecords = RECORDS_PER_PAGE;
page = 1;
while (numberOfRecords === RECORDS_PER_PAGE) {
logUtils.log(`Fetching Github forks from API, page: ${page}.`);
const rawForks = await githubSource.getGithubForksAsync(page);
const forks = parseGithubForks(rawForks, observedTimestamp);
logUtils.log('Fetching compare stats for each fork from API.');
const enrichedForks = await Promise.all(
forks.map(async fork => {
const comparison = await githubSource.getGithubComparisonAsync(fork.ownerLogin, fork.defaultBranch);
const enriched = enrichGithubForkWithComparisonDetails(fork, comparison);
return enriched;
}),
);
numberOfRecords = enrichedForks.length;
page++;
logUtils.log(`Saving ${enrichedForks.length} forks to database.`);
await GithubForkRepository.save(enrichedForks);
}
// get issues and save
const GithubIssueRepository = connection.getRepository(GithubIssue);
numberOfRecords = RECORDS_PER_PAGE;
page = 1;
const maxAttempts = 3;
const repoFullName = `${GITHUB_OWNER}/${GITHUB_REPO}`;
while (numberOfRecords === RECORDS_PER_PAGE) {
let rawIssues;
let issues;
let attempt = 1;
do {
logUtils.log(`Fetching Github issues from API, page: ${page}.`);
if (attempt > 1) {
logUtils.log(`Attempt #${attempt}`);
}
rawIssues = await githubSource.getGithubIssuesAsync(page);
issues = parseGithubIssues(rawIssues, observedTimestamp, repoFullName);
} while (issues.length === 0 && attempt++ < maxAttempts); // Github API returns no records
numberOfRecords = issues.length;
page++;
logUtils.log(`Saving ${issues.length} issues to database.`);
await GithubIssueRepository.save(issues);
}
process.exit(0);
})().catch(handleError);

View File

@ -0,0 +1,109 @@
import 'mocha';
import 'reflect-metadata';
import { GithubFork, GithubIssue, GithubPullRequest, GithubRepo } from '../../src/entities';
import { createDbConnectionOnceAsync } from '../db_setup';
import { chaiSetup } from '../utils/chai_setup';
import { testSaveAndFindEntityAsync } from './util';
chaiSetup.configure();
// tslint:disable:custom-no-magic-numbers
const fork: GithubFork = {
observedTimestamp: Date.now(),
fullName: 'NoahZinsmeister/0x-monorepo',
ownerLogin: 'NoahZinsmeister',
createdAt: 1552181010000,
updatedAt: 1552191123000,
pushedAt: 1552191120000,
size: 86271,
stargazers: 0,
watchers: 0,
forks: 0,
openIssues: 0,
network: undefined,
subscribers: undefined,
defaultBranch: 'development',
status: 'ahead',
aheadBy: 1,
behindBy: 0,
totalCommits: 1,
};
const issue: GithubIssue = {
observedTimestamp: Date.now(),
repoFullName: '0xProject/0x-monorepo',
issueNumber: 1691,
title: 'An in-range update of source-map-support is breaking the build',
state: 'open',
locked: false,
assigneeLogin: undefined,
userLogin: 'greenkeeper[bot]',
userType: 'Bot',
userSiteAdmin: false,
comments: 1,
createdAt: Date.parse('2019-03-12T17:30:58Z'),
updatedAt: Date.parse('2019-03-12T17:32:26Z'),
closedAt: undefined,
};
const pullRequest: GithubPullRequest = {
observedTimestamp: Date.now(),
repoFullName: '0xProject/0x-monorepo',
pullRequestNumber: 1684,
state: 'open',
title: '[WIP] Pull Github data',
userLogin: 'askeluv',
createdAt: 1552019788000,
updatedAt: 1552019788000,
closedAt: null,
mergedAt: null,
};
const repo: GithubRepo = {
observedTimestamp: Date.now(),
fullName: '0xProject/0x-monorepo',
createdAt: 1495549053000,
updatedAt: 1551908929000,
pushedAt: 1551916745000,
size: 86538,
stargazers: 989,
watchers: 989,
forks: 294,
openIssues: 46,
network: 294,
subscribers: 89,
};
describe('GithubFork entity', () => {
it('save/find', async () => {
const connection = await createDbConnectionOnceAsync();
const forkRepository = connection.getRepository(GithubFork);
await testSaveAndFindEntityAsync(forkRepository, fork);
});
});
describe('GithubIssue entity', () => {
it('save/find', async () => {
const connection = await createDbConnectionOnceAsync();
const issueRepository = connection.getRepository(GithubIssue);
await testSaveAndFindEntityAsync(issueRepository, issue);
});
});
describe('GithubPullRequest entity', () => {
it('save/find', async () => {
const connection = await createDbConnectionOnceAsync();
const pullRequestRepository = connection.getRepository(GithubPullRequest);
await testSaveAndFindEntityAsync(pullRequestRepository, pullRequest);
});
});
describe('GithubRepo entity', () => {
it('save/find', async () => {
const connection = await createDbConnectionOnceAsync();
const repoRepository = connection.getRepository(GithubRepo);
await testSaveAndFindEntityAsync(repoRepository, repo);
});
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,101 @@
[
{
"id": 174764562,
"node_id": "MDEwOlJlcG9zaXRvcnkxNzQ3NjQ1NjI=",
"name": "0x-monorepo",
"full_name": "NoahZinsmeister/0x-monorepo",
"private": false,
"owner": {
"login": "NoahZinsmeister",
"id": 3760414,
"node_id": "MDQ6VXNlcjM3NjA0MTQ=",
"avatar_url": "https://avatars3.githubusercontent.com/u/3760414?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/NoahZinsmeister",
"html_url": "https://github.com/NoahZinsmeister",
"followers_url": "https://api.github.com/users/NoahZinsmeister/followers",
"following_url": "https://api.github.com/users/NoahZinsmeister/following{/other_user}",
"gists_url": "https://api.github.com/users/NoahZinsmeister/gists{/gist_id}",
"starred_url": "https://api.github.com/users/NoahZinsmeister/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/NoahZinsmeister/subscriptions",
"organizations_url": "https://api.github.com/users/NoahZinsmeister/orgs",
"repos_url": "https://api.github.com/users/NoahZinsmeister/repos",
"events_url": "https://api.github.com/users/NoahZinsmeister/events{/privacy}",
"received_events_url": "https://api.github.com/users/NoahZinsmeister/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/NoahZinsmeister/0x-monorepo",
"description": "0x protocol monorepo - includes our smart contracts and many developer tools",
"fork": true,
"url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo",
"forks_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/forks",
"keys_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/teams",
"hooks_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/hooks",
"issue_events_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/issues/events{/number}",
"events_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/events",
"assignees_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/assignees{/user}",
"branches_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/branches{/branch}",
"tags_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/tags",
"blobs_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/statuses/{sha}",
"languages_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/languages",
"stargazers_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/stargazers",
"contributors_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/contributors",
"subscribers_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/subscribers",
"subscription_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/subscription",
"commits_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/contents/{+path}",
"compare_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/merges",
"archive_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/downloads",
"issues_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/issues{/number}",
"pulls_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/pulls{/number}",
"milestones_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/milestones{/number}",
"notifications_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/labels{/name}",
"releases_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/releases{/id}",
"deployments_url": "https://api.github.com/repos/NoahZinsmeister/0x-monorepo/deployments",
"created_at": "2019-03-10T01:23:30Z",
"updated_at": "2019-03-10T04:12:03Z",
"pushed_at": "2019-03-10T04:12:00Z",
"git_url": "git://github.com/NoahZinsmeister/0x-monorepo.git",
"ssh_url": "git@github.com:NoahZinsmeister/0x-monorepo.git",
"clone_url": "https://github.com/NoahZinsmeister/0x-monorepo.git",
"svn_url": "https://github.com/NoahZinsmeister/0x-monorepo",
"homepage": "",
"size": 86271,
"stargazers_count": 0,
"watchers_count": 0,
"language": "TypeScript",
"has_issues": false,
"has_projects": true,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"open_issues_count": 0,
"license": {
"key": "other",
"name": "Other",
"spdx_id": "NOASSERTION",
"url": null,
"node_id": "MDc6TGljZW5zZTA="
},
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "development"
}
]

View File

@ -0,0 +1,36 @@
import { GithubFork } from '../../../src/entities';
// To re-create the JSON files from the API (e.g. if the API output schema changes), run the below commands:
// (1) Forks:
// curl https://api.github.com/repos/0xProject/0x-monorepo/forks?per_page=1&page=1
// docs here: https://developer.github.com/v3/repos/forks/#list-forks
// (2) Comparisons:
// curl https://api.github.com/repos/0xProject/0x-monorepo/compare/development...NoahZinsmeister:development
// --> (replace the last part with the fork owner + branch that you get from the Fork API response)
// docs here: https://developer.github.com/v3/repos/commits/#compare-two-commits
const ParsedGithubFork = new GithubFork();
ParsedGithubFork.observedTimestamp = Date.now();
ParsedGithubFork.fullName = 'NoahZinsmeister/0x-monorepo';
ParsedGithubFork.ownerLogin = 'NoahZinsmeister';
ParsedGithubFork.createdAt = 1552181010000; // tslint:disable-line:custom-no-magic-numbers
ParsedGithubFork.updatedAt = 1552191123000; // tslint:disable-line:custom-no-magic-numbers
ParsedGithubFork.pushedAt = 1552191120000; // tslint:disable-line:custom-no-magic-numbers
ParsedGithubFork.size = 86271; // tslint:disable-line:custom-no-magic-numbers
ParsedGithubFork.stargazers = 0;
ParsedGithubFork.watchers = 0;
ParsedGithubFork.forks = 0;
ParsedGithubFork.openIssues = 0;
ParsedGithubFork.network = undefined;
ParsedGithubFork.subscribers = undefined;
ParsedGithubFork.defaultBranch = 'development';
const EnrichedGithubFork = { ...ParsedGithubFork }; // clone the above
EnrichedGithubFork.status = 'ahead';
EnrichedGithubFork.aheadBy = 1;
EnrichedGithubFork.behindBy = 0;
EnrichedGithubFork.totalCommits = 1;
export { ParsedGithubFork, EnrichedGithubFork };

View File

@ -0,0 +1,55 @@
[
{
"url": "https://api.github.com/repos/0xProject/0x-monorepo/issues/1691",
"repository_url": "https://api.github.com/repos/0xProject/0x-monorepo",
"labels_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues/1691/labels{/name}",
"comments_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues/1691/comments",
"events_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues/1691/events",
"html_url": "https://github.com/0xProject/0x-monorepo/issues/1691",
"id": 420115585,
"node_id": "MDU6SXNzdWU0MjAxMTU1ODU=",
"number": 1691,
"title": "An in-range update of source-map-support is breaking the build 🚨",
"user": {
"login": "greenkeeper[bot]",
"id": 23040076,
"node_id": "MDM6Qm90MjMwNDAwNzY=",
"avatar_url": "https://avatars3.githubusercontent.com/in/505?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/greenkeeper%5Bbot%5D",
"html_url": "https://github.com/apps/greenkeeper",
"followers_url": "https://api.github.com/users/greenkeeper%5Bbot%5D/followers",
"following_url": "https://api.github.com/users/greenkeeper%5Bbot%5D/following{/other_user}",
"gists_url": "https://api.github.com/users/greenkeeper%5Bbot%5D/gists{/gist_id}",
"starred_url": "https://api.github.com/users/greenkeeper%5Bbot%5D/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/greenkeeper%5Bbot%5D/subscriptions",
"organizations_url": "https://api.github.com/users/greenkeeper%5Bbot%5D/orgs",
"repos_url": "https://api.github.com/users/greenkeeper%5Bbot%5D/repos",
"events_url": "https://api.github.com/users/greenkeeper%5Bbot%5D/events{/privacy}",
"received_events_url": "https://api.github.com/users/greenkeeper%5Bbot%5D/received_events",
"type": "Bot",
"site_admin": false
},
"labels": [
{
"id": 618533621,
"node_id": "MDU6TGFiZWw2MTg1MzM2MjE=",
"url": "https://api.github.com/repos/0xProject/0x-monorepo/labels/greenkeeper",
"name": "greenkeeper",
"color": "00c775",
"default": false
}
],
"state": "open",
"locked": false,
"assignee": null,
"assignees": [],
"milestone": null,
"comments": 1,
"created_at": "2019-03-12T17:30:58Z",
"updated_at": "2019-03-12T17:32:26Z",
"closed_at": null,
"author_association": "CONTRIBUTOR",
"body": "\n## The devDependency [source-map-support](https://github.com/evanw/node-source-map-support) was updated from `0.5.10` to `0.5.11`.\n\n🚨 [View failing branch](https://github.com/0xProject/0x-monorepo/compare/development...0xProject:greenkeeper%2Fsource-map-support-0.5.11).\n\nThis version is **covered** by your **current version range** and after updating it in your project **the build failed**.\n\n\n\n\nsource-map-support is a devDependency of this project. It **might not break your production code or affect downstream projects**, but probably breaks your build or test tools, which may **prevent deploying or publishing**.\n\n\n\n<details>\n<summary>Status Details</summary>\n\n- ❌ **ci/circleci: build:** Your tests failed on CircleCI ([Details](https://circleci.com/gh/0xProject/0x-monorepo/65642?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link)).\n- ✅ **ci/circleci: test-python:** Your tests passed on CircleCI! ([Details](https://circleci.com/gh/0xProject/0x-monorepo/65641?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link)).\n- ✅ **ci/circleci: static-tests-python:** Your tests passed on CircleCI! ([Details](https://circleci.com/gh/0xProject/0x-monorepo/65643?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link)).\n</details>\n\n\n---\n\n<details>\n<summary>Commits</summary>\n<p>The new version differs by 6 commits.</p>\n<ul>\n<li><a href=\"https://urls.greenkeeper.io/evanw/node-source-map-support/commit/6035ef534325864f396befc4028da7f0fdbcaaa4\"><code>6035ef5</code></a> <code>0.5.11</code></li>\n<li><a href=\"https://urls.greenkeeper.io/evanw/node-source-map-support/commit/f70e1caf81a9bd37eb8e7f2d1fcbd1884d9feae1\"><code>f70e1ca</code></a> <code>Update built files</code></li>\n<li><a href=\"https://urls.greenkeeper.io/evanw/node-source-map-support/commit/bd2c3f5d4aa17a0434ab50495af50dedc493106e\"><code>bd2c3f5</code></a> <code>Merge pull request #236 from LinusU/update-deps</code></li>\n<li><a href=\"https://urls.greenkeeper.io/evanw/node-source-map-support/commit/2e04483d67a9355fba8b1ba5ef8b52dd58cebd03\"><code>2e04483</code></a> <code>Update some dev-dependencies</code></li>\n<li><a href=\"https://urls.greenkeeper.io/evanw/node-source-map-support/commit/538e1c5aca18a6692ef612ca5be941829ae39d54\"><code>538e1c5</code></a> <code>Merge pull request #235 from ArtemGovorov/patch-1</code></li>\n<li><a href=\"https://urls.greenkeeper.io/evanw/node-source-map-support/commit/16f1a6d847ce857533b7173ae16cbea39b626f3e\"><code>16f1a6d</code></a> <code>Fix <code>resetRetrieveHandlers</code> to reset <code>retrieveSourceMap</code> and <code>retrieveFile</code> functions</code></li>\n</ul>\n<p>See the <a href=\"https://urls.greenkeeper.io/evanw/node-source-map-support/compare/80643a622cdedf03d150b34911f859c97d1c5fe8...6035ef534325864f396befc4028da7f0fdbcaaa4\">full diff</a></p>\n</details>\n\n\n<details>\n<summary>FAQ and help</summary>\n\nThere is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those dont help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new).\n</details>\n\n---\n\n\nYour [Greenkeeper](https://greenkeeper.io) Bot :palm_tree:\n"
}
]

View File

@ -0,0 +1,24 @@
import { GithubIssue } from '../../../src/entities';
// To re-create the JSON files from the API (e.g. if the API output schema changes), run the below command:
// curl "https://api.github.com/repos/0xProject/0x-monorepo/issues?state=all&per_page=1"
// docs here: https://developer.github.com/v3/issues/#list-issues-for-a-repository
const ParsedGithubIssue: GithubIssue = {
observedTimestamp: Date.now(),
repoFullName: '0xProject/0x-monorepo',
issueNumber: 1691,
title: 'An in-range update of source-map-support is breaking the build 🚨',
state: 'open',
locked: false,
assigneeLogin: undefined,
userLogin: 'greenkeeper[bot]',
userType: 'Bot',
userSiteAdmin: false,
comments: 1,
createdAt: Date.parse('2019-03-12T17:30:58Z'),
updatedAt: Date.parse('2019-03-12T17:32:26Z'),
closedAt: undefined,
};
export { ParsedGithubIssue };

View File

@ -0,0 +1,327 @@
[
{
"url": "https://api.github.com/repos/0xProject/0x-monorepo/pulls/1684",
"id": 259358832,
"node_id": "MDExOlB1bGxSZXF1ZXN0MjU5MzU4ODMy",
"html_url": "https://github.com/0xProject/0x-monorepo/pull/1684",
"diff_url": "https://github.com/0xProject/0x-monorepo/pull/1684.diff",
"patch_url": "https://github.com/0xProject/0x-monorepo/pull/1684.patch",
"issue_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues/1684",
"number": 1684,
"state": "open",
"locked": false,
"title": "[WIP] Pull Github data",
"user": {
"login": "askeluv",
"id": 2386262,
"node_id": "MDQ6VXNlcjIzODYyNjI=",
"avatar_url": "https://avatars2.githubusercontent.com/u/2386262?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/askeluv",
"html_url": "https://github.com/askeluv",
"followers_url": "https://api.github.com/users/askeluv/followers",
"following_url": "https://api.github.com/users/askeluv/following{/other_user}",
"gists_url": "https://api.github.com/users/askeluv/gists{/gist_id}",
"starred_url": "https://api.github.com/users/askeluv/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/askeluv/subscriptions",
"organizations_url": "https://api.github.com/users/askeluv/orgs",
"repos_url": "https://api.github.com/users/askeluv/repos",
"events_url": "https://api.github.com/users/askeluv/events{/privacy}",
"received_events_url": "https://api.github.com/users/askeluv/received_events",
"type": "User",
"site_admin": false
},
"body": "## Description\r\n\r\nPulling Github data so we can start monitoring metrics related to the monorepo.\r\n\r\n## Testing instructions\r\n\r\n```\r\nyarn build\r\nyarn migrate:run\r\nyarn test\r\nyarn test:db\r\nnode lib/src/scripts/pull_github.js\r\n```\r\n\r\n## Types of changes\r\n\r\nNew feature (non-breaking change which adds functionality)\r\n\r\n## Checklist:\r\n\r\n- [x] Github repo entity\r\n- [ ] Github pull request entity\r\n- [ ] Github fork entity\r\n",
"created_at": "2019-03-08T04:36:28Z",
"updated_at": "2019-03-08T04:36:28Z",
"closed_at": null,
"merged_at": null,
"merge_commit_sha": "85d164aedbf17d96f11d20b2f08eeaca0defb6e2",
"assignee": null,
"assignees": [],
"requested_reviewers": [],
"requested_teams": [],
"labels": [],
"milestone": null,
"commits_url": "https://api.github.com/repos/0xProject/0x-monorepo/pulls/1684/commits",
"review_comments_url": "https://api.github.com/repos/0xProject/0x-monorepo/pulls/1684/comments",
"review_comment_url": "https://api.github.com/repos/0xProject/0x-monorepo/pulls/comments{/number}",
"comments_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues/1684/comments",
"statuses_url": "https://api.github.com/repos/0xProject/0x-monorepo/statuses/1991bd437f798e52d6210cf4fac173a10e30f0bd",
"head": {
"label": "0xProject:pull-github-data",
"ref": "pull-github-data",
"sha": "1991bd437f798e52d6210cf4fac173a10e30f0bd",
"user": {
"login": "0xProject",
"id": 24832717,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjI0ODMyNzE3",
"avatar_url": "https://avatars2.githubusercontent.com/u/24832717?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/0xProject",
"html_url": "https://github.com/0xProject",
"followers_url": "https://api.github.com/users/0xProject/followers",
"following_url": "https://api.github.com/users/0xProject/following{/other_user}",
"gists_url": "https://api.github.com/users/0xProject/gists{/gist_id}",
"starred_url": "https://api.github.com/users/0xProject/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/0xProject/subscriptions",
"organizations_url": "https://api.github.com/users/0xProject/orgs",
"repos_url": "https://api.github.com/users/0xProject/repos",
"events_url": "https://api.github.com/users/0xProject/events{/privacy}",
"received_events_url": "https://api.github.com/users/0xProject/received_events",
"type": "Organization",
"site_admin": false
},
"repo": {
"id": 92181371,
"node_id": "MDEwOlJlcG9zaXRvcnk5MjE4MTM3MQ==",
"name": "0x-monorepo",
"full_name": "0xProject/0x-monorepo",
"private": false,
"owner": {
"login": "0xProject",
"id": 24832717,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjI0ODMyNzE3",
"avatar_url": "https://avatars2.githubusercontent.com/u/24832717?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/0xProject",
"html_url": "https://github.com/0xProject",
"followers_url": "https://api.github.com/users/0xProject/followers",
"following_url": "https://api.github.com/users/0xProject/following{/other_user}",
"gists_url": "https://api.github.com/users/0xProject/gists{/gist_id}",
"starred_url": "https://api.github.com/users/0xProject/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/0xProject/subscriptions",
"organizations_url": "https://api.github.com/users/0xProject/orgs",
"repos_url": "https://api.github.com/users/0xProject/repos",
"events_url": "https://api.github.com/users/0xProject/events{/privacy}",
"received_events_url": "https://api.github.com/users/0xProject/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/0xProject/0x-monorepo",
"description": "0x protocol monorepo - includes our smart contracts and many developer tools",
"fork": false,
"url": "https://api.github.com/repos/0xProject/0x-monorepo",
"forks_url": "https://api.github.com/repos/0xProject/0x-monorepo/forks",
"keys_url": "https://api.github.com/repos/0xProject/0x-monorepo/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/0xProject/0x-monorepo/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/0xProject/0x-monorepo/teams",
"hooks_url": "https://api.github.com/repos/0xProject/0x-monorepo/hooks",
"issue_events_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues/events{/number}",
"events_url": "https://api.github.com/repos/0xProject/0x-monorepo/events",
"assignees_url": "https://api.github.com/repos/0xProject/0x-monorepo/assignees{/user}",
"branches_url": "https://api.github.com/repos/0xProject/0x-monorepo/branches{/branch}",
"tags_url": "https://api.github.com/repos/0xProject/0x-monorepo/tags",
"blobs_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/0xProject/0x-monorepo/statuses/{sha}",
"languages_url": "https://api.github.com/repos/0xProject/0x-monorepo/languages",
"stargazers_url": "https://api.github.com/repos/0xProject/0x-monorepo/stargazers",
"contributors_url": "https://api.github.com/repos/0xProject/0x-monorepo/contributors",
"subscribers_url": "https://api.github.com/repos/0xProject/0x-monorepo/subscribers",
"subscription_url": "https://api.github.com/repos/0xProject/0x-monorepo/subscription",
"commits_url": "https://api.github.com/repos/0xProject/0x-monorepo/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/0xProject/0x-monorepo/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/0xProject/0x-monorepo/contents/{+path}",
"compare_url": "https://api.github.com/repos/0xProject/0x-monorepo/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/0xProject/0x-monorepo/merges",
"archive_url": "https://api.github.com/repos/0xProject/0x-monorepo/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/0xProject/0x-monorepo/downloads",
"issues_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues{/number}",
"pulls_url": "https://api.github.com/repos/0xProject/0x-monorepo/pulls{/number}",
"milestones_url": "https://api.github.com/repos/0xProject/0x-monorepo/milestones{/number}",
"notifications_url": "https://api.github.com/repos/0xProject/0x-monorepo/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/0xProject/0x-monorepo/labels{/name}",
"releases_url": "https://api.github.com/repos/0xProject/0x-monorepo/releases{/id}",
"deployments_url": "https://api.github.com/repos/0xProject/0x-monorepo/deployments",
"created_at": "2017-05-23T14:17:33Z",
"updated_at": "2019-03-08T00:48:18Z",
"pushed_at": "2019-03-08T04:36:28Z",
"git_url": "git://github.com/0xProject/0x-monorepo.git",
"ssh_url": "git@github.com:0xProject/0x-monorepo.git",
"clone_url": "https://github.com/0xProject/0x-monorepo.git",
"svn_url": "https://github.com/0xProject/0x-monorepo",
"homepage": "",
"size": 86647,
"stargazers_count": 989,
"watchers_count": 989,
"language": "TypeScript",
"has_issues": true,
"has_projects": false,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"forks_count": 295,
"mirror_url": null,
"archived": false,
"open_issues_count": 46,
"license": {
"key": "other",
"name": "Other",
"spdx_id": "NOASSERTION",
"url": null,
"node_id": "MDc6TGljZW5zZTA="
},
"forks": 295,
"open_issues": 46,
"watchers": 989,
"default_branch": "development"
}
},
"base": {
"label": "0xProject:development",
"ref": "development",
"sha": "9e03e1c742d73c6f0b2d61b1a069120e4aa71d3e",
"user": {
"login": "0xProject",
"id": 24832717,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjI0ODMyNzE3",
"avatar_url": "https://avatars2.githubusercontent.com/u/24832717?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/0xProject",
"html_url": "https://github.com/0xProject",
"followers_url": "https://api.github.com/users/0xProject/followers",
"following_url": "https://api.github.com/users/0xProject/following{/other_user}",
"gists_url": "https://api.github.com/users/0xProject/gists{/gist_id}",
"starred_url": "https://api.github.com/users/0xProject/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/0xProject/subscriptions",
"organizations_url": "https://api.github.com/users/0xProject/orgs",
"repos_url": "https://api.github.com/users/0xProject/repos",
"events_url": "https://api.github.com/users/0xProject/events{/privacy}",
"received_events_url": "https://api.github.com/users/0xProject/received_events",
"type": "Organization",
"site_admin": false
},
"repo": {
"id": 92181371,
"node_id": "MDEwOlJlcG9zaXRvcnk5MjE4MTM3MQ==",
"name": "0x-monorepo",
"full_name": "0xProject/0x-monorepo",
"private": false,
"owner": {
"login": "0xProject",
"id": 24832717,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjI0ODMyNzE3",
"avatar_url": "https://avatars2.githubusercontent.com/u/24832717?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/0xProject",
"html_url": "https://github.com/0xProject",
"followers_url": "https://api.github.com/users/0xProject/followers",
"following_url": "https://api.github.com/users/0xProject/following{/other_user}",
"gists_url": "https://api.github.com/users/0xProject/gists{/gist_id}",
"starred_url": "https://api.github.com/users/0xProject/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/0xProject/subscriptions",
"organizations_url": "https://api.github.com/users/0xProject/orgs",
"repos_url": "https://api.github.com/users/0xProject/repos",
"events_url": "https://api.github.com/users/0xProject/events{/privacy}",
"received_events_url": "https://api.github.com/users/0xProject/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/0xProject/0x-monorepo",
"description": "0x protocol monorepo - includes our smart contracts and many developer tools",
"fork": false,
"url": "https://api.github.com/repos/0xProject/0x-monorepo",
"forks_url": "https://api.github.com/repos/0xProject/0x-monorepo/forks",
"keys_url": "https://api.github.com/repos/0xProject/0x-monorepo/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/0xProject/0x-monorepo/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/0xProject/0x-monorepo/teams",
"hooks_url": "https://api.github.com/repos/0xProject/0x-monorepo/hooks",
"issue_events_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues/events{/number}",
"events_url": "https://api.github.com/repos/0xProject/0x-monorepo/events",
"assignees_url": "https://api.github.com/repos/0xProject/0x-monorepo/assignees{/user}",
"branches_url": "https://api.github.com/repos/0xProject/0x-monorepo/branches{/branch}",
"tags_url": "https://api.github.com/repos/0xProject/0x-monorepo/tags",
"blobs_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/0xProject/0x-monorepo/statuses/{sha}",
"languages_url": "https://api.github.com/repos/0xProject/0x-monorepo/languages",
"stargazers_url": "https://api.github.com/repos/0xProject/0x-monorepo/stargazers",
"contributors_url": "https://api.github.com/repos/0xProject/0x-monorepo/contributors",
"subscribers_url": "https://api.github.com/repos/0xProject/0x-monorepo/subscribers",
"subscription_url": "https://api.github.com/repos/0xProject/0x-monorepo/subscription",
"commits_url": "https://api.github.com/repos/0xProject/0x-monorepo/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/0xProject/0x-monorepo/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/0xProject/0x-monorepo/contents/{+path}",
"compare_url": "https://api.github.com/repos/0xProject/0x-monorepo/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/0xProject/0x-monorepo/merges",
"archive_url": "https://api.github.com/repos/0xProject/0x-monorepo/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/0xProject/0x-monorepo/downloads",
"issues_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues{/number}",
"pulls_url": "https://api.github.com/repos/0xProject/0x-monorepo/pulls{/number}",
"milestones_url": "https://api.github.com/repos/0xProject/0x-monorepo/milestones{/number}",
"notifications_url": "https://api.github.com/repos/0xProject/0x-monorepo/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/0xProject/0x-monorepo/labels{/name}",
"releases_url": "https://api.github.com/repos/0xProject/0x-monorepo/releases{/id}",
"deployments_url": "https://api.github.com/repos/0xProject/0x-monorepo/deployments",
"created_at": "2017-05-23T14:17:33Z",
"updated_at": "2019-03-08T00:48:18Z",
"pushed_at": "2019-03-08T04:36:28Z",
"git_url": "git://github.com/0xProject/0x-monorepo.git",
"ssh_url": "git@github.com:0xProject/0x-monorepo.git",
"clone_url": "https://github.com/0xProject/0x-monorepo.git",
"svn_url": "https://github.com/0xProject/0x-monorepo",
"homepage": "",
"size": 86647,
"stargazers_count": 989,
"watchers_count": 989,
"language": "TypeScript",
"has_issues": true,
"has_projects": false,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"forks_count": 295,
"mirror_url": null,
"archived": false,
"open_issues_count": 46,
"license": {
"key": "other",
"name": "Other",
"spdx_id": "NOASSERTION",
"url": null,
"node_id": "MDc6TGljZW5zZTA="
},
"forks": 295,
"open_issues": 46,
"watchers": 989,
"default_branch": "development"
}
},
"_links": {
"self": {
"href": "https://api.github.com/repos/0xProject/0x-monorepo/pulls/1684"
},
"html": {
"href": "https://github.com/0xProject/0x-monorepo/pull/1684"
},
"issue": {
"href": "https://api.github.com/repos/0xProject/0x-monorepo/issues/1684"
},
"comments": {
"href": "https://api.github.com/repos/0xProject/0x-monorepo/issues/1684/comments"
},
"review_comments": {
"href": "https://api.github.com/repos/0xProject/0x-monorepo/pulls/1684/comments"
},
"review_comment": {
"href": "https://api.github.com/repos/0xProject/0x-monorepo/pulls/comments{/number}"
},
"commits": {
"href": "https://api.github.com/repos/0xProject/0x-monorepo/pulls/1684/commits"
},
"statuses": {
"href": "https://api.github.com/repos/0xProject/0x-monorepo/statuses/1991bd437f798e52d6210cf4fac173a10e30f0bd"
}
},
"author_association": "CONTRIBUTOR"
}
]

View File

@ -0,0 +1,19 @@
import { GithubPullRequest } from '../../../src/entities';
// To re-create the JSON file from the API (e.g. if the API output schema changes), run the below command:
// curl https://api.github.com/repos/0xProject/0x-monorepo/pulls?per_page=1&page=1
// docs here: https://developer.github.com/v3/pulls/#list-pull-requests
const ParsedGithubPullRequest: GithubPullRequest = {
observedTimestamp: Date.now(),
repoFullName: '0xProject/0x-monorepo',
pullRequestNumber: 1684,
state: 'open',
title: '[WIP] Pull Github data',
userLogin: 'askeluv',
createdAt: 1552019788000,
updatedAt: 1552019788000,
closedAt: null,
mergedAt: null,
};
export { ParsedGithubPullRequest };

View File

@ -0,0 +1,121 @@
{
"id": 92181371,
"node_id": "MDEwOlJlcG9zaXRvcnk5MjE4MTM3MQ==",
"name": "0x-monorepo",
"full_name": "0xProject/0x-monorepo",
"private": false,
"owner": {
"login": "0xProject",
"id": 24832717,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjI0ODMyNzE3",
"avatar_url": "https://avatars2.githubusercontent.com/u/24832717?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/0xProject",
"html_url": "https://github.com/0xProject",
"followers_url": "https://api.github.com/users/0xProject/followers",
"following_url": "https://api.github.com/users/0xProject/following{/other_user}",
"gists_url": "https://api.github.com/users/0xProject/gists{/gist_id}",
"starred_url": "https://api.github.com/users/0xProject/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/0xProject/subscriptions",
"organizations_url": "https://api.github.com/users/0xProject/orgs",
"repos_url": "https://api.github.com/users/0xProject/repos",
"events_url": "https://api.github.com/users/0xProject/events{/privacy}",
"received_events_url": "https://api.github.com/users/0xProject/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/0xProject/0x-monorepo",
"description": "0x protocol monorepo - includes our smart contracts and many developer tools",
"fork": false,
"url": "https://api.github.com/repos/0xProject/0x-monorepo",
"forks_url": "https://api.github.com/repos/0xProject/0x-monorepo/forks",
"keys_url": "https://api.github.com/repos/0xProject/0x-monorepo/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/0xProject/0x-monorepo/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/0xProject/0x-monorepo/teams",
"hooks_url": "https://api.github.com/repos/0xProject/0x-monorepo/hooks",
"issue_events_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues/events{/number}",
"events_url": "https://api.github.com/repos/0xProject/0x-monorepo/events",
"assignees_url": "https://api.github.com/repos/0xProject/0x-monorepo/assignees{/user}",
"branches_url": "https://api.github.com/repos/0xProject/0x-monorepo/branches{/branch}",
"tags_url": "https://api.github.com/repos/0xProject/0x-monorepo/tags",
"blobs_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/0xProject/0x-monorepo/statuses/{sha}",
"languages_url": "https://api.github.com/repos/0xProject/0x-monorepo/languages",
"stargazers_url": "https://api.github.com/repos/0xProject/0x-monorepo/stargazers",
"contributors_url": "https://api.github.com/repos/0xProject/0x-monorepo/contributors",
"subscribers_url": "https://api.github.com/repos/0xProject/0x-monorepo/subscribers",
"subscription_url": "https://api.github.com/repos/0xProject/0x-monorepo/subscription",
"commits_url": "https://api.github.com/repos/0xProject/0x-monorepo/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/0xProject/0x-monorepo/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/0xProject/0x-monorepo/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/0xProject/0x-monorepo/contents/{+path}",
"compare_url": "https://api.github.com/repos/0xProject/0x-monorepo/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/0xProject/0x-monorepo/merges",
"archive_url": "https://api.github.com/repos/0xProject/0x-monorepo/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/0xProject/0x-monorepo/downloads",
"issues_url": "https://api.github.com/repos/0xProject/0x-monorepo/issues{/number}",
"pulls_url": "https://api.github.com/repos/0xProject/0x-monorepo/pulls{/number}",
"milestones_url": "https://api.github.com/repos/0xProject/0x-monorepo/milestones{/number}",
"notifications_url": "https://api.github.com/repos/0xProject/0x-monorepo/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/0xProject/0x-monorepo/labels{/name}",
"releases_url": "https://api.github.com/repos/0xProject/0x-monorepo/releases{/id}",
"deployments_url": "https://api.github.com/repos/0xProject/0x-monorepo/deployments",
"created_at": "2017-05-23T14:17:33Z",
"updated_at": "2019-03-06T21:48:49Z",
"pushed_at": "2019-03-06T23:59:05Z",
"git_url": "git://github.com/0xProject/0x-monorepo.git",
"ssh_url": "git@github.com:0xProject/0x-monorepo.git",
"clone_url": "https://github.com/0xProject/0x-monorepo.git",
"svn_url": "https://github.com/0xProject/0x-monorepo",
"homepage": "",
"size": 86538,
"stargazers_count": 989,
"watchers_count": 989,
"language": "TypeScript",
"has_issues": true,
"has_projects": false,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"forks_count": 294,
"mirror_url": null,
"archived": false,
"open_issues_count": 46,
"license": {
"key": "other",
"name": "Other",
"spdx_id": "NOASSERTION",
"url": null,
"node_id": "MDc6TGljZW5zZTA="
},
"forks": 294,
"open_issues": 46,
"watchers": 989,
"default_branch": "development",
"organization": {
"login": "0xProject",
"id": 24832717,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjI0ODMyNzE3",
"avatar_url": "https://avatars2.githubusercontent.com/u/24832717?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/0xProject",
"html_url": "https://github.com/0xProject",
"followers_url": "https://api.github.com/users/0xProject/followers",
"following_url": "https://api.github.com/users/0xProject/following{/other_user}",
"gists_url": "https://api.github.com/users/0xProject/gists{/gist_id}",
"starred_url": "https://api.github.com/users/0xProject/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/0xProject/subscriptions",
"organizations_url": "https://api.github.com/users/0xProject/orgs",
"repos_url": "https://api.github.com/users/0xProject/repos",
"events_url": "https://api.github.com/users/0xProject/events{/privacy}",
"received_events_url": "https://api.github.com/users/0xProject/received_events",
"type": "Organization",
"site_admin": false
},
"network_count": 294,
"subscribers_count": 89
}

View File

@ -0,0 +1,21 @@
import { GithubRepo } from '../../../src/entities';
// To re-create the JSON file from the API (e.g. if the API output schema changes), run the below command:
// curl https://api.github.com/repos/0xProject/0x-monorepo
// docs here: https://developer.github.com/v3/repos/#get
const ParsedGithubRepo: GithubRepo = {
observedTimestamp: Date.now(),
fullName: '0xProject/0x-monorepo',
createdAt: 1495549053000,
updatedAt: 1551908929000,
pushedAt: 1551916745000,
size: 86538,
stargazers: 989,
watchers: 989,
forks: 294,
openIssues: 46,
network: 294,
subscribers: 89,
};
export { ParsedGithubRepo };

View File

@ -0,0 +1,37 @@
import * as chai from 'chai';
import 'mocha';
import { GithubComparisonResponse, GithubForkResponse } from '../../../src/data_sources/github';
import { enrichGithubForkWithComparisonDetails, parseGithubForks } from '../../../src/parsers/github';
import * as githubComparisonResponse from '../../fixtures/github/api_v3_compare.json';
import { EnrichedGithubFork, ParsedGithubFork } from '../../fixtures/github/api_v3_forks';
import * as githubForksResponse from '../../fixtures/github/api_v3_forks.json';
import { chaiSetup } from '../../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
// tslint:disable:custom-no-magic-numbers
describe('github_forks', () => {
describe('parseGithubForks', () => {
it('converts GithubForksResponse to GithubFork entities', () => {
const forksResponse: GithubForkResponse[] = githubForksResponse;
const expected = ParsedGithubFork;
const observedTimestamp = expected.observedTimestamp;
const actualList = parseGithubForks(forksResponse, observedTimestamp);
const actual = actualList[0];
expect(actual).deep.equal(expected);
});
});
describe('enrichGithubFork', () => {
it('enriches GithubFork with comparison details', () => {
const comparisonResponse: GithubComparisonResponse = githubComparisonResponse;
const expected = EnrichedGithubFork;
const actual = enrichGithubForkWithComparisonDetails(ParsedGithubFork, comparisonResponse);
expect(actual).deep.equal(expected);
});
});
});

View File

@ -0,0 +1,27 @@
import * as chai from 'chai';
import 'mocha';
import { GithubIssueResponse } from '../../../src/data_sources/github';
import { parseGithubIssues } from '../../../src/parsers/github';
import { chaiSetup } from '../../utils/chai_setup';
import { ParsedGithubIssue } from '../../fixtures/github/api_v3_issues';
import * as githubIssuesResponse from '../../fixtures/github/api_v3_issues.json';
chaiSetup.configure();
const expect = chai.expect;
// tslint:disable:custom-no-magic-numbers
describe('github_issues', () => {
describe('parseGithubIssues', () => {
it('converts GithubIssuesResponse to GithubIssue entities', () => {
const response: GithubIssueResponse[] = githubIssuesResponse;
const expected = ParsedGithubIssue;
const observedTimestamp = expected.observedTimestamp;
const repoFullName = '0xProject/0x-monorepo';
const actualList = parseGithubIssues(response, observedTimestamp, repoFullName);
const actual = actualList[0];
expect(actual).deep.equal(expected);
});
});
});

View File

@ -0,0 +1,26 @@
import * as chai from 'chai';
import 'mocha';
import { GithubPullRequestResponse } from '../../../src/data_sources/github';
import { parseGithubPulls } from '../../../src/parsers/github';
import { chaiSetup } from '../../utils/chai_setup';
import { ParsedGithubPullRequest } from '../../fixtures/github/api_v3_pulls';
import * as githubPullsResponse from '../../fixtures/github/api_v3_pulls.json';
chaiSetup.configure();
const expect = chai.expect;
// tslint:disable:custom-no-magic-numbers
describe('github_pulls', () => {
describe('parseGithubPulls', () => {
it('converts GithubPullsResponse to GithubPullRequest entities', () => {
const response: GithubPullRequestResponse[] = githubPullsResponse;
const expected = ParsedGithubPullRequest;
const observedTimestamp = expected.observedTimestamp;
const actualList = parseGithubPulls(response, observedTimestamp);
const actual = actualList[0];
expect(actual).deep.equal(expected);
});
});
});

View File

@ -0,0 +1,25 @@
import * as chai from 'chai';
import 'mocha';
import { ParsedGithubRepo } from '../../fixtures/github/api_v3_repo';
import * as githubRepoResponse from '../../fixtures/github/api_v3_repo.json';
import { GithubRepoResponse } from '../../../src/data_sources/github';
import { parseGithubRepo } from '../../../src/parsers/github';
import { chaiSetup } from '../../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
// tslint:disable:custom-no-magic-numbers
describe('github_repo', () => {
describe('parseGithubRepo', () => {
it('converts GithubRepoResponse to GithubRepo entities', () => {
const response: GithubRepoResponse = githubRepoResponse;
const expected = ParsedGithubRepo;
const observedTimestamp = expected.observedTimestamp;
const actual = parseGithubRepo(response, observedTimestamp);
expect(actual).deep.equal(expected);
});
});
});

View File

@ -9,5 +9,6 @@ export const chaiSetup = {
chai.use(ChaiBigNumber()); chai.use(ChaiBigNumber());
chai.use(dirtyChai); chai.use(dirtyChai);
chai.use(chaiAsPromised); chai.use(chaiAsPromised);
chai.config.truncateThreshold = 0;
}, },
}; };

View File

@ -15,6 +15,11 @@
"./test/fixtures/copper/api_v1_list_leads.json", "./test/fixtures/copper/api_v1_list_leads.json",
"./test/fixtures/copper/api_v1_list_opportunities.json", "./test/fixtures/copper/api_v1_list_opportunities.json",
"./test/fixtures/etherscan/api_v1_accounts_transactions.json", "./test/fixtures/etherscan/api_v1_accounts_transactions.json",
"./test/fixtures/github/api_v3_compare.json",
"./test/fixtures/github/api_v3_forks.json",
"./test/fixtures/github/api_v3_issues.json",
"./test/fixtures/github/api_v3_pulls.json",
"./test/fixtures/github/api_v3_repo.json",
"./test/fixtures/greenhouse/api_v1_applications.json" "./test/fixtures/greenhouse/api_v1_applications.json"
] ]
} }