danger-samsao 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 608978c81f0415647bdf2a56bd87899397eccfca
4
+ data.tar.gz: 82332e9016b7efe03cee778b5fd43150cc494037
5
+ SHA512:
6
+ metadata.gz: c80089389404b1c748ba22e14621e77af2ac1f6de1c56b0202b75b35700b58d59def8ee0c4afb6a9ce88bb88bfb9c759388290c78f0b106a423363a9d96ae3ab
7
+ data.tar.gz: b84adde8c6cb832fcdc00b769ba088a002a37c0237e78bab75ea7bc0a26ef14fa4ab17af8f12b38d195622c6cd4ce91f344d88a9436f6e881b65136059ff9f77
@@ -0,0 +1 @@
1
+ DANGER_GITHUB_API_TOKEN=
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ .env
3
+ .yardoc
4
+
5
+ *.gem
@@ -0,0 +1,28 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'bin/**/*'
4
+ TargetRubyVersion: '2.1'
5
+
6
+ Metrics/BlockLength:
7
+ Max: 9999
8
+
9
+ Metrics/LineLength:
10
+ Max: 120
11
+
12
+ Style/IndentArray:
13
+ Enabled: false
14
+
15
+ Style/SignalException:
16
+ Enabled: false
17
+
18
+ Style/SymbolArray:
19
+ Enabled: false
20
+
21
+ Style/TrailingCommaInArguments:
22
+ EnforcedStyleForMultiline: comma
23
+
24
+ Style/TrailingCommaInLiteral:
25
+ EnforcedStyleForMultiline: comma
26
+
27
+ Style/WordArray:
28
+ Enabled: false
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ rvm:
7
+ - 2.0
8
+ - 2.1.3
9
+ - 2.3.1
10
+
11
+ script:
12
+ - bundle exec rake spec
@@ -0,0 +1,25 @@
1
+ ## 0.1.0 (May 1, 2017)
2
+
3
+ * Added `fail_when_merge_commit_detected` action.
4
+
5
+ * Added `warn_when_work_in_progess_pr` action.
6
+
7
+ * Added `changelog_modified?` helper.
8
+
9
+ * Updated `trivial_change?` helper to support `#typo` in PR title.
10
+
11
+ * Added `has_app_changes?` helper.
12
+
13
+ * Added `trivial_change?` helper.
14
+
15
+ * Added branch helpers:
16
+ * `fix_branch?`
17
+ * `feature_branch?`
18
+ * `release_branch?`
19
+ * `trivial_branch?`
20
+
21
+ * Added `fail_when_changelog_update_missing` action.
22
+
23
+ * Added `fail_when_non_single_commit_feature` action.
24
+
25
+ * Added `fail_when_wrong_branching_model` action.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-samsao.gemspec
4
+ gemspec
@@ -0,0 +1,136 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-samsao (0.1.0)
5
+ danger-plugin-api (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.5.1)
11
+ public_suffix (~> 2.0, >= 2.0.2)
12
+ ast (2.3.0)
13
+ claide (1.0.1)
14
+ claide-plugins (0.9.2)
15
+ cork
16
+ nap
17
+ open4 (~> 1.3)
18
+ coderay (1.1.1)
19
+ colored2 (3.1.2)
20
+ cork (0.3.0)
21
+ colored2 (~> 3.1)
22
+ danger (5.1.1)
23
+ claide (~> 1.0)
24
+ claide-plugins (>= 0.9.2)
25
+ colored2 (~> 3.1)
26
+ cork (~> 0.1)
27
+ faraday (~> 0.9)
28
+ faraday-http-cache (~> 1.0)
29
+ git (~> 1)
30
+ kramdown (~> 1.5)
31
+ octokit (~> 4.2)
32
+ terminal-table (~> 1)
33
+ danger-plugin-api (1.0.0)
34
+ danger (> 2.0)
35
+ diff-lcs (1.3)
36
+ faraday (0.12.1)
37
+ multipart-post (>= 1.2, < 3)
38
+ faraday-http-cache (1.3.1)
39
+ faraday (~> 0.8)
40
+ ffi (1.9.18)
41
+ formatador (0.2.5)
42
+ git (1.3.0)
43
+ guard (2.14.1)
44
+ formatador (>= 0.2.4)
45
+ listen (>= 2.7, < 4.0)
46
+ lumberjack (~> 1.0)
47
+ nenv (~> 0.1)
48
+ notiffany (~> 0.0)
49
+ pry (>= 0.9.12)
50
+ shellany (~> 0.0)
51
+ thor (>= 0.18.1)
52
+ guard-compat (1.2.1)
53
+ guard-rspec (4.7.3)
54
+ guard (~> 2.1)
55
+ guard-compat (~> 1.1)
56
+ rspec (>= 2.99.0, < 4.0)
57
+ guard-rubocop (1.2.0)
58
+ guard (~> 2.0)
59
+ rubocop (~> 0.20)
60
+ kramdown (1.13.2)
61
+ listen (3.1.5)
62
+ rb-fsevent (~> 0.9, >= 0.9.4)
63
+ rb-inotify (~> 0.9, >= 0.9.7)
64
+ ruby_dep (~> 1.2)
65
+ lumberjack (1.0.11)
66
+ method_source (0.8.2)
67
+ multipart-post (2.0.0)
68
+ nap (1.1.0)
69
+ nenv (0.3.0)
70
+ notiffany (0.1.1)
71
+ nenv (~> 0.1)
72
+ shellany (~> 0.0)
73
+ octokit (4.7.0)
74
+ sawyer (~> 0.8.0, >= 0.5.3)
75
+ open4 (1.3.4)
76
+ parser (2.4.0.0)
77
+ ast (~> 2.2)
78
+ powerpack (0.1.1)
79
+ pry (0.11.0.pre2)
80
+ coderay (~> 1.1.0)
81
+ method_source (~> 0.8.1)
82
+ public_suffix (2.0.5)
83
+ rainbow (2.2.2)
84
+ rake
85
+ rake (10.5.0)
86
+ rb-fsevent (0.9.8)
87
+ rb-inotify (0.9.8)
88
+ ffi (>= 0.5.0)
89
+ rspec (3.5.0)
90
+ rspec-core (~> 3.5.0)
91
+ rspec-expectations (~> 3.5.0)
92
+ rspec-mocks (~> 3.5.0)
93
+ rspec-core (3.5.4)
94
+ rspec-support (~> 3.5.0)
95
+ rspec-expectations (3.5.0)
96
+ diff-lcs (>= 1.2.0, < 2.0)
97
+ rspec-support (~> 3.5.0)
98
+ rspec-mocks (3.5.0)
99
+ diff-lcs (>= 1.2.0, < 2.0)
100
+ rspec-support (~> 3.5.0)
101
+ rspec-support (3.5.0)
102
+ rubocop (0.48.1)
103
+ parser (>= 2.3.3.1, < 3.0)
104
+ powerpack (~> 0.1)
105
+ rainbow (>= 1.99.1, < 3.0)
106
+ ruby-progressbar (~> 1.7)
107
+ unicode-display_width (~> 1.0, >= 1.0.1)
108
+ ruby-progressbar (1.8.1)
109
+ ruby_dep (1.5.0)
110
+ sawyer (0.8.1)
111
+ addressable (>= 2.3.5, < 2.6)
112
+ faraday (~> 0.8, < 1.0)
113
+ shellany (0.0.1)
114
+ terminal-table (1.7.3)
115
+ unicode-display_width (~> 1.1.1)
116
+ thor (0.19.4)
117
+ unicode-display_width (1.1.3)
118
+ yard (0.9.9)
119
+
120
+ PLATFORMS
121
+ ruby
122
+
123
+ DEPENDENCIES
124
+ bundler (~> 1.3)
125
+ danger-samsao!
126
+ guard (~> 2.14)
127
+ guard-rspec (~> 4.7)
128
+ guard-rubocop (~> 1.2)
129
+ pry (~> 0.11.0.pre2)
130
+ rake (~> 10.0)
131
+ rspec (~> 3.4)
132
+ rubocop (~> 0.41)
133
+ yard (~> 0.8)
134
+
135
+ BUNDLED WITH
136
+ 1.14.4
@@ -0,0 +1,21 @@
1
+
2
+ guard :rspec, cmd: 'bundle exec rspec' do
3
+ require 'guard/rspec/dsl'
4
+
5
+ dsl = Guard::RSpec::Dsl.new(self)
6
+
7
+ # RSpec files
8
+ rspec = dsl.rspec
9
+ watch(rspec.spec_helper) { rspec.spec_dir }
10
+ watch(rspec.spec_support) { rspec.spec_dir }
11
+ watch(rspec.spec_files)
12
+
13
+ # Ruby files
14
+ ruby = dsl.ruby
15
+ dsl.watch_spec_files_for(ruby.lib_files)
16
+ end
17
+
18
+ guard :rubocop do
19
+ watch(/.+\.rb$/)
20
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |match| File.dirname(match[0]) }
21
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2017 Samsao Development Inc. <mvachon@samsao.co>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,230 @@
1
+ # Danger Samsao
2
+
3
+ A Danger plugin bringing Samsao's PR guideline into code.
4
+
5
+ ## Installation
6
+
7
+ Simply add `danger-samsao` to your `Gemfile` and configure your `Dangerfile`
8
+ using all the nice goodies.
9
+
10
+ ## Usage
11
+
12
+ Methods and attributes from this plugin are available in
13
+ your `Dangerfile` under the `samsao` namespace.
14
+
15
+ ### Table of Contents
16
+
17
+ * [Config](#config)
18
+ * [Actions](#actions)
19
+ * [samsao.fail_when_changelog_update_missing](#changelog-update-missing)
20
+ * [samsao.fail_when_merge_commit_detected](#merge-commits-detected)
21
+ * [samsao.fail_when_non_single_commit_feature](#feature-branch-multiple-commits)
22
+ * [samsao.fail_when_wrong_branching_model](#branching-model)
23
+ * [samsao.warn_when_work_in_progess_pr](#when-work-in-progess-pr)
24
+ * [Helpers](#helpers)
25
+ * [samsao.changelog_modified?](#changelog-modified-)
26
+ * [samsao.feature_branch?](#feature-branch-)
27
+ * [samsao.fix_branch?](#fix-branch-)
28
+ * [samsao.has_app_changes?](#has-app-changes-)
29
+ * [samsao.release_branch?](#release-branch-)
30
+ * [samsao.trivial_branch?](#trivial-branch-)
31
+ * [samsao.trivial_change?](#trivial-change-)
32
+
33
+ ### Config
34
+
35
+ Some of the actions of this plugin can be configured by project to make stuff
36
+ easier. This is done by using the `config` attributes the plugin:
37
+
38
+ ```
39
+ samsao.config do
40
+ changelogs 'CHANGELOG.yml'
41
+ sources 'app/src'
42
+ end
43
+ ```
44
+
45
+ #### Changelogs
46
+
47
+ Default: `CHANGELOG.md`
48
+
49
+ Enable to change the CHANGELOG file paths looked upon when checking if
50
+ CHANGELOG file has been modified or not.
51
+
52
+ #### Sources
53
+
54
+ Default: `<Empty>`
55
+
56
+ Enable to change which paths are considered has being source files of the
57
+ project. Multiple entries can be passed. Accepts multiple entries to be passed:
58
+
59
+ ```
60
+ samsao.config do
61
+ sources 'common/src', 'web/src'
62
+ end
63
+ ```
64
+
65
+ Each source entry can be a `Regexp`
66
+
67
+ ```
68
+ sources /^(common|mobile|web|/src)/
69
+ ```
70
+
71
+ Or a pure `String`. When a pure string, matches start of git modified files list:
72
+
73
+ ```
74
+ sources 'common/src'
75
+ ```
76
+
77
+ Would match `common/src/a/b.txt` but not `other/common/src/a/b.txt`.
78
+
79
+ ### Actions
80
+
81
+ Here all the actions you can call in your own `Dangerfile` and how to
82
+ configure them.
83
+
84
+ #### Branching Model
85
+
86
+ ```
87
+ samsao.fail_when_wrong_branching_model
88
+ ```
89
+
90
+ Going to make the PR fails when the branch does not respect the git branching
91
+ model.
92
+
93
+ #### CHANGELOG Update Missing
94
+
95
+ ```
96
+ samsao.fail_when_changelog_update_missing
97
+ ```
98
+
99
+ Going to make the PR fails when it's a feature branch (starts with `feature/`)
100
+ or fix branch (`fix/`) and the CHANGELOG file was not updated.
101
+
102
+ #### Feature Branch Multiple Commits
103
+
104
+ ```
105
+ samsao.fail_when_non_single_commit_feature
106
+ ```
107
+
108
+ Going to make the PR fails when it's a feature branch (starts with `feature/`)
109
+ and the PR contains more than one commit.
110
+
111
+ #### Merge Commit(s) Detected
112
+
113
+ ```
114
+ samsao.fail_when_merge_commit_detected
115
+ ```
116
+
117
+ Going to make the PR fails when one or multipl merge commits are detcted.
118
+ A merge commit is one created when merging two branches and matching the
119
+ regexp `^Merge branch '<base branch>'` where `<base branch>` is the branch
120
+ the PR is being merged into (usually `develop`).
121
+
122
+ Use a Git `rebase` to get rid of those commits and correctly sync up with
123
+ `develop` branch.
124
+
125
+ #### Work in Progress PR
126
+
127
+ ```
128
+ samsao.warn_when_work_in_progess_pr
129
+ ```
130
+
131
+ Going to mark PR as in warning state when PR title contains the `[WIP]` marker
132
+
133
+ ### Helpers
134
+
135
+ #### Changelog Modified?
136
+
137
+ ```
138
+ samsao.changelog_modified?
139
+ ```
140
+
141
+ When no arguments are given, returns true if any configured [changelogs](#changelogs) has
142
+ been modified in this commit.
143
+
144
+ When one or more arguments is given, returns true if any given changelog entry file has been
145
+ modified in this commit.
146
+
147
+ #### Has App Changes?
148
+
149
+ ```
150
+ samsao.has_app_changes?
151
+ ```
152
+
153
+ When no arguments are given, returns true if any configured [source files](#sources) has
154
+ been modified in this commit.
155
+
156
+ When one or more arguments is given, uses same rules as for [source files](#sources) (see
157
+ section for details) and returns true if any given source entry files has been modified in this
158
+ commit.
159
+
160
+ #### Feature Branch?
161
+
162
+ ```
163
+ samsao.feature_branch?
164
+ ```
165
+
166
+ Returns true if the PR branch starts with `feature/`.
167
+
168
+ #### Fix Branch?
169
+
170
+ ```
171
+ samsao.fix_branch?
172
+ ```
173
+
174
+ Returns true if the PR branch starts with `fix/`.
175
+
176
+ #### Release Branch?
177
+
178
+ ```
179
+ samsao.release_branch?
180
+ ```
181
+
182
+ Returns true if the PR branch starts with `release/`.
183
+
184
+ #### Trivial Branch?
185
+
186
+ ```
187
+ samsao.trivial_branch?
188
+ ```
189
+
190
+ Returns true if the PR branch starts with `trivial/`.
191
+
192
+ #### Trivial Change?
193
+
194
+ ```
195
+ samsao.trivial_change?
196
+ ```
197
+
198
+ Returns true if the PR title contains `#trivial` or `#typo` or the branch is a
199
+ trivial branch ([trivial_branch?](#trivial-branch-) helper).
200
+
201
+ ## Development
202
+
203
+ You must have `Ruby` and `Bundler` installed to develop this project as well
204
+ as a GitHub token (see [Testing](#tests) section below).
205
+
206
+ 1. Clone this repository.
207
+ 2. Run `bundle install` to setup dependencies.
208
+ 3. Run `bundle exec rake` to run the linters and the tests (See notes below about [testing](#tests)).
209
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
210
+ 5. Make your changes.
211
+ 6. Send PR.
212
+
213
+ ### Tests
214
+
215
+ Prior running test, you need to setup a GitHub API token. Connect to GitHub
216
+ and then go to your profile's settings page. There, go to
217
+ `Developer Settings > Personal access tokens` and click the `Generate new token`
218
+ button. Enter a `Description` for the token something like `Danger Testing` and
219
+ then check the `repo` box (`Full control of private repositories`) then click
220
+ `Generate` at the bottom of the page.
221
+
222
+ Once you have the token, make it available as an environment variable named
223
+ `DANGER_GITHUB_API_TOKEN`. Preferred way is to use a `.env` file at the root
224
+ of this project. Simply do `cp .env.example .env` and edit the copied `.env`
225
+ and enter the token to the side of `DANGER_GITHUB_API_TOKEN` line.
226
+
227
+ ### Publish
228
+
229
+ The release process is quite simple. It consists of doing a release commit,
230
+ run a rake task and finally doing a bump to next version commit and push it.