Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/danger/danger-js
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Jan 5, 2023
2 parents 3a42b04 + 0f48d32 commit 042c4fa
Show file tree
Hide file tree
Showing 42 changed files with 2,310 additions and 1,408 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,56 @@
name: Release executable files for macOS

on:
workflow_dispatch:
inputs:
version_digit:
description: 'Version digit (major | minor | patch)'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch

jobs:
release:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_DEPLOY_SECRET_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_SECRET_KEY }}
permissions: write-all
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Install ldid
uses: MOZGIII/install-ldid-action@v1
with:
tag: v2.1.5-procursus6

- name: Check out repository code
uses: actions/checkout@v3

- name: Use node
uses: actions/setup-node@v3
with:
node-version: "14"

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Package
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
npm run release -- ${{ github.event.inputs.version_digit }} --ci
- name: Update homebrew/tap repo for new release
shell: bash
run: scripts/create-homebrew-tap-pr.sh
env:
VERSION: ${{ env.VERSION }}
6 changes: 3 additions & 3 deletions .release-it.json
Expand Up @@ -3,10 +3,10 @@
"release": true,
"assets": "brew-distribution/*.zip"
},
"buildCommand": "yarn package",
"buildCommand": "yarn package:x64; yarn package:arm64",
"hooks": {
"before:bump": "yarn declarations; yarn build:schemas",
"after:bump": "yarn package",
"after:release": "VERSION=${version} scripts/create-homebrew-tap-pr.sh"
"after:bump": "yarn package:x64; yarn package:arm64",
"after:release": "export VERSION=${version}; echo 'VERSION=${version}' >> $GITHUB_ENV"
}
}
22 changes: 20 additions & 2 deletions CHANGELOG.md
Expand Up @@ -16,18 +16,34 @@

<!-- Your comment below this -->

- Support arm64 binary generation for Apple silicon users [#1342](https://github.com/danger/danger-js/pull/1342) [@pepix]

<!-- Your comment above this -->

## 11.1.2

- Bug fix for bitbucket bot detection ignoring case #1291

## 11.2.0

- Append random string to danger-results.json and danger-dsl.json files to better support concurrent processes #1311
- Gitlab: add support for skipping remove of messages when empty [#1330](https://github.com/danger/danger-js/issues/1330) [@ivankatliarchuk]
- 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]
- GitHub: Added `danger.github.pr.draft` field to DSL
- GitLab: Add support for using threads instead of comments [#1331](https://github.com/danger/danger-js/pull/1331) [@uncaught]

## 11.1.2

- Improvements to `--staging` in Danger local
- Protection against custom git prompts in Danger local

## 11.1.1

- Bug fix for over-deleting inline comments #1287

## 11.1.0
## 11.1.0

- Adds support for the new [GitHub Job summaries](https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/) API via:
- `danger.github.setSummaryMarkdown("[markdown]")` for the JavaScript DSL
Expand Down Expand Up @@ -56,7 +72,7 @@
# 11.0.0 -> 11.0.2

- *Breaking:* Upgrade @octokit/rest from ^16.43.1 to ^18.12.0 - [#1204](https://github.com/danger/danger-js/pull/1204) [@fbartho]

This is only likely to hit you if you use `danger.github.api` pretty extensively in your Dangerfiles, but better to keep an eye out.

# 10.8.1
Expand Down Expand Up @@ -1946,7 +1962,9 @@ 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
[@jamiebuilds]: https://github.com/jamiebuilds
[@jamime]: https://github.com/jamime
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -40,8 +40,8 @@ Following [this commit](https://github.com/danger/danger-js/commit/a26ac3b3bd4f0
- Modify `changelog.md`, adding a new `### 0.21.0` heading under the `### Main` heading at the top of the file.
- Commit both changes with the commit message **Version bump**.
- Tag this commit - `git tag 0.21.0`.
- Push the commit and tag to master - `git push origin main --follow-tags`. Travis CI will build the tagged commit and
publish that tagged version to NPM.
- Push the commit and tag to master - `git push origin main --follow-tags`. GitHub Actions will build the tagged commit
and publish that tagged version to NPM.

:ship:

Expand Down
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -27,7 +27,6 @@ Codefresh, AppCenter, BitBucket Pipelines, Cirrus CI, Codemagic or Xcode Cloud.
[![npm](https://img.shields.io/npm/v/danger.svg)](https://www.npmjs.com/package/danger)
[![Build Status](https://travis-ci.org/danger/danger-js.svg?branch=main)](https://travis-ci.org/danger/danger-js)
[![Build Status](https://ci.appveyor.com/api/projects/status/ep5hgeox3lbc5c7f?svg=true)](https://ci.appveyor.com/project/orta/danger-js/branch/main)
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/danger)

## For example?

Expand Down
2 changes: 1 addition & 1 deletion docs/issue_template.md
Expand Up @@ -6,7 +6,7 @@ If this is a support request, e.g:
* Does Danger support ...?
* Is there a plugin for ...?

Please use https://spectrum.chat/danger
Please use discussions: https://github.com/danger/danger-js/discussions

If this issue feels like:

Expand Down
5 changes: 5 additions & 0 deletions docs/usage/gitlab.html.md
Expand Up @@ -41,3 +41,8 @@ danger.gitlab.
/** The commits associated with the merge request */
commits: GitLabMRCommit[]
```

---

If you want danger to open threads (discussions) instead of just commenting in merge requests, set an environment
variable `DANGER_GITLAB_USE_THREADS` with value `1` or `true`.
18 changes: 9 additions & 9 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "danger",
"version": "11.1.1",
"version": "11.2.0",
"description": "Unit tests for Team Culture",
"main": "distribution/danger.js",
"typings": "distribution/danger.d.ts",
Expand Down Expand Up @@ -65,6 +65,8 @@
"build:watch": "tsc -w",
"link": "yarn run build && chmod +x distribution/commands/danger.js && yarn link",
"package": "yarn run pkg . --output brew-distribution/danger; zip -j brew-distribution/danger-macos.zip brew-distribution/danger; shasum -a 256 brew-distribution/danger-macos.zip",
"package:x64": "yarn run pkg . --output brew-distribution/danger-x64 --targets node16-macos-x64; zip -j brew-distribution/danger-macos-x64.zip brew-distribution/danger-x64; shasum -a 256 brew-distribution/danger-macos-x64.zip",
"package:arm64": "yarn run pkg . --output brew-distribution/danger-arm64 --targets node16-macos-arm64; zip -j brew-distribution/danger-macos-arm64.zip brew-distribution/danger-arm64; shasum -a 256 brew-distribution/danger-macos-arm64.zip",
"declarations": "ts-node ./scripts/create-danger-dts.ts",
"docs:cp_defs": "mkdir docs/docs_generate; cp source/danger.d.ts docs/docs_generate; cp node_modules/@octokit/rest/index.d.ts docs/docs_generate/github.d.ts",
"docs": "yarn run docs:cp_defs; yarn typedoc --ignoreCompilerErrors --mode modules --json docs/js_ref_dsl_docs.json --includeDeclarations source",
Expand Down Expand Up @@ -99,16 +101,14 @@
"@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",
"@types/jsonwebtoken": "^7.2.8",
"@types/jsonwebtoken": "^9.0.0",
"@types/lodash.includes": "^4.3.4",
"@types/lodash.mapvalues": "^4.6.6",
"@types/lodash.memoize": "^4.1.3",
"@types/micromatch": "^3.1.0",
"@types/nock": "^10.0.3",
"@types/node": "^10.11.3",
"@types/node-fetch": "^2.5.12",
"@types/p-limit": "^2.0.0",
Expand All @@ -130,7 +130,7 @@
"jest-json-reporter": "^1.2.2",
"lint-staged": "^12.3.7",
"madge": "^5.0.1",
"nock": "^10.0.6",
"nock": "^13.2.0",
"pkg": "^5.4.0",
"prettier": "^2.5.1",
"release-it": "^13.5.2",
Expand All @@ -150,13 +150,13 @@
"debug": "^4.1.1",
"fast-json-patch": "^3.0.0-1",
"get-stdin": "^6.0.0",
"gitlab": "^10.0.1",
"http-proxy-agent": "^2.1.0",
"https-proxy-agent": "^2.2.1",
"@gitbeaker/node": "^21.3.0",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.1",
"hyperlinker": "^1.0.0",
"json5": "^2.1.0",
"jsonpointer": "^5.0.0",
"jsonwebtoken": "^8.4.0",
"jsonwebtoken": "^9.0.0",
"lodash.find": "^4.6.0",
"lodash.includes": "^4.3.0",
"lodash.isobject": "^3.0.2",
Expand Down
57 changes: 43 additions & 14 deletions scripts/create-homebrew-tap-pr.sh
Expand Up @@ -2,36 +2,65 @@

[ -z ${VERSION+x} ] && { echo "VERSION is missing"; exit 1; }

FILE=brew-distribution/danger-macos.zip
FILE_X64=brew-distribution/danger-macos-x64.zip
FILE_ARM64=brew-distribution/danger-macos-arm64.zip

if [ ! -f ${FILE} ]; then
echo ${FILE} not found!
if [ ! -f ${FILE_X64} ]; then
echo ${FILE_X64} not found!
exit 1
fi
if [ ! -f ${FILE_ARM64} ]; then
echo ${FILE_ARM64} not found!
exit 1
fi

SHA=$(shasum -a 256 ${FILE} | cut -f 1 -d " ")
echo "$SHA"
SHA_X64=$(shasum -a 256 ${FILE_X64} | cut -f 1 -d " ")
echo "SHA_X64=$SHA_X64"
SHA_ARM64=$(shasum -a 256 ${FILE_ARM64} | cut -f 1 -d " ")
echo "SHA_ARM64=$SHA_ARM64"

# Set up SSH
mkdir -p ~/.ssh
echo "${HOMEBREW_TAP_DEPLOY_SECRET_KEY}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
git config --global user.name danger
git config --global user.email danger@users.noreply.github.com
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
ssh -o StrictHostKeyChecking=no -F /dev/null -vT git@github.com

# Clone tap repo
HOMEBREW_TAP_TMPDIR=$(mktemp -d)
git clone --depth 1 https://github.com/danger/homebrew-tap.git "$HOMEBREW_TAP_TMPDIR"
git clone --depth 1 git@github.com:danger/homebrew-tap.git "$HOMEBREW_TAP_TMPDIR"
cd "$HOMEBREW_TAP_TMPDIR" || exit 1

# git config user.name danger
# git config user.email danger@users.noreply.github.com

# Write formula
echo "class DangerJs < Formula" > danger-js.rb
echo " homepage \"https://github.com/danger/danger-js\"" >> danger-js.rb
echo " url \"https://github.com/danger/danger-js/releases/download/${VERSION}/danger-macos.zip\"" >> danger-js.rb
echo " sha256 \"${SHA}\"" >> danger-js.rb
echo >> danger-js.rb
echo " def install" >> danger-js.rb
echo " bin.install \"danger\"" >> danger-js.rb
echo " if Hardware::CPU.intel?" >> danger-js.rb
echo " url \"https://github.com/danger/danger-js/releases/download/${VERSION}/danger-macos-x64.zip\"" >> danger-js.rb
echo " sha256 \"${SHA_X64}\"" >> danger-js.rb
echo >> danger-js.rb
echo " def install" >> danger-js.rb
echo " bin.install \"danger-x64\" => \"danger\"" >> danger-js.rb
echo " end" >> danger-js.rb
echo " end" >> danger-js.rb
echo >> danger-js.rb
echo " if Hardware::CPU.arm?" >> danger-js.rb
echo " url \"https://github.com/danger/danger-js/releases/download/${VERSION}/danger-macos-arm64.zip\"" >> danger-js.rb
echo " sha256 \"${SHA_ARM64}\"" >> danger-js.rb
echo >> danger-js.rb
echo " def install" >> danger-js.rb
echo " bin.install \"danger-arm64\" => \"danger\"" >> danger-js.rb
echo " end" >> danger-js.rb
echo " end" >> danger-js.rb
echo "end" >> danger-js.rb

# Commit changes
git add danger-js.rb
git commit -m "Releasing danger-js version ${VERSION}"
git push origin master
git remote rm origin
git remote add origin git@github.com:danger/homebrew-tap.git
git push origin master
2 changes: 1 addition & 1 deletion scripts/danger-dts.ts
Expand Up @@ -9,7 +9,7 @@ const createDTS = () => {
//
import { Octokit as GitHub } from "@octokit/rest"
import { Gitlab } from "gitlab"
import { Gitlab } from "@gitbeaker/node"
import { File } from "parse-diff"
`
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

0 comments on commit 042c4fa

Please sign in to comment.