Skip to content

Commit 2654c1e

Browse files
committed
Integrate Danger in CircleCI
* Add jobs to run Danger as part of the CI * Add the `Dangerfile` with some basics rules for the project * Add the `Gemfile` to manage the Ruby dependencies
1 parent 1e90679 commit 2654c1e

File tree

4 files changed

+137
-2
lines changed

4 files changed

+137
-2
lines changed

.circleci/config.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
version: 2
22

33
jobs:
4+
danger:
5+
macos:
6+
xcode: 10.2.0
7+
steps:
8+
- checkout
9+
- run:
10+
name: Set Ruby Version
11+
command: echo "ruby-2.4" > ~/.ruby-version
12+
- restore_cache:
13+
key: 1-gems-{{ checksum "Gemfile.lock" }}
14+
- run:
15+
name: Install Ruby Dependencies
16+
command: bundle check || bundle install
17+
environment:
18+
BUNDLE_JOBS: 4
19+
BUNDLE_RETRY: 3
20+
- save_cache:
21+
key: 1-gems-{{ checksum "Gemfile.lock" }}
22+
paths:
23+
- vendor/bundle
24+
- run:
25+
name: Danger
26+
command: bundle exec danger
427
macos:
528
environment:
629
TEST_REPORTS: /tmp/test-results
@@ -51,5 +74,10 @@ workflows:
5174
version: 2
5275
tests:
5376
jobs:
54-
- linux
55-
- macos
77+
- danger
78+
- linux:
79+
requires:
80+
- danger
81+
- macos:
82+
requires:
83+
- danger

Dangerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# send a welcome message for the user
2+
message "Hey, @#{github.pr_author} 👋."
3+
4+
# Just to let people know
5+
warn("PR is classed as Work in Progress.") if github.pr_title.include? "[WIP]"
6+
7+
# Warn when there is a big PR
8+
warn("Big PR") if git.lines_of_code > 500
9+
10+
# ensure there is a summary for a PR
11+
fail "Please provide a summary in the Pull Request description." if github.pr_body.length < 5
12+
13+
# Changelog entries are required for changes to library files.
14+
fail("Please include a CHANGELOG entry. You can find it at [CHANGELOG.md](https://github.com/httpswift/swifter/blob/stable/CHANGELOG.md).") unless git.modified_files.include?("CHANGELOG.md") || git.added_files.include?("CHANGELOG.md")
15+
16+
# Don't accept PR on master for now
17+
fail "Please re-submit this PR to stable, you're trying to merge the PR on master." if github.branch_for_base == "master"
18+
19+
# If these are all empty something has gone wrong, better to raise it in a comment
20+
if git.modified_files.empty? && git.added_files.empty? && git.deleted_files.empty?
21+
fail "This PR has no changes at all, this is likely a developer issue."
22+
end
23+
24+
# Run SwiftLint
25+
swiftlint.config_file = '.swiftlint.yml'
26+
swiftlint.lint_files
27+
28+
# Warn when new tests are added but the XCTestManifests wasn't updated to run on Linux
29+
tests_added_or_modified = git.modified_files.grep(/XCode\/Tests/).empty? || git.added_files.grep(/XCode\/Tests/).empty?
30+
xc_manifest_updated = !git.modified_files.grep(/XCode\/Tests\/XCTestManifests.swift/).empty?
31+
if tests_added_or_modified && !xc_manifest_updated
32+
warn("It seems like you've added new tests to the library. If that's the case, please update the [XCTestManifests.swift](https://github.com/httpswift/swifter/blob/stable/XCode/Tests/XCTestManifests.swift) file running in your terminal the command `swift test --generate-linuxmain`.")
33+
34+
# This is a temporary warning to remove the entry for the failed test until we solve the issue in Linux
35+
warn("If you ran the command `swift test --generate-linuxmain` in your terminal, please remove the line `testCase(IOSafetyTests.__allTests__IOSafetyTests),` from `public func __allTests() -> [XCTestCaseEntry]` in the bottom of the file. For more reference see [#366](https://github.com/httpswift/swifter/issues/366).")
36+
end

Gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6+
7+
gem 'danger'
8+
gem 'danger-swiftlint'

Gemfile.lock

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
addressable (2.5.2)
5+
public_suffix (>= 2.0.2, < 4.0)
6+
claide (1.0.2)
7+
claide-plugins (0.9.2)
8+
cork
9+
nap
10+
open4 (~> 1.3)
11+
colored2 (3.1.2)
12+
cork (0.3.0)
13+
colored2 (~> 3.1)
14+
danger (6.0.6)
15+
claide (~> 1.0)
16+
claide-plugins (>= 0.9.2)
17+
colored2 (~> 3.1)
18+
cork (~> 0.1)
19+
faraday (~> 0.9)
20+
faraday-http-cache (~> 1.0)
21+
git (~> 1.5)
22+
kramdown (~> 2.0)
23+
kramdown-parser-gfm (~> 1.0)
24+
no_proxy_fix
25+
octokit (~> 4.7)
26+
terminal-table (~> 1)
27+
danger-swiftlint (0.20.1)
28+
danger
29+
rake (> 10)
30+
thor (~> 0.19)
31+
faraday (0.15.4)
32+
multipart-post (>= 1.2, < 3)
33+
faraday-http-cache (1.3.1)
34+
faraday (~> 0.8)
35+
git (1.5.0)
36+
kramdown (2.1.0)
37+
kramdown-parser-gfm (1.0.1)
38+
kramdown (~> 2.0)
39+
multipart-post (2.0.0)
40+
nap (1.1.0)
41+
no_proxy_fix (0.1.2)
42+
octokit (4.14.0)
43+
sawyer (~> 0.8.0, >= 0.5.3)
44+
open4 (1.3.4)
45+
public_suffix (3.0.3)
46+
rake (12.3.2)
47+
sawyer (0.8.1)
48+
addressable (>= 2.3.5, < 2.6)
49+
faraday (~> 0.8, < 1.0)
50+
terminal-table (1.8.0)
51+
unicode-display_width (~> 1.1, >= 1.1.1)
52+
thor (0.20.3)
53+
unicode-display_width (1.5.0)
54+
55+
PLATFORMS
56+
ruby
57+
58+
DEPENDENCIES
59+
danger
60+
danger-swiftlint
61+
62+
BUNDLED WITH
63+
1.16.5

0 commit comments

Comments
 (0)