Skip to content
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 7 commits into from
Aug 31, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push, pull_request]
on: [push]

jobs:
buildsh:
Expand Down Expand Up @@ -29,4 +29,5 @@ jobs:
steps:
- name: Checkout the Git repository
uses: actions/checkout@v1
- run: ./build.sh ${{ matrix.mode }}
- name: Run build script
run: ./build.sh ${{ matrix.mode }}
37 changes: 37 additions & 0 deletions .github/workflows/ci_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on: [pull_request]

jobs:
buildsh:
strategy:
matrix:
mode: [tests, danger, framework, life-without-cocoapods, carthage, examples-pt1, examples-pt2, examples-pt3, examples-pt4]
include:
- mode: tests
name: Build and run tests
- mode: danger
name: Run Danger
- mode: framework
name: Build Texture as a dynamic framework
- mode: life-without-cocoapods
name: Build Texture as a static library
- mode: carthage
name: Verify that Carthage works
- mode: examples-pt1
name: Build examples (examples-pt1)
- mode: examples-pt2
name: Build examples (examples-pt2)
- mode: examples-pt3
name: Build examples (examples-pt3)
- mode: examples-pt4
name: Build examples (examples-pt4)
name: ${{ matrix.name }}
runs-on: macOS-10.14
steps:
- name: Checkout the Git repository
uses: actions/checkout@v1
- name: Run build script
run: ./build.sh ${{ matrix.mode }}
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 0 additions & 28 deletions .github/workflows/danger.yml

This file was deleted.

83 changes: 83 additions & 0 deletions Dangerfile
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
7 changes: 7 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ if [ "$MODE" = "tests" -o "$MODE" = "all" ]; then
success="1"
fi

if [ "$MODE" = "danger" -o "$MODE" = "all" ]; then
bundle install
echo "Running Danger..."
bundle exec danger --fail-on-errors=true
success="1"
fi

if [ "$MODE" = "tests_listkit" ]; then
echo "Building & testing AsyncDisplayKit+IGListKit."
pod install --project-directory=SubspecWorkspaces/ASDKListKit
Expand Down
89 changes: 0 additions & 89 deletions dangerfile.js

This file was deleted.