From 8dcf74d050d4ea32a70019a8879b63dfd259a719 Mon Sep 17 00:00:00 2001 From: Ian Maia Date: Wed, 20 Sep 2023 12:00:17 +0200 Subject: [PATCH] Add initial Danger setup with Dangermattic --- .buildkite/commands/danger-pr-check.sh | 9 +++ .buildkite/danger/Dangerfile | 18 ++++++ .buildkite/pipeline.yml | 33 +++++++--- .rubocop.yml | 31 +++++++++ .ruby-version | 2 +- Gemfile | 4 +- Gemfile.lock | 89 +++++++++++++++++++++++++- 7 files changed, 173 insertions(+), 13 deletions(-) create mode 100755 .buildkite/commands/danger-pr-check.sh create mode 100644 .buildkite/danger/Dangerfile create mode 100644 .rubocop.yml diff --git a/.buildkite/commands/danger-pr-check.sh b/.buildkite/commands/danger-pr-check.sh new file mode 100755 index 00000000000..107926653e2 --- /dev/null +++ b/.buildkite/commands/danger-pr-check.sh @@ -0,0 +1,9 @@ +#!/bin/bash -eu + +export DANGER_GITHUB_API_TOKEN=${GITHUB_TOKEN} + +echo "--- :rubygems: Setting up Gems" +bundle install + +echo "--- Running Danger: PR Check" +bundle exec danger --fail-on-errors=true --dangerfile=.buildkite/danger/Dangerfile --remove-previous-comments --danger_id=pr-check diff --git a/.buildkite/danger/Dangerfile b/.buildkite/danger/Dangerfile new file mode 100644 index 00000000000..efd7a4e5a52 --- /dev/null +++ b/.buildkite/danger/Dangerfile @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +return if github.pr_labels.include?('Releases') + +manifest_pr_checker.check_gemfile_lock_updated +labels_checker.check( + required_labels: [//], + required_labels_error: 'PR is missing at least one label.' +) +view_changes_need_screenshots.view_changes_need_screenshots +pr_size_checker.check_diff_size +android_unit_test_checker.check_missing_tests +milestone_checker.check_milestone_due_date(days_before_due: 2) + +github.dismiss_out_of_range_messages +rubocop.lint inline_comment: true, fail_on_inline_comment: true, include_cop_names: true + +warn "No reviewers have been set for this PR yet. Please request a review from **@\u2028Automattic/pocket-casts-android**." unless github.pr_json['assignee'] diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 7666eb8923d..be880450276 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -16,6 +16,31 @@ steps: # Wait for Gradle Wrapper to be validated before running any other jobs - wait + - group: "Linters" + steps: + - label: "☢️ Danger - PR Check" + command: .buildkite/commands/danger-pr-check.sh + plugins: + - docker#v5.8.0: + image: "public.ecr.aws/docker/library/ruby:3.2.2" + propagate-environment: true + environment: + - "GITHUB_TOKEN" + if: "build.pull_request.id != null" + agents: + queue: "default" + retry: + manual: + permit_on_passed: true + + - label: 'Lint' + command: | + echo "--- 🧹 Linting" + ./gradlew lintDebug + plugins: *common_plugins + artifact_paths: + - "**/build/reports/lint-results*.*" + - label: 'Unit tests' command: | echo "--- 🧪 Testing" @@ -28,14 +53,6 @@ steps: ./gradlew spotlessCheck plugins: *common_plugins - - label: 'Lint' - command: | - echo "--- 🧹 Linting" - ./gradlew lintDebug - plugins: *common_plugins - artifact_paths: - - "**/build/reports/lint-results*.*" - - label: "Instrumented tests" command: | echo "--- :rubygems: Setting up Gems" diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000000..cd28203dcc8 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,31 @@ +inherit_mode: + merge: + - Include + +AllCops: + Exclude: + - vendor/**/* + Include: + - .buildkite/danger/**/* + NewCops: enable + +Layout/LineLength: + Max: 180 + Exclude: + - fastlane/Fastfile + - scripts/themes/generate_themes.rb + +Metrics/BlockLength: + Exclude: + - fastlane/Fastfile + - scripts/themes/generate_themes.rb + +Metrics/MethodLength: + Max: 30 + Exclude: + - fastlane/Fastfile + - scripts/themes/generate_themes.rb + +Naming/FileName: + Exclude: + - .buildkite/danger/Dangerfile diff --git a/.ruby-version b/.ruby-version index a4dd9dba4fb..be94e6f53db 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.4 +3.2.2 diff --git a/Gemfile b/Gemfile index 2f1069c5228..06d3e7d1c5f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,8 @@ # frozen_string_literal: true -source "https://rubygems.org" +source 'https://rubygems.org' + +gem 'danger-dangermattic', git: 'https://github.com/Automattic/dangermattic' gem 'fastlane', '~> 2' gem 'fastlane-plugin-wpmreleasetoolkit', '~> 9.0' diff --git a/Gemfile.lock b/Gemfile.lock index d5ca5622ba2..77e9d21c025 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,22 @@ +GIT + remote: https://github.com/Automattic/dangermattic + revision: 0635de8b07954c70a4ed908fc1619774cb8fd10d + specs: + danger-dangermattic (0.0.1) + danger (~> 9.3) + danger-junit (~> 1.0) + danger-plugin-api (~> 1.0) + danger-rubocop (~> 0.11) + danger-swiftlint (~> 0.29) + danger-xcode_summary (~> 1.0) + rubocop (~> 1.56) + GEM remote: https://rubygems.org/ specs: CFPropertyList (3.0.6) rexml - activesupport (7.1.0) + activesupport (7.1.1) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -16,9 +29,10 @@ GEM addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) artifactory (3.0.15) + ast (2.4.2) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.834.0) + aws-partitions (1.835.0) aws-sdk-core (3.185.1) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) @@ -40,12 +54,46 @@ GEM sawyer (>= 0.6) chroma (0.2.0) claide (1.1.0) + claide-plugins (0.9.2) + cork + nap + open4 (~> 1.3) colored (1.2) colored2 (3.1.2) commander (4.6.0) highline (~> 2.0.0) concurrent-ruby (1.2.2) connection_pool (2.4.1) + cork (0.3.0) + colored2 (~> 3.1) + danger (9.3.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) + no_proxy_fix + octokit (~> 6.0) + terminal-table (>= 1, < 4) + danger-junit (1.0.2) + danger (> 2.0) + ox (~> 2.0) + danger-plugin-api (1.0.0) + danger (> 2.0) + danger-rubocop (0.12.0) + danger + rubocop (~> 1.0) + danger-swiftlint (0.33.0) + danger + rake (> 10) + thor (~> 0.19) + danger-xcode_summary (1.2.0) + danger-plugin-api (~> 1.0) + xcresult (~> 0.2) declarative (0.0.20) diffy (3.4.2) digest-crc (0.6.5) @@ -75,6 +123,8 @@ GEM faraday-em_http (1.0.0) faraday-em_synchrony (1.0.0) faraday-excon (1.1.0) + faraday-http-cache (2.5.0) + faraday (>= 0.8) faraday-httpclient (1.0.1) faraday-multipart (1.0.4) multipart-post (~> 2) @@ -194,6 +244,11 @@ GEM jmespath (1.6.2) json (2.6.3) 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) mini_magick (4.12.0) mini_mime (1.1.5) minitest (5.20.0) @@ -201,7 +256,9 @@ GEM multipart-post (2.3.0) mutex_m (0.1.2) nanaimo (0.3.0) + nap (1.1.0) naturally (2.2.1) + no_proxy_fix (0.1.2) nokogiri (1.15.4-arm64-darwin) racc (~> 1.4) nokogiri (1.15.4-x86_64-darwin) @@ -209,20 +266,27 @@ GEM octokit (6.1.1) faraday (>= 1, < 3) sawyer (~> 0.9) + open4 (1.3.4) options (2.3.2) optparse (0.1.1) os (1.1.4) + ox (2.14.17) parallel (1.23.0) + parser (3.2.2.4) + ast (~> 2.4.1) + racc plist (3.7.0) progress_bar (1.3.3) highline (>= 1.6, < 3) options (~> 2.3.0) public_suffix (5.0.3) racc (1.7.1) + rainbow (3.1.1) rake (13.0.6) rake-compiler (1.2.5) rake rchardet (1.8.0) + regexp_parser (2.8.2) representable (3.2.0) declarative (< 0.1.0) trailblazer-option (>= 0.1.1, < 0.2.0) @@ -230,6 +294,21 @@ GEM retriable (3.1.2) rexml (3.2.6) rouge (2.0.7) + rubocop (1.57.1) + base64 (~> 0.1.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.4) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) rubyzip (2.3.2) sawyer (0.9.2) @@ -247,6 +326,7 @@ GEM terminal-notifier (2.0.0) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) + thor (0.20.3) trailblazer-option (0.1.2) tty-cursor (0.7.1) tty-screen (0.8.1) @@ -272,15 +352,18 @@ GEM rouge (~> 2.0.7) xcpretty-travis-formatter (1.0.1) xcpretty (~> 0.2, >= 0.0.7) + xcresult (0.2.1) PLATFORMS arm64-darwin-21 + arm64-darwin-22 x86_64-darwin-20 x86_64-darwin-21 DEPENDENCIES + danger-dangermattic! fastlane (~> 2) fastlane-plugin-wpmreleasetoolkit (~> 9.0) BUNDLED WITH - 2.3.22 + 2.4.19