-
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
[GitHub CI] Revert back to Ruby Danger as Danger JS is not working properly #1650
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
937e49a
Update ci.yml
Kaspik 5099490
Revert back Dangerfile and remove danger JS, create separate workflow…
Kaspik 839ba3a
remove PR ci
Kaspik b34e544
Revert "remove PR ci"
Kaspik 7375d07
cahnge token to default one
Kaspik e0c06a2
PR feedback
Kaspik af6362c
Rename danger.yml name
Kaspik 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
require 'open-uri' | ||
|
||
source_pattern = /(\.m|\.mm|\.h)$/ | ||
|
||
modified_source_files = git.modified_files.grep(source_pattern) | ||
has_modified_source_files = !modified_source_files.empty? | ||
added_source_files = git.added_files.grep(source_pattern) | ||
has_added_source_files = !added_source_files.empty? | ||
|
||
# Make it more obvious that a PR is a work in progress and shouldn't be merged yet | ||
warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]" | ||
|
||
# Warn when there is a big PR | ||
warn("This is a big PR, please consider splitting it up to ease code review.") if git.lines_of_code > 500 | ||
|
||
# Modifying the changelog will probably get overwritten. | ||
if git.modified_files.include?("CHANGELOG.md") && !github.pr_title.include?("#changelog") | ||
warn("PR modifies CHANGELOG.md, which is a generated file. Add #changelog to the title to suppress this warning.") | ||
end | ||
|
||
def full_license(partial_license, filename) | ||
license_header = <<-HEREDOC | ||
// | ||
HEREDOC | ||
license_header += "// " + filename + "\n" | ||
license_header += <<-HEREDOC | ||
// Texture | ||
// | ||
HEREDOC | ||
license_header += partial_license | ||
return license_header | ||
end | ||
|
||
def check_file_header(files_to_check, licenses) | ||
repo_name = github.pr_json["base"]["repo"]["full_name"] | ||
pr_number = github.pr_json["number"] | ||
files = github.api.pull_request_files(repo_name, pr_number) | ||
files.each do |file| | ||
if files_to_check.include?(file["filename"]) | ||
filename = File.basename(file["filename"]) | ||
|
||
data = "" | ||
contents = github.api.get file["contents_url"] | ||
open(contents["download_url"]) { |io| | ||
data += io.read | ||
} | ||
|
||
correct_license = false | ||
licenses.each do |license| | ||
license_header = full_license(license, filename) | ||
if data.include? "Pinterest, Inc." | ||
correct_license = true | ||
end | ||
end | ||
|
||
if correct_license == false | ||
warn ("Please ensure license is correct for #{filename}: \n```\n" + full_license(licenses[0], filename) + "```") | ||
end | ||
|
||
end | ||
end | ||
end | ||
|
||
# Ensure new files have proper header | ||
new_source_license_header = <<-HEREDOC | ||
// Copyright (c) Pinterest, Inc. All rights reserved. | ||
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0 | ||
HEREDOC | ||
|
||
if has_added_source_files | ||
check_file_header(added_source_files, [new_source_license_header]) | ||
end | ||
|
||
# Ensure modified files have proper header | ||
modified_source_license_header = <<-HEREDOC | ||
// Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. | ||
// Changes after 4/13/2017 are: Copyright (c) Pinterest, Inc. All rights reserved. | ||
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0 | ||
HEREDOC | ||
|
||
if has_modified_source_files | ||
check_file_header(modified_source_files, [modified_source_license_header, new_source_license_header]) | ||
end |
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 was deleted.
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.
With only one configuration, using a matrix is a bit overkill since you can just configure the job directly (like this). Please feel free to follow up on another PR but not a big deal otherwise.