diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml new file mode 100644 index 000000000..1249453ab --- /dev/null +++ b/.github/workflows/danger.yml @@ -0,0 +1,24 @@ +name: Danger +on: + pull_request: + types: [opened, synchronize, reopened] +jobs: + danger: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2.1' + + - name: Install dependencies + run: bundle install + + + - name: Run Danger + env: + DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_BOT_TOKEN_PLACEHOLDER }} + run: bundle exec danger --verbose \ No newline at end of file diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 000000000..25296d31c --- /dev/null +++ b/Dangerfile @@ -0,0 +1,6 @@ +# Rule 1: PR should not be too small (less than 50 lines of code) +fail("Your pull request should not be too small (less than 50 LoC).") if git.lines_of_code < 50 + + +# Rule 2: PR should not touch too many files (more than 30 files) +fail("Your pull request should not touch too many files (more than 30 files).") if git.modified_files.size + git.added_files.size > 30 \ No newline at end of file diff --git a/Gemfile b/Gemfile index 1786836d0..cec1df9ee 100644 --- a/Gemfile +++ b/Gemfile @@ -44,6 +44,7 @@ group :development, :test do gem 'rswag-specs' gem 'rubocop' gem 'simplecov', require: false, group: :test + gem 'danger' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index cb84960a2..172ac48d6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -69,12 +69,35 @@ GEM addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) + base64 (0.2.0) bcrypt (3.1.19) bootsnap (1.16.0) msgpack (~> 1.2) builder (3.2.4) + claide (1.1.0) + claide-plugins (0.9.2) + cork + nap + open4 (~> 1.3) + colored2 (3.1.2) concurrent-ruby (1.2.2) + cork (0.3.0) + colored2 (~> 3.1) crass (1.0.6) + danger (9.5.1) + base64 (~> 0.2) + claide (~> 1.0) + claide-plugins (>= 0.9.2) + colored2 (~> 3.1) + cork (~> 0.1) + faraday (>= 0.9.0, < 3.0) + faraday-http-cache (~> 2.0) + git (~> 1.13) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.0) + octokit (>= 4.0) + pstore (~> 0.1) + terminal-table (>= 1, < 4) date (3.3.3) debug (1.8.0) irb (>= 1.5.0) @@ -89,8 +112,19 @@ GEM railties (>= 5.0.0) faker (3.2.0) i18n (>= 1.8.11, < 2) + faraday (2.12.2) + faraday-net_http (>= 2.0, < 3.5) + json + logger + faraday-http-cache (2.5.1) + faraday (>= 0.8) + faraday-net_http (3.4.0) + net-http (>= 0.5.0) find_with_order (1.3.1) activerecord (>= 3) + git (1.19.1) + addressable (~> 2.8) + rchardet (~> 1.8) globalid (1.1.0) activesupport (>= 5.0) i18n (1.14.1) @@ -102,8 +136,13 @@ GEM json-schema (3.0.0) addressable (>= 2.8) jwt (2.7.1) + kramdown (2.4.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) language_server-protocol (3.17.0.3) lingua (0.6.2) + logger (1.6.6) loofah (2.21.3) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -118,6 +157,9 @@ GEM minitest (5.19.0) msgpack (1.7.2) mysql2 (0.5.5) + nap (1.1.0) + net-http (0.6.0) + uri net-imap (0.3.7) date net-protocol @@ -136,10 +178,15 @@ GEM racc (~> 1.4) nokogiri (1.15.2-x86_64-linux) racc (~> 1.4) + octokit (9.2.0) + faraday (>= 1, < 3) + sawyer (~> 0.9) + open4 (1.3.4) parallel (1.23.0) parser (3.2.2.3) ast (~> 2.4.1) racc + pstore (0.1.4) public_suffix (5.0.3) puma (5.6.6) nio4r (~> 2.0) @@ -179,6 +226,7 @@ GEM zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) + rchardet (1.9.0) regexp_parser (2.8.1) reline (0.3.7) io-console (~> 0.5) @@ -224,6 +272,9 @@ GEM rubocop-ast (1.29.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) + sawyer (0.9.2) + addressable (>= 2.3.5) + faraday (>= 0.17.3, < 3) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -231,6 +282,8 @@ GEM simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) spring (4.1.1) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) thor (1.2.2) timeout (0.4.0) tzinfo (2.0.6) @@ -238,6 +291,7 @@ GEM tzinfo-data (1.2023.3) tzinfo (>= 1.0.0) unicode-display_width (2.4.2) + uri (1.0.2) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -252,6 +306,7 @@ PLATFORMS DEPENDENCIES bcrypt (~> 3.1.7) bootsnap + danger debug factory_bot_rails faker