-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dangermattic checks update #20132
Merged
Merged
Dangermattic checks update #20132
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5c411d6
Upgrade Dangermattic Gem
iangmaia 83b964a
Update Dangerfile to use latest Dangermattic plugins
iangmaia 1ecc225
Use published Dangermattic Gem
iangmaia f6896e1
Fix RuboCop offense
iangmaia 57413fd
Use versioned shared GitHub Actions Workflow
iangmaia 530c0cf
Tweaks to prevent unnecessary checks running while a PR is a Draft
iangmaia 49f63b4
Add Dangerfile improvements from PR feedback
iangmaia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,12 @@ name: ☢️ Danger | |
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, edited, review_requested, review_request_removed, labeled, unlabeled, milestoned, demilestoned] | ||
types: [opened, reopened, ready_for_review, synchronize, edited, labeled, unlabeled, milestoned, demilestoned] | ||
|
||
jobs: | ||
dangermattic: | ||
uses: Automattic/dangermattic/.github/workflows/reusable-run-danger.yml@trunk | ||
# runs on draft PRs only for opened / synchronize events | ||
if: ${{ (github.event.pull_request.draft == false) || (github.event.pull_request.draft == true && contains(fromJSON('["opened", "synchronize"]'), github.event.action)) }} | ||
uses: Automattic/dangermattic/.github/workflows/[email protected] | ||
secrets: | ||
github-token: ${{ secrets.DANGERMATTIC_GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
def release_branch? | ||
danger.github.branch_for_base.start_with?('release/') || danger.github.branch_for_base.start_with?('hotfix/') | ||
end | ||
github.dismiss_out_of_range_messages | ||
|
||
def main_branch? | ||
danger.github.branch_for_base == 'trunk' | ||
end | ||
# `files: []` forces rubocop to scan all files, not just the ones modified in the PR | ||
rubocop.lint(files: [], force_exclusion: true, inline_comment: true, fail_on_inline_comment: true, include_cop_names: true) | ||
|
||
def wip_feature? | ||
has_wip_label = github.pr_labels.any? { |label| label.include?('WIP') } | ||
has_wip_title = github.pr_title.include?('WIP') | ||
manifest_pr_checker.check_gemfile_lock_updated | ||
|
||
has_wip_label || has_wip_title | ||
end | ||
android_release_checker.check_release_notes_and_play_store_strings | ||
|
||
return if github.pr_labels.include?('Releases') | ||
android_strings_checker.check_strings_do_not_refer_resource | ||
|
||
github.dismiss_out_of_range_messages | ||
# skip remaining checks if we're in a release-process PR | ||
if github.pr_labels.include?('Releases') | ||
message('This PR has the `Releases` label: some checks will be skipped.') | ||
return | ||
end | ||
|
||
manifest_pr_checker.check_gemfile_lock_updated | ||
common_release_checker.check_internal_release_notes_changed(report_type: :message) | ||
|
||
labels_checker.check( | ||
required_labels: [//], | ||
required_labels_error: 'PR requires at least one label.' | ||
) | ||
android_release_checker.check_modified_strings_on_release | ||
|
||
view_changes_need_screenshots.view_changes_need_screenshots | ||
view_changes_checker.check | ||
|
||
pr_size_checker.check_diff_size( | ||
file_selector: ->(path) { !path.include?('/src/test') }, | ||
max_size: 300 | ||
max_size: 300, | ||
file_selector: ->(path) { !path.include?('/src/test') } | ||
) | ||
|
||
android_unit_test_checker.check_missing_tests | ||
|
||
# skip check for draft PRs and for WIP features unless the PR is against the main branch or release branch | ||
milestone_checker.check_milestone_due_date(days_before_due: 4) unless github.pr_draft? || (wip_feature? && !(release_branch? || main_branch?)) | ||
# 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: [//], | ||
required_labels_error: 'PR requires at least one label.' | ||
) | ||
|
||
rubocop.lint(inline_comment: true, fail_on_inline_comment: true, include_cop_names: true) | ||
# runs the milestone check if this is not a WIP feature and the PR is against the main branch or the release branch | ||
milestone_checker.check_milestone_due_date(days_before_due: 4) if (github_utils.main_branch? || github_utils.release_branch?) && !github_utils.wip_feature? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL