Skip to content

Commit

Permalink
Add initial Danger setup with Dangermattic
Browse files Browse the repository at this point in the history
  • Loading branch information
iangmaia committed Oct 5, 2023
1 parent f0ec4b0 commit bae6cdb
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .buildkite/commands/danger-pr-check.sh
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions .buildkite/danger/Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

def release_branch?
danger.github.branch_for_base.start_with?('release/') || danger.github.branch_for_base.start_with?('hotfix/')
end

def main_branch?
danger.github.branch_for_base == 'develop' || danger.github.branch_for_base == 'trunk' || danger.github.branch_for_base == 'main'
end

def wip_feature?
has_wip_label = github.pr_labels.any? { |label| label.include?('WIP Feature') || label == 'WIP' }
has_wip_title = github.pr_title.include?('[WIP]')

has_wip_label || has_wip_title
end

# if we have a shared Dangerfile, we can import it here
# danger.import_dangerfile(gem: 'danger-dangermattic')

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(
file_selector: ->(path) { !path.include?('/src/test') },
max_size: 300
)
android_unit_test_checker.check_missing_tests

# skip for draft PRs and for wip features unless the PR is against "develop" or "release/x.x" branches
milestone_checker.check_milestone_due_date(days_before_due: 4) if !github.pr_draft? && (!wip_feature? || (release_branch? || main_branch?))

github.dismiss_out_of_range_messages
rubocop.lint inline_comment: true, fail_on_inline_comment: true, include_cop_names: true
10 changes: 10 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ steps:
#################
- 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"

- label: "🕵️ checkstyle"
command: |
cp gradle.properties-example gradle.properties
Expand Down
20 changes: 20 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
inherit_mode:
merge:
- Include

AllCops:
Exclude:
- vendor/**/*
Include:
- .buildkite/danger/**/*
NewCops: enable

Metrics/MethodLength:
Max: 30

Layout/LineLength:
Max: 180

Naming/FileName:
Exclude:
- .buildkite/danger/Dangerfile
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

source 'https://rubygems.org'

gem 'danger-dangermattic', git: 'https://github.com/Automattic/dangermattic'
gem 'fastlane', '~> 2'
gem 'nokogiri'

Expand Down
99 changes: 96 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
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.0.8)
activesupport (7.1.0)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
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.830.0)
aws-sdk-core (3.184.0)
aws-partitions (1.833.0)
aws-sdk-core (3.185.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
Expand All @@ -29,22 +48,61 @@ GEM
aws-sigv4 (1.6.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.1.1)
bigdecimal (3.1.4)
buildkit (1.5.0)
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)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.8.1)
drb (2.1.1)
ruby2_keywords
emoji_regex (3.2.3)
excon (0.104.0)
faraday (1.10.3)
Expand All @@ -65,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)
Expand Down Expand Up @@ -184,34 +244,49 @@ 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)
mini_portile2 (2.8.4)
minitest (5.20.0)
multi_json (1.15.0)
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)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
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.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
Expand All @@ -220,6 +295,21 @@ GEM
rexml (3.2.6)
rmagick (4.3.0)
rouge (2.0.7)
rubocop (1.56.4)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
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)
Expand All @@ -237,6 +327,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)
Expand All @@ -262,11 +353,13 @@ GEM
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)
xcresult (0.2.1)

PLATFORMS
ruby

DEPENDENCIES
danger-dangermattic!
fastlane (~> 2)
fastlane-plugin-wpmreleasetoolkit (~> 9.0)
nokogiri
Expand Down

0 comments on commit bae6cdb

Please sign in to comment.