-
-
Notifications
You must be signed in to change notification settings - Fork 767
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into deprecate-multi-rule
- Loading branch information
Showing
126 changed files
with
15,463 additions
and
920 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,41 @@ | ||
name: "Danger" | ||
|
||
on: | ||
issue_comment: | ||
pull_request_target: | ||
types: [assigned, opened, synchronize, reopened] | ||
branches: | ||
- "**" | ||
|
||
permissions: | ||
actions: write | ||
checks: write | ||
contents: write | ||
issues: write | ||
pull-requests: write | ||
statuses: write | ||
|
||
jobs: | ||
danger: | ||
name: Danger JS | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3 | ||
with: | ||
node-version: "16" | ||
cache: "yarn" | ||
cache-dependency-path: "website/yarn.lock" | ||
|
||
- name: Install Yarn Dependencies | ||
working-directory: bots/ | ||
run: yarn install | ||
|
||
- name: Run Danger | ||
working-directory: bots/ | ||
run: yarn danger ci | ||
env: | ||
DANGER_GITHUB_API_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
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,9 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Misc | ||
.DS_Store | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
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,62 @@ | ||
import { danger, fail, markdown, warn, message } from "danger"; | ||
|
||
// API reference: https://danger.systems/js/reference.html | ||
const pr = danger.github.pr; | ||
|
||
const functionalChanges = danger.git.fileMatch("**/src/main/kotlin/**/*.kt"); | ||
const testChanges = danger.git.fileMatch("**/src/test/kotlin/**/*.kt"); | ||
const docsChanges = danger.git.fileMatch("**/*.md"); | ||
const rulesChanges = danger.git.fileMatch( | ||
"detekt-rules-*/src/main/kotlin/**/*.kt" | ||
); | ||
const ruleTestChanges = danger.git.fileMatch( | ||
"detekt-rules-*/src/test/kotlin/**/*.kt" | ||
); | ||
const detektConfigFileChanges = danger.git.fileMatch( | ||
"**/default-detekt-config.yml" | ||
); | ||
const milestone = danger.github.pr.milestone; | ||
const prReviews = danger.github.reviews; | ||
|
||
// Warn if the PR contains a functional change without a test | ||
if (functionalChanges.length > 0 && testChanges.length === 0) { | ||
warn( | ||
"It looks like this PR contains functional changes without a corresponding test." | ||
); | ||
} | ||
|
||
// Handle PRs for new Detekt rules. | ||
if (rulesChanges.created) { | ||
message("Thanks for adding a new rule to Detekt :heart:"); | ||
if (ruleTestChanges.length === 0) { | ||
warn( | ||
"It looks like your new rule doesn't comes with tests. Make sure you include them." | ||
); | ||
} | ||
if (detektConfigFileChanges.length === 0) { | ||
warn( | ||
"It looks like you haven't updated the `default-detekt-config.yml` file in your PR. Make sure you run `./gradlew generateDocumentation`" | ||
); | ||
} | ||
} | ||
|
||
// If `default-detekt-config.yml` changes without a rule change, warn the user | ||
if (detektConfigFileChanges.length > 0 && rulesChanges.length === 0) { | ||
warn( | ||
"It looks like you're touching the `default-detekt-config.yml` file without updating the rules code. This file is automatically generated with the `gradlew generateDocumentation` task, so your changes will be overridden." | ||
); | ||
} | ||
|
||
// Say thank you to Website edits. | ||
if (docsChanges.edited) { | ||
message( | ||
"Thank you very much for making [our website](https://detekt.dev/) better :heart:!" | ||
); | ||
} | ||
|
||
// Warn if the PR has been accepted but has no milestone set. | ||
if (!milestone && prReviews.some((review) => review.state === "APPROVED")) { | ||
warn( | ||
"This PR is approved with no milestone set. If merged, it won't appear in the Detekt release notes." | ||
); | ||
} |
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,12 @@ | ||
{ | ||
"name": "@detekt/bots", | ||
"version": "1.0.0", | ||
"private": true, | ||
"description": "Bots and automation for Detekt", | ||
"type": "module", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"danger": "^11.1.1" | ||
} | ||
} |
Oops, something went wrong.