-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add dangerjs * test: add .sol file to test * refactor: better naming for the CI * fix: check all files * fix: check if review is approved * refactor: delete test file
- Loading branch information
1 parent
4c80f7f
commit 67fa12a
Showing
4 changed files
with
938 additions
and
187 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Danger CI | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize, edited] | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Use Node.js 16x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
cache: "yarn" | ||
- run: yarn install --frozen-lockfile | ||
- run: yarn danger ci | ||
env: | ||
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { warn, danger, message } from "danger"; | ||
|
||
const MINIMUM_REVIEWERS = 2; | ||
|
||
const files = [ | ||
...danger.git.modified_files, | ||
...danger.git.created_files, | ||
...danger.git.deleted_files, | ||
]; | ||
const hasContractChanges = files.some((file) => file.endsWith(".sol")); | ||
|
||
if (hasContractChanges) { | ||
const reviewers = danger.github.reviews.filter( | ||
(review) => review.state === "APPROVED" | ||
).length; | ||
|
||
if (reviewers < MINIMUM_REVIEWERS) { | ||
warn(`:eyes: This PR needs at least ${MINIMUM_REVIEWERS} reviewers`); | ||
} else { | ||
message(`:tada: This PR has ${reviewers} approved reviews`); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -11,5 +11,8 @@ | |
}, | ||
"engines": { | ||
"node": "16" | ||
}, | ||
"devDependencies": { | ||
"danger": "^11.2.8" | ||
} | ||
} |
Oops, something went wrong.