danger-samsao 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17a57df336d68834fbc0789edfd27de8f66ad1b6
4
- data.tar.gz: a1465dc66e0437c9659bbe61d4baae682133dc3a
3
+ metadata.gz: 03220a151b794360af987c44251ffd233e149fa6
4
+ data.tar.gz: '081d457757e6ca7108968cbdf1c35656222e4b7e'
5
5
  SHA512:
6
- metadata.gz: 942d127d15303f2a7fcf8fb1df32ba074e5c401e5e23b732646c3b12ca5130ac2ed6fa6a2d3d602614201935a1755186570b467cf17d37813e05b483298606c2
7
- data.tar.gz: 7f7b39dc19d1a8fbc998e2afc17191043b16947a61a61636576159b400a78f2a33635d89a1c95856959ae3547b46fe47917bb9851c50afb77a3d9b1cddf6e8dd
6
+ metadata.gz: 7cce010f0f2cc393b5be15c1e509988724903093eb85fd4128a2c4a53bb566c654dd19e056bb7c309b9c20bb628873c76f13db3a826f5ac9f580253f43996d1c
7
+ data.tar.gz: 931219f4890eaf3d817b1a29437987ed974c06dd3dcd6075ef8d10bc86a13b3d4c2d793a03e684f62b1b7591f5e74ff20a89926d60a055884664f4612ebe0d26
data/.travis/danger.sh ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/sh -e
2
+
3
+ if [ "$TRAVIS_PULL_REQUEST" != "false" ]
4
+ then
5
+ echo 'Danger ...'
6
+ bundle exec danger
7
+ fi
data/.travis.yml CHANGED
@@ -1,12 +1,21 @@
1
1
  language: ruby
2
- cache:
3
- directories:
4
- - bundle
2
+ cache: bundler
5
3
 
6
4
  rvm:
7
- - 2.0
8
- - 2.1.3
9
- - 2.3.1
5
+ - 2.2.7
6
+ - 2.3.4
7
+ - 2.4.1
10
8
 
11
9
  script:
12
- - bundle exec rake spec
10
+ - .travis/danger.sh
11
+
12
+ - echo 'Linting...'
13
+ - bundle exec rake lint
14
+
15
+ - echo 'Test...'
16
+ - bundle exec rake tests
17
+
18
+ branches:
19
+ only:
20
+ - master
21
+ - develop
data/CHANGELOG.md CHANGED
@@ -1,3 +1,55 @@
1
+ ## 0.3.0 (August 23, 2017)
2
+
3
+ ### Breaking Changes
4
+
5
+ * Renamed the following methods to match the `level` parameter they now optionally receive:
6
+ * `fail_when_wrong_branching_model` to `check_wrong_branching_model`
7
+ * `fail_when_non_single_commit_feature` to `check_non_single_commit_feature`
8
+ * `fail_when_changelog_update_missing` to `check_changelog_update_missing`
9
+ * `fail_when_merge_commit_detected` to `check_merge_commit_detected`
10
+ * `warn_when_work_in_progess_pr` to `check_work_in_progess_pr`
11
+
12
+ #### Features
13
+
14
+ * Added `level` parameter to all actions to personnalize the report level
15
+ (`:fail`, `:warn`, `:message`) if the check fails.
16
+
17
+ * Added `have_message` and `have_no_message` matchers.
18
+
19
+ * Added `check_label_pr` action.
20
+
21
+ * Added `check_acceptance_criteria` action.
22
+
23
+ * Added `check_feature_jira_issue_number` action.
24
+
25
+ * Added `check_fix_jira_issue_number` action.
26
+
27
+ * Added `contains_jira_issue_number?` helper.
28
+
29
+ * Added `jira_project_key?` helper.
30
+
31
+ * Added `shorten_sha` helper.
32
+
33
+ * Added `truncate` helper.
34
+
35
+ *
36
+
37
+ *
38
+
39
+ *
40
+
41
+ *
42
+
43
+ *
44
+
45
+ #### Support
46
+
47
+ * Fixed grammatical errors in the `README.md`.
48
+
49
+ #### Support
50
+
51
+ * Open source repository and now using Travis as the build system.
52
+
1
53
  ## 0.2.0 (May 9, 2017)
2
54
 
3
55
  #### Breaking Changes
data/Dangerfile CHANGED
@@ -7,13 +7,13 @@ samsao.config do
7
7
  end
8
8
 
9
9
  ## Errors
10
- samsao.fail_when_changelog_update_missing
11
- samsao.fail_when_merge_commit_detected
12
- samsao.fail_when_non_single_commit_feature
13
- samsao.fail_when_wrong_branching_model
10
+ samsao.check_changelog_update_missing
11
+ samsao.check_merge_commit_detected
12
+ samsao.check_non_single_commit_feature
13
+ samsao.check_wrong_branching_model
14
14
 
15
15
  ## Warnings
16
- samsao.warn_when_work_in_progess_pr
16
+ samsao.check_work_in_progess_pr
17
17
 
18
18
  ## Messages
19
19
  unless status_report[:errors].empty?
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-samsao (0.2.0)
4
+ danger-samsao (0.3.0)
5
5
  danger-plugin-api (~> 1.0)
6
6
 
7
7
  GEM
@@ -134,4 +134,4 @@ DEPENDENCIES
134
134
  yard (~> 0.8)
135
135
 
136
136
  BUNDLED WITH
137
- 1.14.4
137
+ 1.14.6
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Danger Samsao
1
+ # Danger Samsao [![Build Status](https://travis-ci.org/samsao/danger-samsao.svg?branch=develop)](https://travis-ci.org/samsao/danger-samsao)
2
2
 
3
3
  A Danger plugin bringing Samsao's PR guideline into code.
4
4
 
@@ -18,13 +18,13 @@ samsao.config do
18
18
  end
19
19
 
20
20
  ## Errors
21
- samsao.fail_when_changelog_update_missing
22
- samsao.fail_when_merge_commit_detected
23
- samsao.fail_when_non_single_commit_feature
24
- samsao.fail_when_wrong_branching_model
21
+ samsao.check_changelog_update_missing
22
+ samsao.check_merge_commit_detected
23
+ samsao.check_non_single_commit_feature
24
+ samsao.check_wrong_branching_model
25
25
 
26
26
  ## Warnings
27
- samsao.warn_when_work_in_progess_pr
27
+ samsao.check_work_in_progess_pr
28
28
 
29
29
  ## Messages
30
30
  unless status_report[:errors].empty?
@@ -41,20 +41,34 @@ your `Dangerfile` under the `samsao` namespace.
41
41
  ### Table of Contents
42
42
 
43
43
  * [Config](#config)
44
+ * [Changelogs](#changelogs)
45
+ * [Jira Project Key](#jira-project-key)
46
+ * [Project Type](#project-type)
47
+ * [Sources](#sources)
44
48
  * [Actions](#actions)
45
- * [samsao.fail_when_changelog_update_missing](#changelog-update-missing)
46
- * [samsao.fail_when_merge_commit_detected](#merge-commits-detected)
47
- * [samsao.fail_when_non_single_commit_feature](#feature-branch-multiple-commits)
48
- * [samsao.fail_when_wrong_branching_model](#branching-model)
49
- * [samsao.warn_when_work_in_progess_pr](#when-work-in-progess-pr)
49
+ * [Report Levels](#report-levels)
50
+ * [samsao.check_acceptance_criteria](#acceptance-criteria)
51
+ * [samsao.check_changelog_update_missing](#changelog-update-missing)
52
+ * [samsao.check_feature_jira_issue_number](#feature-jira-issue-number)
53
+ * [samsao.check_fix_jira_issue_number](#fix-jira-issue-number)
54
+ * [samsao.check_label_pr](#label_pr)
55
+ * [samsao.check_merge_commit_detected](#merge-commits-detected)
56
+ * [samsao.check_non_single_commit_feature](#feature-branch-multiple-commits)
57
+ * [samsao.check_wrong_branching_model](#branching-model)
58
+ * [samsao.check_work_in_progess_pr](#when-work-in-progess-pr)
50
59
  * [Helpers](#helpers)
51
60
  * [samsao.changelog_modified?](#changelog-modified)
61
+ * [samsao.contains_any_jira_issue_number?](#contains-any-jira-issue-number)
62
+ * [samsao.contains_single_jira_issue_number?](#contains-single-jira-issue-number)
52
63
  * [samsao.feature_branch?](#feature-branch)
53
64
  * [samsao.fix_branch?](#fix-branch)
54
65
  * [samsao.has_app_changes?](#has-app-changes)
66
+ * [samsao.jira_project_key?](#has-jira-project-key)
55
67
  * [samsao.release_branch?](#release-branch)
68
+ * [samsao.shorten_sha](#shorten-sha)
56
69
  * [samsao.support_branch?](#support-branch)
57
70
  * [samsao.trivial_change?](#trivial-change)
71
+ * [samsao.truncate](#truncate)
58
72
 
59
73
  ### Config
60
74
 
@@ -63,7 +77,8 @@ easier. This is done by using the `config` attributes the plugin:
63
77
 
64
78
  ```
65
79
  samsao.config do
66
- changelogs 'CHANGELOG.yml'
80
+ changelogs 'CHANGELOG.md'
81
+ jira_project_key 'VER'
67
82
  project_type :library
68
83
  sources 'app/src'
69
84
  end
@@ -73,17 +88,30 @@ end
73
88
 
74
89
  Defaults: `[CHANGELOG.md]`
75
90
 
76
- Enable to change the CHANGELOG file paths looked upon when checking if
77
- CHANGELOG file has been modified or not.
91
+ Enable to change the CHANGELOG file paths looked upon when checking if CHANGELOG
92
+ file has been modified or not.
93
+
94
+ #### Jira Project Key
95
+
96
+ Defaults: nil
97
+
98
+ Example: `VER`
99
+
100
+ This refers to the project key on Jira. This settings affects these actions and helpers:
101
+
102
+ * [samsao.check_feature_jira_issue_number](#feature-jira-issue-number)
103
+ * [samsao.check_fix_jira_issue_number](#fix-jira-issue-number)
104
+
105
+ See the exact actions or helpers for precise details about implications.
78
106
 
79
107
  #### Project Type
80
108
 
81
109
  Defaults: `:application`
82
110
 
83
- Change the kind of project your are currently developing. This settings
84
- affects these actions and helpers:
111
+ Change the kind of project you are currently developing. This settings affects
112
+ these actions and helpers:
85
113
 
86
- * [samsao.fail_when_changelog_update_missing](#changelog-update-missing)
114
+ * [samsao.check_when_changelog_update_missing](#changelog-update-missing)
87
115
 
88
116
  See the exact actions or helpers for precise details about implications.
89
117
 
@@ -91,8 +119,8 @@ See the exact actions or helpers for precise details about implications.
91
119
 
92
120
  Default: `[]`
93
121
 
94
- Enable to change which paths are considered has being source files of the
95
- project. Multiple entries can be passed. Accepts multiple entries to be passed:
122
+ Enable to change which paths are considered as being source files of the project.
123
+ Multiple entries can be passed. Accepts multiple entries to be passed:
96
124
 
97
125
  ```
98
126
  samsao.config do
@@ -106,7 +134,7 @@ Each source entry can be a `Regexp`
106
134
  sources /^(common|mobile|web|/src)/
107
135
  ```
108
136
 
109
- Or a pure `String`. When a pure string, matches start of git modified files list:
137
+ Or a pure `String`. When a pure string, matches the start of git modified files list:
110
138
 
111
139
  ```
112
140
  sources 'common/src'
@@ -116,18 +144,51 @@ Would match `common/src/a/b.txt` but not `other/common/src/a/b.txt`.
116
144
 
117
145
  ### Actions
118
146
 
119
- Here all the actions you can call in your own `Dangerfile` and how to
120
- configure them.
147
+ Here all the actions you can call in your own `Dangerfile` and how to configure them.
148
+
149
+ #### Report Levels
150
+
151
+ Each action as a `level` parameter that can be set to fail, warn or simply write
152
+ a message if the check fails. Each action also has a default value for the check.
153
+
154
+ The possible values for `level` are the following:
155
+ * `:fail`
156
+ * `:warn`
157
+ * `:message`
158
+
159
+ For example since `check_wrong_branching_model` has the default value of `:fail`.
160
+ If you don't want this check to reject your PR, you can overwrite it by writing :
161
+
162
+ ```
163
+ samsao.check_wrong_branching_model :warn
164
+ ```
165
+
166
+ Note that only a `:fail` will reject the PR.
167
+
168
+ #### Acceptance Criteria
169
+
170
+ ```
171
+ samsao.check_acceptance_criteria(level = :warn)
172
+ ```
173
+
174
+ Parameters:
175
+ * `level` | The [report level](#report-levels) to use when the check does not pass.
176
+
177
+ Check if it's a feature branch (starts with `feature/`) and if the PR body contains
178
+ the string `acceptance criteria`.
121
179
 
122
180
  #### Branching Model
123
181
 
124
182
  ```
125
- samsao.fail_when_wrong_branching_model
183
+ samsao.check_wrong_branching_model(level = :fail)
126
184
  ```
127
185
 
128
- Going to make the PR fails when the branch does not respect the git branching
129
- model. We follow git flow branching model and failure will occurs if the branch
130
- name does not start with one of the following prefixes:
186
+ Parameters:
187
+ * `level` | The [report level](#report-levels) to use when the check does not pass.
188
+
189
+ Check if the branch does not respect the git branching model. We follow git flow
190
+ branching model and if the branch name does not start with one of the following
191
+ prefixes:
131
192
 
132
193
  * `fix/`
133
194
  * `bugfix/`
@@ -139,47 +200,96 @@ name does not start with one of the following prefixes:
139
200
  #### CHANGELOG Update Missing
140
201
 
141
202
  ```
142
- samsao.fail_when_changelog_update_missing
203
+ samsao.check_changelog_update_missing(level = :fail)
204
+ ```
205
+
206
+ Parameters:
207
+ * `level` | The [report level](#report-levels) to use when the check does not pass.
208
+
209
+ Check if when a PR is made that is not flagged as a [trivial change](#trivial-change)
210
+ and the changelog (based on `changelogs` config options) has not been modified.
211
+
212
+ When the project is of type `:application`, a change made to a [support branch]
213
+ (#support-branch) will pass even if the changelog is not updated.
214
+
215
+ #### Label PR
216
+
217
+ ```
218
+ samsao.check_label_pr(level = :fail)
143
219
  ```
144
220
 
145
- This action reports a failure when a PR is made that is not flagged
146
- as a [trivial change](#trivial-change) and the changelog (based on
147
- `changelogs` config options) has not been modified.
221
+ Parameters:
222
+ * `level` | The [report level](#report-levels) to use when the check does not pass.
148
223
 
149
- When the project is of type `:application`, a change made to a [support
150
- branch](#support-branch) will not trigger a failure even if the changelog
151
- is not updated.
224
+ Check if the PR has at least one label added to it.
152
225
 
153
226
  #### Feature Branch Multiple Commits
154
227
 
155
228
  ```
156
- samsao.fail_when_non_single_commit_feature
229
+ samsao.check_non_single_commit_feature(level = :fail)
157
230
  ```
158
231
 
159
- Going to make the PR fails when it's a feature branch (starts with `feature/`)
160
- and the PR contains more than one commit.
232
+ Parameters:
233
+ * `level` | The [report level](#report-levels) to use when the check does not pass.
234
+
235
+ Check if it's a feature branch (starts with `feature/`) and the PR contains more
236
+ than one commit.
237
+
238
+ #### Feature Jira Issue Number
239
+
240
+ ```
241
+ samsao.check_feature_jira_issue_number(level = :fail)
242
+ ```
243
+
244
+ Parameters:
245
+ * `level` | The [report level](#report-levels) to use when the check does not pass.
246
+
247
+ Check if it's a feature branch (starts with `feature/`) and the PR title contains the
248
+ issue number using your configuration's [jira project key](#jira-project-key).
249
+
250
+ Example : `[VER-123] Adding new screen.`
251
+
252
+ #### Fix Jira Issue Number
253
+
254
+ ```
255
+ samsao.check_fix_jira_issue_number(level = :warn)
256
+ ```
257
+
258
+ Parameters:
259
+ * `level` | The [report level](#report-levels) to use when the check does not pass.
260
+
261
+ Check if it's a feature branch (starts with `fix/`, `bugfix/` or `hotfix/`.) and if every
262
+ commit message contains any issue number using your configuration's [jira project key](#jira-project-key).
263
+
264
+ Example : `[VER-123, VER-124, VER-125] Bug fixes.`
161
265
 
162
266
  #### Merge Commit(s) Detected
163
267
 
164
268
  ```
165
- samsao.fail_when_merge_commit_detected
269
+ samsao.check_merge_commit_detected(level = :fail)
166
270
  ```
167
271
 
168
- Going to make the PR fails when one or multipl merge commits are detcted.
272
+ Parameters:
273
+ * `level` | The [report level](#report-levels) to use when the check does not pass.
274
+
275
+ Check if one or multiple merge commits are detected.
276
+
169
277
  A merge commit is one created when merging two branches and matching the
170
278
  regexp `^Merge branch '<base branch>'` where `<base branch>` is the branch
171
279
  the PR is being merged into (usually `develop`).
172
280
 
173
- Use a Git `rebase` to get rid of those commits and correctly sync up with
174
- `develop` branch.
281
+ Use a Git `rebase` to get rid of those commits and correctly sync up with `develop` branch.
175
282
 
176
283
  #### Work in Progress PR
177
284
 
178
285
  ```
179
- samsao.warn_when_work_in_progess_pr
286
+ samsao.check_work_in_progess_pr(level = :warn)
180
287
  ```
181
288
 
182
- Going to mark PR as in warning state when PR title contains the `[WIP]` marker
289
+ Parameters:
290
+ * `level` | The [report level](#report-levels) to use when the check does not pass.
291
+
292
+ Check if the PR title contains the `[WIP]` marker
183
293
 
184
294
  ### Helpers
185
295
 
@@ -189,24 +299,22 @@ Going to mark PR as in warning state when PR title contains the `[WIP]` marker
189
299
  samsao.changelog_modified?
190
300
  ```
191
301
 
192
- When no arguments are given, returns true if any configured [changelogs](#changelogs) has
193
- been modified in this commit.
302
+ When no arguments are given, returns true if any configured [changelogs](#changelogs)
303
+ has been modified in this commit.
194
304
 
195
- When one or more arguments is given, returns true if any given changelog entry file has been
196
- modified in this commit.
305
+ When one or more arguments are given, returns true if any given changelog entry
306
+ file has been modified in this commit.
197
307
 
198
- #### Has App Changes?
308
+ #### Contains Jira Issue Number?
199
309
 
200
310
  ```
201
- samsao.has_app_changes?
311
+ samsao.contains_jira_issue_number?(input)
202
312
  ```
203
313
 
204
- When no arguments are given, returns true if any configured [source files](#sources) has
205
- been modified in this commit.
314
+ Return true if input contains the issue number using your configuration's
315
+ [jira project key](#jira-project-key). The input could be a PR title or a commit message.
206
316
 
207
- When one or more arguments is given, uses same rules as for [source files](#sources) (see
208
- section for details) and returns true if any given source entry files has been modified in this
209
- commit.
317
+ Example : `[VER-123] Adding new screen.` or `[VER-123, VER-124, VER-125] Bug fixes.`
210
318
 
211
319
  #### Feature Branch?
212
320
 
@@ -224,6 +332,27 @@ samsao.fix_branch?
224
332
 
225
333
  Returns true if the PR branch starts with `fix/`, `bugfix/` or `hotfix/`.
226
334
 
335
+ #### Has App Changes?
336
+
337
+ ```
338
+ samsao.has_app_changes?
339
+ ```
340
+
341
+ When no arguments are given, returns true if any configured [source files](#sources)
342
+ has been modified in this commit.
343
+
344
+ When one or more arguments are given, uses same rules as for [source files](#sources)
345
+ (see section for details) and returns true if any given source entry files have
346
+ been modified in this commit.
347
+
348
+ #### Has Jira Project Key?
349
+
350
+ ```
351
+ samsao.jira_project_key?
352
+ ```
353
+
354
+ Return true if the config has a [jira project key](#jira-project-key).
355
+
227
356
  #### Release Branch?
228
357
 
229
358
  ```
@@ -232,6 +361,17 @@ samsao.release_branch?
232
361
 
233
362
  Returns true if the PR branch starts with `release/`.
234
363
 
364
+ #### Shorten Sha
365
+
366
+ ```
367
+ samsao.shorten_sha(sha)
368
+ ```
369
+
370
+ Parameters:
371
+ * `sha` | The sha to shorten.
372
+
373
+ Shorten the git sha to 8 characters mostly for readability.
374
+
235
375
  #### Support Branch?
236
376
 
237
377
  ```
@@ -248,6 +388,19 @@ samsao.trivial_change?
248
388
 
249
389
  Returns true if the PR title contains `#trivial`, `#typo` or `#typos`.
250
390
 
391
+ #### Truncate
392
+
393
+ ```
394
+ samsao.truncate(input, max = 30)
395
+ ```
396
+
397
+ Parameters:
398
+ * `input` | The input to truncate.
399
+ * `max` | The max length of the truncated input.
400
+
401
+ Truncate the input received to the max size passed as a parameter. the default value for
402
+ the max is 30 characters.
403
+
251
404
  ## Development
252
405
 
253
406
  You must have `Ruby` and `Bundler` installed to develop this project as well
@@ -310,7 +463,7 @@ on the current commit of the current branch (should be the release commit
310
463
  made earlier) named `v0.1.0`. And it will finally push the branch & tag to the
311
464
  repository as well as building and publishing the gem on RubyGems.
312
465
 
313
- Last thing to do is bumping to next development version. Edit back
466
+ The last thing to do is bumping to next development version. Edit back
314
467
  `CHANGELOG.md` so that `## In progress` is the new section header and
315
468
  add a bunch of empty lines (around 10, only 2 shown in the example for
316
469
  brevity) into single `Features` section (add other sections when updating
@@ -333,7 +486,7 @@ Also edit `lib/samsao/gem_version.rb` so that next development version
333
486
  value is used `VERSION = '0.1.1.pre1'.freeze`. The `.pre1` is the lowest
334
487
  possible version before the official `0.1.1` one (or higher).
335
488
 
336
- Commit all this changes together in a new commit that has the following
489
+ Commit all these changes together in a new commit that has the following
337
490
  message:
338
491
 
339
492
  ```
@@ -341,5 +494,5 @@ Bumped to next development version
341
494
  ```
342
495
 
343
496
  Finally, create a PR with this branch and open a pull request and merge
344
- right away (your team mates should known in advance that a release is
497
+ right away (your teammates should know in advance that a release is
345
498
  happening and branch merged faster than other ones).
data/Rakefile CHANGED
@@ -11,7 +11,9 @@ task :check => [:lint, :tests]
11
11
  task :lint => [:lint_ruby, :lint_danger]
12
12
 
13
13
  desc 'Run RuboCop on the lib/specs directory'
14
- RuboCop::RakeTask.new(:lint_ruby)
14
+ RuboCop::RakeTask.new(:lint_ruby) do |task|
15
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb', '*.gemspec', 'Dangerfile', 'Gemfile', 'Guardfile', 'Rakefile']
16
+ end
15
17
 
16
18
  desc 'Ensure that the plugin passes `danger plugins lint`'
17
19
  task :lint_danger do