Skip to content

Commit

Permalink
Look for more CircleCI PR environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-clayton committed Sep 29, 2017
1 parent b18204b commit 66ee98f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions source/ci_source/providers/Circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class Circle implements CISource {
}

get isPR(): boolean {
if (ensureEnvKeysExist(this.env, ["CI_PULL_REQUEST"])) {
if (ensureEnvKeysExist(this.env, ["CI_PULL_REQUEST"]) || ensureEnvKeysExist(this.env, ["CIRCLE_PULL_REQUEST"])) {
return true
}

Expand All @@ -50,7 +50,7 @@ export class Circle implements CISource {
}

private _prParseURL(): { owner?: string; reponame?: string; id?: string } {
const prUrl = this.env.CI_PULL_REQUEST || ""
const prUrl = this.env.CI_PULL_REQUEST || this.env.CIRCLE_PULL_REQUEST || ""
const splitSlug = prUrl.split("/")
if (splitSlug.length === 7) {
const owner = splitSlug[3]
Expand Down
5 changes: 4 additions & 1 deletion source/ci_source/providers/_tests/_circle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const correctEnv = {
CIRCLE_PROJECT_REPONAME: "someproject",
CIRCLE_BUILD_NUM: "1501",
CIRCLE_PR_NUMBER: "800",
CIRCLE_PULL_REQUEST: "https://github.com/artsy/eigen/pull/800",
CI_PULL_REQUEST: "https://github.com/artsy/eigen/pull/800",
}

Expand Down Expand Up @@ -48,6 +49,7 @@ describe(".isPR", () => {
CIRCLE_PROJECT_REPONAME: "someproject",
CIRCLE_BUILD_NUM: "1501",
CIRCLE_PR_NUMBER: "800",
CIRCLE_PULL_REQUEST: "https://github.com/artsy/eigen/pull/800",
CI_PULL_REQUEST: "https://github.com/artsy/eigen/pull/800",
}
env[key] = null
Expand All @@ -68,7 +70,7 @@ describe(".isPR", () => {
})
})

describe(".pullReuestID", () => {
describe(".pullRequestID", () => {
it("pulls it out of the env", () => {
const circle = new Circle({ CIRCLE_PR_NUMBER: "800" })
expect(circle.pullRequestID).toEqual("800")
Expand All @@ -77,6 +79,7 @@ describe(".pullReuestID", () => {
it("can derive it from PR Url", () => {
let env = {
CI_PULL_REQUEST: "https://github.com/artsy/eigen/pull/23",
CIRCLE_PULL_REQUEST: "https://github.com/artsy/eigen/pull/23",
}
const circle = new Circle(env)
expect(circle.pullRequestID).toEqual("23")
Expand Down

0 comments on commit 66ee98f

Please sign in to comment.