Skip to content

Commit 10a7282

Browse files
authored
Merge pull request #1 from Elemigrante/danger
feat: add danger
2 parents 0b1b789 + bbddfac commit 10a7282

File tree

8 files changed

+249
-1
lines changed

8 files changed

+249
-1
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Set to true to add reviewers to pull requests
2+
addReviewers: true
3+
4+
# Set to true to add assignees to pull requests
5+
addAssignees: false
6+
7+
# A list of team reviewers to be added to pull requests (GitHub team slug)
8+
reviewers:
9+
- org/teamReviewerA
10+
- org/teamReviewerB
11+
- /teamReviewerC
12+
13+
# Number of reviewers has no impact on Github teams
14+
# Set 0 to add all the reviewers (default: 0)
15+
numberOfReviewers: 0
16+
17+
# A list of assignees, overrides reviewers if set
18+
# assignees:
19+
# - assigneeA
20+
21+
# A number of assignees to add to the pull request
22+
# Set to 0 to add all of the assignees.
23+
# Uses numberOfReviewers if unset.
24+
# numberOfAssignees: 2
25+
26+
# A list of keywords to be skipped the process that add reviewers if pull requests include it
27+
# skipKeywords:
28+
# - wip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Danger
2+
3+
on:
4+
# Triggers the workflow on push or pull request events but only for the master branch
5+
pull_request:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
if: github.event_name == 'pull_request' # if only run pull request when multiple trigger workflow
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up ruby
16+
uses: actions/setup-ruby@v1
17+
with:
18+
ruby-version: '3.0.2'
19+
- uses: actions/cache@v1
20+
with:
21+
path: vendor/bundle
22+
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile') }} # change your gemfile path
23+
restore-keys: |
24+
${{ runner.os }}-gems-
25+
- name: Run Auto assign
26+
uses: kentaro-m/[email protected]
27+
with:
28+
repo-token: ${{ secrets.GITHUB_TOKEN }} # sets in repo settings/secrets
29+
configuration-path: .github/auto_assign.yml
30+
- name: Run brakeman with reviewdog
31+
uses: reviewdog/action-brakeman@v1
32+
with:
33+
brakeman_flags: --color
34+
github_token: ${{ secrets.github_token }}
35+
reporter: github-pr-review # Default is github-pr-check
36+
- name: Run Danger
37+
uses: MeilCli/danger-action@v5
38+
with:
39+
plugins_file: 'Gemfile'
40+
install_path: 'vendor/bundle'
41+
danger_file: 'Dangerfile'
42+
danger_id: 'danger-pr'
43+
env:
44+
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} # sets in repo settings/secrets

rails-bootstrap/Dangerfile

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Sometimes it's a README fix, or something like that - which isn't relevant for
2+
# including in a project's CHANGELOG for example
3+
declared_trivial = github.pr_title.include? "#trivial"
4+
5+
# Make it more obvious that a PR is a work in progress and shouldn't be merged yet
6+
warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]"
7+
8+
# Warn when there is a big PR
9+
warn("Big PR") if git.lines_of_code > 500
10+
11+
# Don't let testing shortcuts get into master by accident
12+
fail("fdescribe left in tests") if `grep -r fdescribe spec/ `.length > 1
13+
fail("fit left in tests") if `grep -r fit spec/ `.length > 1
14+
15+
# Ensure that labels have been used on the PR
16+
failure "Please add labels to this PR" if github.pr_labels.empty?
17+
18+
# Ensure there is a summary for a PR
19+
failure "Please provide a summary in the Pull Request description" if github.pr_body.length < 5
20+
21+
# Note when a PR cannot be manually merged, which goes away when you can
22+
can_merge = github.pr_json["mergeable"]
23+
warn("This PR cannot be merged yet.", sticky: false) unless can_merge
24+
25+
# Ensure that body of PR is not empty
26+
failure "Please add text to PR body" if github.pr_body.empty?
27+
28+
# Changelog check
29+
changelog.check!
30+
31+
# Commit lint check
32+
commit_lint.check
33+
34+
# Runs rails_best_practices on modified and added files in the PR
35+
rails_best_practices.lint
36+
37+
# Suggest code changes through inline comments in pull requests.
38+
suggester.suggest
39+
40+
# README.md has a TOC
41+
toc.check!
42+
43+
# Runs danger-rubocop linter
44+
rubocop.lint

rails-bootstrap/Gemfile.tt

+8
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ group :development do
103103
gem "brakeman", require: false
104104
gem "bundler-audit", ">= 0.9.0"
105105
gem "derailed_benchmarks"
106+
gem "danger"
107+
gem "danger-brakeman_scanner"
108+
gem "danger-changelog", "~> 0.6.1"
109+
gem "danger-commit_lint"
110+
gem "danger-rails_best_practices", "~> 0.1.3"
111+
gem "danger-suggester"
112+
gem "danger-toc", "~> 0.2.0"
113+
gem "danger-rubocop"
106114
gem "erb_lint"
107115
gem "fasterer"
108116
gem "pry-rails"
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Set to true to add reviewers to pull requests
2+
addReviewers: true
3+
4+
# Set to true to add assignees to pull requests
5+
addAssignees: false
6+
7+
# A list of team reviewers to be added to pull requests (GitHub team slug)
8+
reviewers:
9+
- org/teamReviewerA
10+
- org/teamReviewerB
11+
- /teamReviewerC
12+
13+
# Number of reviewers has no impact on Github teams
14+
# Set 0 to add all the reviewers (default: 0)
15+
numberOfReviewers: 0
16+
17+
# A list of assignees, overrides reviewers if set
18+
# assignees:
19+
# - assigneeA
20+
21+
# A number of assignees to add to the pull request
22+
# Set to 0 to add all of the assignees.
23+
# Uses numberOfReviewers if unset.
24+
# numberOfAssignees: 2
25+
26+
# A list of keywords to be skipped the process that add reviewers if pull requests include it
27+
# skipKeywords:
28+
# - wip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Danger
2+
3+
on:
4+
# Triggers the workflow on push or pull request events but only for the master branch
5+
pull_request:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
if: github.event_name == 'pull_request' # if only run pull request when multiple trigger workflow
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up ruby
16+
uses: actions/setup-ruby@v1
17+
with:
18+
ruby-version: '3.0.2'
19+
- uses: actions/cache@v1
20+
with:
21+
path: vendor/bundle
22+
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile') }} # change your gemfile path
23+
restore-keys: |
24+
${{ runner.os }}-gems-
25+
- name: Run Auto assign
26+
uses: kentaro-m/[email protected]
27+
with:
28+
repo-token: ${{ secrets.GITHUB_TOKEN }} # sets in repo settings/secrets
29+
configuration-path: .github/auto_assign.yml
30+
- name: Run brakeman with reviewdog
31+
uses: reviewdog/action-brakeman@v1
32+
with:
33+
brakeman_flags: --color
34+
github_token: ${{ secrets.github_token }}
35+
reporter: github-pr-review # Default is github-pr-check
36+
- name: Run Danger
37+
uses: MeilCli/danger-action@v5
38+
with:
39+
plugins_file: 'Gemfile'
40+
install_path: 'vendor/bundle'
41+
danger_file: 'Dangerfile'
42+
danger_id: 'danger-pr'
43+
env:
44+
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} # sets in repo settings/secrets

rails-tailwind/Dangerfile

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Sometimes it's a README fix, or something like that - which isn't relevant for
2+
# including in a project's CHANGELOG for example
3+
declared_trivial = github.pr_title.include? "#trivial"
4+
5+
# Make it more obvious that a PR is a work in progress and shouldn't be merged yet
6+
warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]"
7+
8+
# Warn when there is a big PR
9+
warn("Big PR") if git.lines_of_code > 500
10+
11+
# Don't let testing shortcuts get into master by accident
12+
fail("fdescribe left in tests") if `grep -r fdescribe spec/ `.length > 1
13+
fail("fit left in tests") if `grep -r fit spec/ `.length > 1
14+
15+
# Ensure that labels have been used on the PR
16+
failure "Please add labels to this PR" if github.pr_labels.empty?
17+
18+
# Ensure there is a summary for a PR
19+
failure "Please provide a summary in the Pull Request description" if github.pr_body.length < 5
20+
21+
# Note when a PR cannot be manually merged, which goes away when you can
22+
can_merge = github.pr_json["mergeable"]
23+
warn("This PR cannot be merged yet.", sticky: false) unless can_merge
24+
25+
# Ensure that body of PR is not empty
26+
failure "Please add text to PR body" if github.pr_body.empty?
27+
28+
# Changelog check
29+
changelog.check!
30+
31+
# Commit lint check
32+
commit_lint.check
33+
34+
# Runs rails_best_practices on modified and added files in the PR
35+
rails_best_practices.lint
36+
37+
# Suggest code changes through inline comments in pull requests.
38+
suggester.suggest
39+
40+
# README.md has a TOC
41+
toc.check!
42+
43+
# Runs danger-rubocop linter
44+
rubocop.lint

rails-tailwind/Gemfile.tt

+9-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ group :development, :test do
8080
gem "rubocop-performance"
8181
gem "rubocop-rails"
8282
gem "rubocop-rspec"
83-
gem "simplecov", require: false
83+
gem "simplecov", require: false
8484

8585
gem "capybara"
8686
gem "cucumber-rails", require: false
@@ -103,6 +103,14 @@ group :development do
103103
gem "brakeman", require: false
104104
gem "bundler-audit", ">= 0.9.0"
105105
gem "derailed_benchmarks"
106+
gem "danger"
107+
gem "danger-brakeman_scanner"
108+
gem "danger-changelog", "~> 0.6.1"
109+
gem "danger-commit_lint"
110+
gem "danger-rails_best_practices", "~> 0.1.3"
111+
gem "danger-suggester"
112+
gem "danger-toc", "~> 0.2.0"
113+
gem "danger-rubocop"
106114
gem "erb_lint"
107115
gem "fasterer"
108116
gem "pry-rails"

0 commit comments

Comments
 (0)