Skip to content

Commit

Permalink
Merge branch 'main' into issue_1301
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Oct 1, 2022
2 parents 6a70f47 + 6a216a1 commit 4c52740
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 84 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -16,7 +16,11 @@

<!-- Your comment below this -->
- Append random string to danger-results.json and danger-dsl.json files to better support concurrent processes #1311

- Gitlab package moved to a new home "@gitbreaker/*" [#1301](https://github.com/danger/danger-js/issues/1301) [@ivankatliarchuk]
- GitLab: Improve support for MRs from forks [#1319](https://github.com/danger/danger-js/pull/1319) [@ivankatliarchuk]
- GitLab: Added provider tests [#1319](https://github.com/danger/danger-js/pull/1319) [@ivankatliarchuk]

<!-- Your comment above this -->

## 11.1.2
Expand Down Expand Up @@ -1947,6 +1951,7 @@ Not usable for others, only stubs of classes etc. - [@orta]
[@hmschreiner]: https://github.com/hmschreiner
[@hongrich]: https://github.com/hongrich
[@igorbek]: https://github.com/igorbek
[@ivankatliarchuk]: https://github.com/ivankatliarchuk
[@iljadaderko]: https://github.com/IljaDaderko
[@ivankatliarchuk]: https://github.com/ivankatliarchuk
[@imorente]: https://github.com/imorente
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -99,7 +99,6 @@
"@types/async-retry": "^1.4.1",
"@types/debug": "0.0.30",
"@types/get-stdin": "^5.0.1",
"@types/http-proxy-agent": "^2.0.1",
"@types/jest": "^24.0.11",
"@types/json5": "^0.0.30",
"@types/jsonpointer": "^4.0.0",
Expand Down Expand Up @@ -150,8 +149,9 @@
"fast-json-patch": "^3.0.0-1",
"get-stdin": "^6.0.0",
"@gitbeaker/node": "^21.3.0",
"http-proxy-agent": "^2.1.0",
"https-proxy-agent": "^2.2.1",
"gitlab": "^10.0.1",
"https-proxy-agent": "^5.0.1",
"hyperlinker": "^1.0.0",
"json5": "^2.1.0",
"jsonpointer": "^5.0.0",
Expand Down
12 changes: 6 additions & 6 deletions source/api/_tests/fetch.test.ts
@@ -1,9 +1,9 @@
import * as http from "http"
import * as node_fetch from "node-fetch"

import type { HttpProxyAgent } from "http-proxy-agent"
import type { HttpsProxyAgent } from "https-proxy-agent"
import { api } from "../fetch"
import HttpProxyAgent from "http-proxy-agent"
import HttpsProxyAgent from "http-proxy-agent"

interface ResponseMock {
body?: any
Expand Down Expand Up @@ -128,7 +128,7 @@ describe("fetch", () => {
let options: node_fetch.RequestInit = { agent: undefined }
await api(url, options, true, { HTTPS_PROXY: proxyUrl })
let agent = options.agent as HttpsProxyAgent
expect(agent.proxy.href).toBe(proxyUrl)
expect(agent["proxy"].href).toBe(proxyUrl)
})

it("sets proxy agent when https_proxy env variable is defined", async () => {
Expand All @@ -140,7 +140,7 @@ describe("fetch", () => {
let options: node_fetch.RequestInit = { agent: undefined }
await api(url, options, true, { https_proxy: proxyUrl })
let agent = options.agent as HttpsProxyAgent
expect(agent.proxy.href).toBe(proxyUrl)
expect(agent["proxy"].href).toBe(proxyUrl)
})

it("sets proxy agent when HTTP_PROXY env variable is defined", async () => {
Expand All @@ -152,7 +152,7 @@ describe("fetch", () => {
let options: node_fetch.RequestInit = { agent: undefined }
await api(url, options, true, { HTTP_PROXY: proxyUrl })
let agent = options.agent as HttpProxyAgent
expect(agent.proxy.href).toBe(proxyUrl)
expect(agent["proxy"].href).toBe(proxyUrl)
})

it("sets proxy agent when http_proxy env variable is defined", async () => {
Expand All @@ -164,6 +164,6 @@ describe("fetch", () => {
let options: node_fetch.RequestInit = { agent: undefined }
await api(url, options, true, { http_proxy: proxyUrl })
let agent = options.agent as HttpProxyAgent
expect(agent.proxy.href).toBe(proxyUrl)
expect(agent["proxy"].href).toBe(proxyUrl)
})
})
2 changes: 1 addition & 1 deletion source/api/fetch.ts
Expand Up @@ -113,7 +113,7 @@ export function api(

if (!agent && proxy) {
let secure = url.toString().startsWith("https")
init.agent = secure ? new HttpsProxyAgent(proxy) : new HttpProxyAgent(proxy)
init.agent = secure ? HttpsProxyAgent(proxy) : HttpProxyAgent(proxy)
}

return retryableFetch(url, init).then(async (response: node_fetch.Response) => {
Expand Down
2 changes: 1 addition & 1 deletion source/ci_source/providers/GitLabCI.ts
Expand Up @@ -23,7 +23,7 @@ export class GitLabCI implements CISource {
}

get repoSlug(): string {
return this.env.CI_PROJECT_PATH
return this.env.CI_MERGE_REQUEST_PROJECT_PATH || this.env.CI_PROJECT_PATH
}

get commitHash(): string {
Expand Down
47 changes: 47 additions & 0 deletions source/ci_source/providers/_tests/_gitlab.test.ts
@@ -0,0 +1,47 @@
import { GitLabCI } from "../GitLabCI"
import { getCISourceForEnv } from "../../get_ci_source"

const correctEnv = {
GITLAB_CI: "true",
CI_MERGE_REQUEST_IID: "27117",
CI_PROJECT_PATH: "gitlab-org/gitlab-foss",
}

describe("being found when looking for CI", () => {
it("finds GitLab with the right ENV", () => {
const ci = getCISourceForEnv(correctEnv)
expect(ci).toBeInstanceOf(GitLabCI)
})
})

describe(".isCI", () => {
it("validates when all GitLab environment vars are set", async () => {
const result = new GitLabCI(correctEnv)
expect(result.isCI).toBeTruthy()
})

it("does not validate without env", async () => {
const result = new GitLabCI({})
expect(result.isCI).toBeFalsy()
})
})

describe(".pullRequestID", () => {
it("pulls it out of the env", () => {
const result = new GitLabCI(correctEnv)
expect(result.pullRequestID).toEqual("27117")
})
})

describe(".repoSlug", () => {
it("derives it from 'CI_PROJECT_PATH' env var", () => {
const result = new GitLabCI(correctEnv)
expect(result.repoSlug).toEqual("gitlab-org/gitlab-foss")
})

it("derives it form 'CI_MERGE_REQUEST_PROJECT_PATH' env var if set", () => {
correctEnv["CI_MERGE_REQUEST_PROJECT_PATH"] = "gitlab-org/release-tools"
const result = new GitLabCI(correctEnv)
expect(result.repoSlug).toEqual("gitlab-org/release-tools")
})
})
24 changes: 0 additions & 24 deletions source/https-proxy-agent.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion source/platforms/bitbucket_cloud/BitBucketCloudAPI.ts
Expand Up @@ -370,7 +370,7 @@ export class BitBucketCloudAPI {
let agent: Agent | undefined = undefined
let proxy = process.env.http_proxy || process.env.https_proxy
if (proxy) {
agent = new HttpsProxyAgent(proxy)
agent = HttpsProxyAgent(proxy)
}

return this.fetch(
Expand Down
2 changes: 1 addition & 1 deletion source/platforms/bitbucket_server/BitBucketServerAPI.ts
Expand Up @@ -353,7 +353,7 @@ export class BitBucketServerAPI implements BitBucketServerAPIDSL {
let agent: Agent | undefined = undefined
let proxy = process.env.http_proxy || process.env.https_proxy
if (proxy) {
agent = new HttpsProxyAgent(proxy)
agent = HttpsProxyAgent(proxy)
}

return this.fetch(
Expand Down
62 changes: 14 additions & 48 deletions yarn.lock
Expand Up @@ -1495,6 +1495,11 @@
dependencies:
defer-to-connect "^2.0.0"

"@tootallnate/once@2":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==

"@tsconfig/node10@^1.0.7":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9"
Expand Down Expand Up @@ -1571,13 +1576,6 @@
resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz#9140779736aa2655635ee756e2467d787cfe8a2a"
integrity sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A==

"@types/http-proxy-agent@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@types/http-proxy-agent/-/http-proxy-agent-2.0.1.tgz#2f95077f6bfe7adc39cc0f0042da85997ae77fc7"
integrity sha512-dgsgbsgI3t+ZkdzF9H19uBaLsurIZJJjJsVpj4mCLp8B6YghQ7jVwyqhaL0PcVtuC3nOi0ZBhAi2Dd9jCUwdFA==
dependencies:
"@types/node" "*"

"@types/jest-diff@*":
version "20.0.1"
resolved "https://registry.yarnpkg.com/@types/jest-diff/-/jest-diff-20.0.1.tgz#35cc15b9c4f30a18ef21852e255fdb02f6d59b89"
Expand Down Expand Up @@ -1897,13 +1895,6 @@ address@^1.0.1:
resolved "https://registry.yarnpkg.com/address/-/address-1.0.3.tgz#b5f50631f8d6cec8bd20c963963afb55e06cbce9"
integrity sha512-z55ocwKBRLryBs394Sm3ushTtBeg6VAeuku7utSoSnsJKvKcnXFIyC6vh27n3rXyxSgkJBBCAvyOn7gSUcTYjg==

agent-base@4, agent-base@^4.1.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9"
integrity sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==
dependencies:
es6-promisify "^5.0.0"

agent-base@6:
version "6.0.2"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77"
Expand Down Expand Up @@ -3307,13 +3298,6 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0:
dependencies:
ms "2.0.0"

debug@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
dependencies:
ms "2.0.0"

debug@4, debug@^4.0.0, debug@^4.3.1:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
Expand Down Expand Up @@ -3772,18 +3756,6 @@ es-to-primitive@^1.1.1:
is-date-object "^1.0.1"
is-symbol "^1.0.1"

es6-promise@^4.0.3:
version "4.2.5"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.5.tgz#da6d0d5692efb461e082c14817fe2427d8f5d054"
integrity sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==

es6-promisify@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203"
integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=
dependencies:
es6-promise "^4.0.3"

escalade@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
Expand Down Expand Up @@ -5040,13 +5012,14 @@ http-errors@~1.6.1:
setprototypeof "1.0.3"
statuses ">= 1.3.1 < 2"

http-proxy-agent@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz#e4821beef5b2142a2026bd73926fe537631c5405"
integrity sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==
http-proxy-agent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz#5129800203520d434f142bc78ff3c170800f2b43"
integrity sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==
dependencies:
agent-base "4"
debug "3.1.0"
"@tootallnate/once" "2"
agent-base "6"
debug "4"

http-signature@~1.2.0:
version "1.2.0"
Expand All @@ -5057,6 +5030,7 @@ http-signature@~1.2.0:
jsprim "^1.2.2"
sshpk "^1.7.0"


http2-wrapper@^1.0.0-beta.5.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-1.0.3.tgz#b8f55e0c1f25d4ebd08b3b0c2c079f9590800b3d"
Expand All @@ -5065,15 +5039,7 @@ http2-wrapper@^1.0.0-beta.5.2:
quick-lru "^5.1.1"
resolve-alpn "^1.0.0"

https-proxy-agent@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0"
integrity sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==
dependencies:
agent-base "^4.1.0"
debug "^3.1.0"

https-proxy-agent@^5.0.0:
https-proxy-agent@^5.0.0, https-proxy-agent@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6"
integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==
Expand Down

0 comments on commit 4c52740

Please sign in to comment.