From fdcca057beb0f703bb5a018366f677e94f0716c4 Mon Sep 17 00:00:00 2001 From: Michal Miszczyszyn Date: Wed, 11 Sep 2019 00:39:01 +0200 Subject: [PATCH 1/4] Fix Buddy.works isPR because PR ids are not always ints --- source/ci_source/providers/BuddyWorks.ts | 5 ++--- source/ci_source/providers/_tests/_buddyWorks.test.ts | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/source/ci_source/providers/BuddyWorks.ts b/source/ci_source/providers/BuddyWorks.ts index aa48b806d..29d0daa46 100644 --- a/source/ci_source/providers/BuddyWorks.ts +++ b/source/ci_source/providers/BuddyWorks.ts @@ -1,5 +1,5 @@ import { Env, CISource } from "../ci_source" -import { ensureEnvKeysExist, ensureEnvKeysAreInt } from "../ci_source_helpers" +import { ensureEnvKeysExist } from "../ci_source_helpers" /** * ### CI Setup * @@ -27,8 +27,7 @@ export class BuddyWorks implements CISource { get isPR(): boolean { const mustHave = ["BUDDY_PIPELINE_ID", "BUDDY_EXECUTION_PULL_REQUEST_ID", "BUDDY_REPO_SLUG"] - const mustBeInts = ["BUDDY_EXECUTION_PULL_REQUEST_ID"] - return ensureEnvKeysExist(this.env, mustHave) && ensureEnvKeysAreInt(this.env, mustBeInts) + return ensureEnvKeysExist(this.env, mustHave) } get pullRequestID(): string { diff --git a/source/ci_source/providers/_tests/_buddyWorks.test.ts b/source/ci_source/providers/_tests/_buddyWorks.test.ts index 945b3930a..c1332f230 100644 --- a/source/ci_source/providers/_tests/_buddyWorks.test.ts +++ b/source/ci_source/providers/_tests/_buddyWorks.test.ts @@ -3,7 +3,7 @@ import { getCISourceForEnv } from "../../get_ci_source" const correctEnv = { BUDDY_PIPELINE_ID: "170873", - BUDDY_EXECUTION_PULL_REQUEST_ID: "1799", + BUDDY_EXECUTION_PULL_REQUEST_ID: "pull/1799", BUDDY_REPO_SLUG: "danger/dangerjs", BUDDY_EXECUTION_URL: "https://app.buddy.works/danger/dangerjs/pipelines/pipeline/170873/execution/5d6d49dbaab2cb6fdf975c71", @@ -50,7 +50,7 @@ describe(".isPR", () => { }) }) - it("needs to have a PR number", () => { + it("needs to have a PR id", () => { const env = Object.assign({}, correctEnv) delete env.BUDDY_EXECUTION_PULL_REQUEST_ID const buddyWorks = new BuddyWorks(env) @@ -61,7 +61,7 @@ describe(".isPR", () => { describe(".pullRequestID", () => { it("pulls it out of the env", () => { const buddyWorks = new BuddyWorks(correctEnv) - expect(buddyWorks.pullRequestID).toEqual("1799") + expect(buddyWorks.pullRequestID).toEqual("pull/1799") }) }) From 22bfbec8dcbcd0372d6c282842979e9739584140 Mon Sep 17 00:00:00 2001 From: Michal Miszczyszyn Date: Wed, 11 Sep 2019 00:59:37 +0200 Subject: [PATCH 2/4] Add Changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed48cd0a5..dcc66d5d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ +- Fix Buddy.works isPR because PR ids are not always ints - [@mmiszy] + # 9.2.0 From 515ec42323037dd8d07402726d4d018f9deb935f Mon Sep 17 00:00:00 2001 From: Michal Miszczyszyn Date: Wed, 11 Sep 2019 19:50:49 +0200 Subject: [PATCH 3/4] Use BUDDY_EXECUTION_PULL_REQUEST_NO instead --- source/ci_source/providers/BuddyWorks.ts | 10 ++++++---- source/ci_source/providers/_tests/_buddyWorks.test.ts | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/source/ci_source/providers/BuddyWorks.ts b/source/ci_source/providers/BuddyWorks.ts index 29d0daa46..59f73bf0c 100644 --- a/source/ci_source/providers/BuddyWorks.ts +++ b/source/ci_source/providers/BuddyWorks.ts @@ -1,5 +1,5 @@ import { Env, CISource } from "../ci_source" -import { ensureEnvKeysExist } from "../ci_source_helpers" +import { ensureEnvKeysExist, ensureEnvKeysAreInt } from "../ci_source_helpers" /** * ### CI Setup * @@ -26,12 +26,14 @@ export class BuddyWorks implements CISource { } get isPR(): boolean { - const mustHave = ["BUDDY_PIPELINE_ID", "BUDDY_EXECUTION_PULL_REQUEST_ID", "BUDDY_REPO_SLUG"] - return ensureEnvKeysExist(this.env, mustHave) + const mustHave = ["BUDDY_PIPELINE_ID", "BUDDY_EXECUTION_PULL_REQUEST_NO", "BUDDY_REPO_SLUG"] + const mustBeInts = ["BUDDY_EXECUTION_PULL_REQUEST_NO"] + + return ensureEnvKeysExist(this.env, mustHave) && ensureEnvKeysAreInt(this.env, mustBeInts) } get pullRequestID(): string { - return this.env.BUDDY_EXECUTION_PULL_REQUEST_ID + return this.env.BUDDY_EXECUTION_PULL_REQUEST_NO } get repoSlug(): string { diff --git a/source/ci_source/providers/_tests/_buddyWorks.test.ts b/source/ci_source/providers/_tests/_buddyWorks.test.ts index c1332f230..3ac04756e 100644 --- a/source/ci_source/providers/_tests/_buddyWorks.test.ts +++ b/source/ci_source/providers/_tests/_buddyWorks.test.ts @@ -3,7 +3,7 @@ import { getCISourceForEnv } from "../../get_ci_source" const correctEnv = { BUDDY_PIPELINE_ID: "170873", - BUDDY_EXECUTION_PULL_REQUEST_ID: "pull/1799", + BUDDY_EXECUTION_PULL_REQUEST_NO: "1799", BUDDY_REPO_SLUG: "danger/dangerjs", BUDDY_EXECUTION_URL: "https://app.buddy.works/danger/dangerjs/pipelines/pipeline/170873/execution/5d6d49dbaab2cb6fdf975c71", @@ -39,7 +39,7 @@ describe(".isPR", () => { expect(buddyWorks.isPR).toBeFalsy() }) - const envs = ["BUDDY_EXECUTION_PULL_REQUEST_ID", "BUDDY_REPO_SLUG"] + const envs = ["BUDDY_EXECUTION_PULL_REQUEST_NO", "BUDDY_REPO_SLUG"] envs.forEach((key: string) => { const env = Object.assign({}, correctEnv) env[key] = null @@ -50,9 +50,9 @@ describe(".isPR", () => { }) }) - it("needs to have a PR id", () => { + it("needs to have a PR number", () => { const env = Object.assign({}, correctEnv) - delete env.BUDDY_EXECUTION_PULL_REQUEST_ID + delete env.BUDDY_EXECUTION_PULL_REQUEST_NO const buddyWorks = new BuddyWorks(env) expect(buddyWorks.isPR).toBeFalsy() }) @@ -61,7 +61,7 @@ describe(".isPR", () => { describe(".pullRequestID", () => { it("pulls it out of the env", () => { const buddyWorks = new BuddyWorks(correctEnv) - expect(buddyWorks.pullRequestID).toEqual("pull/1799") + expect(buddyWorks.pullRequestID).toEqual("1799") }) }) From 2cce4c2b63f3b764922f8ad63bbe6906b4db3b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Miszczyszyn?= Date: Wed, 11 Sep 2019 19:55:44 +0200 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcc66d5d3..4d1c026d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ -- Fix Buddy.works isPR because PR ids are not always ints - [@mmiszy] +- Fix Buddy.works isPR and use PR number instead of PR ID - [@mmiszy]