-
-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pulls in github PR metadata based on a CI source
- Loading branch information
Showing
8 changed files
with
76 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
], | ||
"plugins": [ | ||
"transform-flow-strip-types", | ||
"syntax-async-functions", | ||
"transform-regenerator" | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"javascript.validate.enable": false, | ||
"files.exclude": { | ||
"**/.git": true, | ||
"**/.svn": true, | ||
"**/.hg": true, | ||
"**/.DS_Store": true, | ||
"distribution/": true, | ||
}, | ||
"search.exclude": { | ||
"**/node_modules": true, | ||
"distribution/": true, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// @flow | ||
"use strict" | ||
|
||
import type { Env } from "./ci_source" | ||
|
||
export default class FakeCI { | ||
env: Env | ||
constructor(env: Env) { this.env = env } | ||
|
||
get isCI() : boolean { return true } | ||
get isPR() : boolean { return true } | ||
|
||
get pullRequestID(): string { return "350" } | ||
get repoSlug(): string { return "artsy/emission" } | ||
get repoURL(): string { return "maybe not needed?" } | ||
get supportedPlatforms() : string[] { return ["github"] } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,46 @@ | ||
// @flow | ||
"use strict" | ||
|
||
import type { CISource } from "../ci_source/ci_source" | ||
|
||
// import type { Metadata, Comment, Platform } from "./platform" | ||
import fetch from "node-fetch" | ||
import "babel-polyfill" | ||
|
||
export type APIToken = string; | ||
export type GraphQLQuery = string; | ||
export type GraphQLResponse = any; | ||
|
||
export class GitHub { | ||
token: APIToken | ||
constructor(token: APIToken) { this.token = token } | ||
ciSource: CISource | ||
|
||
constructor(token: APIToken, ciSource: CISource) { | ||
this.token = token | ||
this.ciSource = ciSource | ||
} | ||
|
||
async getInfo() : void { | ||
console.log("starting") | ||
let deets = await this.getUserInfo() | ||
console.log(deets) | ||
let deets = await this.getPullRequestInfo() | ||
let pr = await deets.json() | ||
console.log(pr) | ||
} | ||
|
||
async getUserInfo(): Promise<any> { | ||
return fetch("https://api.github.com/user", { | ||
method: "GET", | ||
body: "", | ||
headers: { "Authorization": this.token } | ||
}) | ||
getUserInfo(): Promise<Response> { | ||
return this.get("user") | ||
} | ||
|
||
getPullRequestInfo(): Promise<Response> { | ||
const repo = this.ciSource.repoSlug | ||
const prID = this.ciSource.pullRequestID | ||
return this.get(`repos/${repo}/pulls/${prID}`) | ||
} | ||
|
||
async runQuery(query: GraphQLQuery): Promise<GraphQLResponse> { | ||
return fetch("https://api.github.com/user", { | ||
get(path: string, body: any = {}): Promise<Response> { | ||
return fetch(`https://api.github.com/${path}`, { | ||
method: "GET", | ||
body: "", | ||
headers: { "Authorization": "aacf0f931f363a0670f6e8b70ac82c1cdead94c0" } | ||
body: body, | ||
headers: { "Authorization": `token ${this.token}` } | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters