From 4c31530d001f4481431386aaaacb03237fe40fc8 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Tue, 10 Sep 2024 19:16:58 +0200 Subject: [PATCH] [Tooling] Setup Dangermattic (#113) * Setup Ruby * Setup Danger * Add Danger action to trigger Danger on Buildkite * Update CHANGELOG * Add review request events as Danger triggers * Replace Unicode emojis * Apply suggestions from code review Co-authored-by: Gio Lodi * Revert "Replace Unicode emojis" This reverts commit 8a3b87405e6ea6d5e1b404b1582c1577f48581ba. --------- Co-authored-by: Gio Lodi --- .buildkite/pipeline.yml | 10 ++++ .bundle/config | 4 ++ .github/workflows/run-danger.yml | 17 ++++++ .gitignore | 5 ++ CHANGELOG.md | 2 +- Dangerfile | 19 ++++++ Gemfile | 5 ++ Gemfile.lock | 99 ++++++++++++++++++++++++++++++++ 8 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 .bundle/config create mode 100644 .github/workflows/run-danger.yml create mode 100644 Dangerfile create mode 100644 Gemfile create mode 100644 Gemfile.lock diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 39675217..785a0ff9 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -15,6 +15,16 @@ steps: agents: queue: default + - label: "☢️ Danger - PR Check" + command: danger + key: danger + if: build.pull_request.id != null + retry: + manual: + permit_on_passed: true + agents: + queue: linter + - group: ":swift: install_swiftpm_dependencies Tests" steps: - label: ":swift: Standalone Swift Package - Autodetect" diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 00000000..33296338 --- /dev/null +++ b/.bundle/config @@ -0,0 +1,4 @@ +--- +BUNDLE_PATH: "vendor/bundle" +BUNDLE_JOBS: "16" +BUNDLE_SPECIFIC_PLATFORM: "false" diff --git a/.github/workflows/run-danger.yml b/.github/workflows/run-danger.yml new file mode 100644 index 00000000..25e63db7 --- /dev/null +++ b/.github/workflows/run-danger.yml @@ -0,0 +1,17 @@ +name: ☢️ Trigger Danger On Buildkite + +on: + pull_request: + types: [labeled, unlabeled, ready_for_review, review_requested, review_request_removed] + +jobs: + dangermattic: + if: ${{ (github.event.pull_request.draft == false) }} + uses: Automattic/dangermattic/.github/workflows/reusable-retry-buildkite-step-on-events.yml@v1.1.2 + with: + org-slug: automattic + pipeline-slug: ci-toolkit-buildkite-plugin + retry-step-key: danger + build-commit-sha: ${{ github.event.pull_request.head.sha }} + secrets: + buildkite-api-token: ${{ secrets.TRIGGER_BK_BUILD_TOKEN }} diff --git a/.gitignore b/.gitignore index 6a4c552b..ad3096f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ .DS_Store + +# IntelliJ .idea/ + +# Bundler +vendor/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e85f97b..2b08fed9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,7 +46,7 @@ _None._ ### Internal Changes -_None._ +- Tooling change: Dangermattic setup [#113] ## 3.6.0 diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 00000000..46e925a3 --- /dev/null +++ b/Dangerfile @@ -0,0 +1,19 @@ +# Check that the PR contains changes to the CHANGELOG.md file. +unless git.modified_files.include?('CHANGELOG.md') + warn('Please add an entry in the `CHANGELOG.md` file to describe the changes made by this PR') +end + +pr_size_checker.check_diff_size(max_size: 500) + +# skip remaining checks if the PR is still a Draft +if github.pr_draft? + message('This PR is still a Draft: some checks will be skipped.') + return +end + +labels_checker.check( + do_not_merge_labels: ['do not merge'], + required_labels: [] +) + +warn("This PR has no reviewers. Please request a review from **@\u2060Automattic/apps-infrastructure**.") unless github_utils.requested_reviewers? diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..a42d3a6a --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem 'danger-dangermattic', '~> 1.1' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..87ab136b --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,99 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + ast (2.4.2) + claide (1.1.0) + claide-plugins (0.9.2) + cork + nap + open4 (~> 1.3) + colored2 (3.1.2) + cork (0.3.0) + colored2 (~> 3.1) + danger (9.5.0) + 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) + terminal-table (>= 1, < 4) + danger-dangermattic (1.1.2) + danger (~> 9.4) + danger-plugin-api (~> 1.0) + danger-rubocop (~> 0.13) + rubocop (~> 1.63) + danger-plugin-api (1.0.0) + danger (> 2.0) + danger-rubocop (0.13.0) + danger + rubocop (~> 1.0) + faraday (2.11.0) + faraday-net_http (>= 2.0, < 3.4) + logger + faraday-http-cache (2.5.1) + faraday (>= 0.8) + faraday-net_http (3.3.0) + net-http + git (1.19.1) + addressable (~> 2.8) + rchardet (~> 1.8) + json (2.7.2) + kramdown (2.4.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + language_server-protocol (3.17.0.3) + logger (1.6.1) + nap (1.1.0) + net-http (0.4.1) + uri + octokit (9.1.0) + faraday (>= 1, < 3) + sawyer (~> 0.9) + open4 (1.3.4) + parallel (1.26.3) + parser (3.3.5.0) + ast (~> 2.4.1) + racc + public_suffix (6.0.1) + racc (1.8.1) + rainbow (3.1.1) + rchardet (1.8.0) + regexp_parser (2.9.2) + rexml (3.3.7) + rubocop (1.66.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.3) + parser (>= 3.3.1.0) + ruby-progressbar (1.13.0) + sawyer (0.9.2) + addressable (>= 2.3.5) + faraday (>= 0.17.3, < 3) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + unicode-display_width (2.5.0) + uri (0.13.1) + +PLATFORMS + arm64-darwin-23 + +DEPENDENCIES + danger-dangermattic (~> 1.1) + +BUNDLED WITH + 2.4.22