danger-gfsm_commit_trailer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2f0c69c56676b939c663d113a28573180cbf8bd2bf1c25fa4272c0db72162cd1
4
+ data.tar.gz: b85b2980a3f916d9d9ac06cb44c55b3edb71b52ce9ed39efe9d90d91e2ec87d0
5
+ SHA512:
6
+ metadata.gz: eb2b2890116eb322def78f1408a0c42dad1d47702257397da58c6a17c61092ae0ea77a974557c030d4687f619af564370dc77f6c36d898016978fb8c9d9811df
7
+ data.tar.gz: 2a756da145a39f8fb27e37847087ae79fffc63c7ce1ef7664fa4f9285226f8fccd7d17de74331748bfe771437139c0a9c3bd64cde909ff2c6afa7197fd4b3370
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ .yardoc
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,106 @@
1
+ stages:
2
+ - version
3
+ - test
4
+ - deploy
5
+ - release
6
+
7
+ workflow:
8
+ rules:
9
+ # For merge requests, create a pipeline.
10
+ - if: '$CI_MERGE_REQUEST_IID'
11
+ # For default branch, create a pipeline.
12
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
13
+ # For tags, never create pipeline.
14
+ - if: '$CI_COMMIT_TAG'
15
+ when: never
16
+
17
+ Update version:
18
+ stage: version
19
+ image: ruby:2.7.5
20
+ before_script:
21
+ - gem install gfsm
22
+ script:
23
+ - gfsm version bump --force > .version
24
+ - gfsm changelog --force --output-file CHANGELOG.md
25
+ - echo "RELEASE_VERSION=$(<.version)" >> variables.env
26
+ artifacts:
27
+ reports:
28
+ dotenv: variables.env
29
+ paths:
30
+ - .version
31
+ - CHANGELOG.md
32
+
33
+ RSpec:
34
+ stage: test
35
+ image: ruby:2.7.5
36
+ before_script:
37
+ - bundle install
38
+ script:
39
+ - bundle exec rspec
40
+ needs:
41
+ - job: "Update version"
42
+ artifacts: true
43
+
44
+ rubocop:
45
+ stage: test
46
+ image: ruby:2.7.5
47
+ before_script:
48
+ - bundle install
49
+ script:
50
+ - bundle exec rubocop
51
+ needs:
52
+ - job: "Update version"
53
+ artifacts: true
54
+
55
+ # Publish gem:
56
+ # - GEM_HOST_API_KEY: A valid RubyGems API key.
57
+ Publish gem:
58
+ stage: deploy
59
+ image: ruby:2.7.5
60
+ needs:
61
+ - job: "Update version"
62
+ artifacts: true
63
+ - job: "RSpec"
64
+ artifacts: false
65
+ - job: "rubocop"
66
+ artifacts: false
67
+ variables:
68
+ GEMSPEC_FILE: "danger-gfsm_commit_trailer.gemspec"
69
+ GEM_FILE: "danger-gfsm_commit_trailer-${RELEASE_VERSION}.gem"
70
+ before_script:
71
+ - |
72
+ rm -f ./*.gem
73
+ [ -f "${GEMSPEC_FILE}" ] || (echo "No ${GEMSPEC_FILE} file found!" && exit 1)
74
+ script:
75
+ - |
76
+ printf "# frozen_string_literal: true\n\nmodule GfsmCommitTrailer\n VERSION = \"$RELEASE_VERSION\"\nend\n" > lib/gfsm_commit_trailer/gem_version.rb
77
+ gem build "${GEMSPEC_FILE}"
78
+ [ -f "${GEM_FILE}" ] || (echo "No ${GEM_FILE} file found!" && exit 1)
79
+ gem push "${GEM_FILE}"
80
+ artifacts:
81
+ paths:
82
+ - "*.gem"
83
+ rules:
84
+ - if: '$GEM_HOST_API_KEY == null'
85
+ when: never
86
+ - if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
87
+ when: never
88
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
89
+
90
+ Create release:
91
+ stage: release
92
+ image: registry.gitlab.com/gitlab-org/release-cli:latest
93
+ script:
94
+ - |
95
+ release-cli create --name "Release v$RELEASE_VERSION" --description CHANGELOG.md --tag-name "v$RELEASE_VERSION"
96
+ needs:
97
+ - job: "Update version"
98
+ artifacts: true
99
+ - job: "Publish gem"
100
+ artifacts: false
101
+ rules:
102
+ - if: '$GEM_HOST_API_KEY == null'
103
+ when: never
104
+ - if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
105
+ when: never
106
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
data/.rubocop.yml ADDED
@@ -0,0 +1,159 @@
1
+ # Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+
3
+ # If you don't like these settings, just delete this file :)
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.7.5
7
+ NewCops: enable
8
+ SuggestExtensions: false
9
+
10
+ Style/StringLiterals:
11
+ EnforcedStyle: double_quotes
12
+ Enabled: true
13
+
14
+ # kind_of? is a good way to check a type
15
+ Style/ClassCheck:
16
+ EnforcedStyle: kind_of?
17
+
18
+ # specs sometimes have useless assignments, which is fine
19
+ Lint/UselessAssignment:
20
+ Exclude:
21
+ - '**/spec/**/*'
22
+
23
+ # We could potentially enable the 2 below:
24
+ Layout/FirstHashElementIndentation:
25
+ Enabled: false
26
+
27
+ Layout/HashAlignment:
28
+ Enabled: false
29
+
30
+ # HoundCI doesn't like this rule
31
+ Layout/DotPosition:
32
+ Enabled: false
33
+
34
+ # We allow !! as it's an easy way to convert ot boolean
35
+ Style/DoubleNegation:
36
+ Enabled: false
37
+
38
+ # Cop supports --auto-correct.
39
+ Lint/UnusedBlockArgument:
40
+ Enabled: false
41
+
42
+ # We want to allow class Fastlane::Class
43
+ Style/ClassAndModuleChildren:
44
+ Enabled: false
45
+
46
+ Metrics/AbcSize:
47
+ Max: 60
48
+
49
+ # The %w might be confusing for new users
50
+ Style/WordArray:
51
+ MinSize: 19
52
+
53
+ # raise and fail are both okay
54
+ Style/SignalException:
55
+ Enabled: false
56
+
57
+ # Better too much 'return' than one missing
58
+ Style/RedundantReturn:
59
+ Enabled: false
60
+
61
+ # Having if in the same line might not always be good
62
+ Style/IfUnlessModifier:
63
+ Enabled: false
64
+
65
+ # and and or is okay
66
+ Style/AndOr:
67
+ Enabled: false
68
+
69
+ # Configuration parameters: CountComments.
70
+ Metrics/ClassLength:
71
+ Max: 350
72
+
73
+ Metrics/CyclomaticComplexity:
74
+ Max: 17
75
+
76
+ # Configuration parameters: AllowURI, URISchemes.
77
+ Layout/LineLength:
78
+ Max: 370
79
+
80
+ # Configuration parameters: CountKeywordArgs.
81
+ Metrics/ParameterLists:
82
+ Max: 10
83
+
84
+ Metrics/PerceivedComplexity:
85
+ Max: 18
86
+
87
+ # Sometimes it's easier to read without guards
88
+ Style/GuardClause:
89
+ Enabled: false
90
+
91
+ # something = if something_else
92
+ # that's confusing
93
+ Style/ConditionalAssignment:
94
+ Enabled: false
95
+
96
+ # Better to have too much self than missing a self
97
+ Style/RedundantSelf:
98
+ Enabled: false
99
+
100
+ Metrics/MethodLength:
101
+ Max: 60
102
+
103
+ # We're not there yet
104
+ Style/Documentation:
105
+ Enabled: false
106
+
107
+ # Adds complexity
108
+ Style/IfInsideElse:
109
+ Enabled: false
110
+
111
+ # danger specific
112
+
113
+ Style/BlockComments:
114
+ Enabled: false
115
+
116
+ Layout/MultilineMethodCallIndentation:
117
+ EnforcedStyle: indented
118
+
119
+ # FIXME: 25
120
+ Metrics/BlockLength:
121
+ Max: 345
122
+ Exclude:
123
+ - "**/*_spec.rb"
124
+
125
+ Metrics/ModuleLength:
126
+ Enabled: false
127
+
128
+ Style/MixinGrouping:
129
+ Enabled: false
130
+
131
+ Naming/FileName:
132
+ Enabled: false
133
+
134
+ Layout/HeredocIndentation:
135
+ Enabled: false
136
+
137
+ Style/SpecialGlobalVars:
138
+ Enabled: false
139
+
140
+ Style/PercentLiteralDelimiters:
141
+ PreferredDelimiters:
142
+ "%": ()
143
+ "%i": ()
144
+ "%q": ()
145
+ "%Q": ()
146
+ "%r": "{}"
147
+ "%s": ()
148
+ "%w": ()
149
+ "%W": ()
150
+ "%x": ()
151
+
152
+ Security/YAMLLoad:
153
+ Enabled: false
154
+
155
+ Gemspec/RequireMFA:
156
+ Enabled: false
157
+
158
+ Gemspec/DeprecatedAttributeAssignment:
159
+ Enabled: false
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.5
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in danger-gfsm_commit_trailer.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,172 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-gfsm_commit_trailer (0.0.0)
5
+ danger-plugin-api (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.8.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ ast (2.4.2)
13
+ claide (1.1.0)
14
+ claide-plugins (0.9.2)
15
+ cork
16
+ nap
17
+ open4 (~> 1.3)
18
+ coderay (1.1.3)
19
+ colored2 (3.1.2)
20
+ cork (0.3.0)
21
+ colored2 (~> 3.1)
22
+ danger (8.6.1)
23
+ claide (~> 1.0)
24
+ claide-plugins (>= 0.9.2)
25
+ colored2 (~> 3.1)
26
+ cork (~> 0.1)
27
+ faraday (>= 0.9.0, < 2.0)
28
+ faraday-http-cache (~> 2.0)
29
+ git (~> 1.7)
30
+ kramdown (~> 2.3)
31
+ kramdown-parser-gfm (~> 1.0)
32
+ no_proxy_fix
33
+ octokit (~> 4.7)
34
+ terminal-table (>= 1, < 4)
35
+ danger-plugin-api (1.0.0)
36
+ danger (> 2.0)
37
+ diff-lcs (1.5.0)
38
+ faraday (1.10.0)
39
+ faraday-em_http (~> 1.0)
40
+ faraday-em_synchrony (~> 1.0)
41
+ faraday-excon (~> 1.1)
42
+ faraday-httpclient (~> 1.0)
43
+ faraday-multipart (~> 1.0)
44
+ faraday-net_http (~> 1.0)
45
+ faraday-net_http_persistent (~> 1.0)
46
+ faraday-patron (~> 1.0)
47
+ faraday-rack (~> 1.0)
48
+ faraday-retry (~> 1.0)
49
+ ruby2_keywords (>= 0.0.4)
50
+ faraday-em_http (1.0.0)
51
+ faraday-em_synchrony (1.0.0)
52
+ faraday-excon (1.1.0)
53
+ faraday-http-cache (2.4.0)
54
+ faraday (>= 0.8)
55
+ faraday-httpclient (1.0.1)
56
+ faraday-multipart (1.0.4)
57
+ multipart-post (~> 2)
58
+ faraday-net_http (1.0.1)
59
+ faraday-net_http_persistent (1.2.0)
60
+ faraday-patron (1.0.0)
61
+ faraday-rack (1.0.0)
62
+ faraday-retry (1.0.3)
63
+ ffi (1.15.5)
64
+ formatador (1.1.0)
65
+ git (1.11.0)
66
+ rchardet (~> 1.8)
67
+ guard (2.18.0)
68
+ formatador (>= 0.2.4)
69
+ listen (>= 2.7, < 4.0)
70
+ lumberjack (>= 1.0.12, < 2.0)
71
+ nenv (~> 0.1)
72
+ notiffany (~> 0.0)
73
+ pry (>= 0.13.0)
74
+ shellany (~> 0.0)
75
+ thor (>= 0.18.1)
76
+ guard-compat (1.2.1)
77
+ guard-rspec (4.7.3)
78
+ guard (~> 2.1)
79
+ guard-compat (~> 1.1)
80
+ rspec (>= 2.99.0, < 4.0)
81
+ json (2.6.2)
82
+ kramdown (2.4.0)
83
+ rexml
84
+ kramdown-parser-gfm (1.1.0)
85
+ kramdown (~> 2.0)
86
+ listen (3.0.7)
87
+ rb-fsevent (>= 0.9.3)
88
+ rb-inotify (>= 0.9.7)
89
+ lumberjack (1.2.8)
90
+ method_source (1.0.0)
91
+ multipart-post (2.2.3)
92
+ nap (1.1.0)
93
+ nenv (0.3.0)
94
+ no_proxy_fix (0.1.2)
95
+ notiffany (0.1.3)
96
+ nenv (~> 0.1)
97
+ shellany (~> 0.0)
98
+ octokit (4.25.1)
99
+ faraday (>= 1, < 3)
100
+ sawyer (~> 0.9)
101
+ open4 (1.3.4)
102
+ parallel (1.22.1)
103
+ parser (3.1.2.0)
104
+ ast (~> 2.4.1)
105
+ pry (0.14.1)
106
+ coderay (~> 1.1)
107
+ method_source (~> 1.0)
108
+ public_suffix (4.0.7)
109
+ rainbow (3.1.1)
110
+ rake (10.5.0)
111
+ rb-fsevent (0.11.1)
112
+ rb-inotify (0.10.1)
113
+ ffi (~> 1.0)
114
+ rchardet (1.8.0)
115
+ regexp_parser (2.5.0)
116
+ rexml (3.2.5)
117
+ rspec (3.11.0)
118
+ rspec-core (~> 3.11.0)
119
+ rspec-expectations (~> 3.11.0)
120
+ rspec-mocks (~> 3.11.0)
121
+ rspec-core (3.11.0)
122
+ rspec-support (~> 3.11.0)
123
+ rspec-expectations (3.11.0)
124
+ diff-lcs (>= 1.2.0, < 2.0)
125
+ rspec-support (~> 3.11.0)
126
+ rspec-mocks (3.11.1)
127
+ diff-lcs (>= 1.2.0, < 2.0)
128
+ rspec-support (~> 3.11.0)
129
+ rspec-support (3.11.0)
130
+ rubocop (1.32.0)
131
+ json (~> 2.3)
132
+ parallel (~> 1.10)
133
+ parser (>= 3.1.0.0)
134
+ rainbow (>= 2.2.2, < 4.0)
135
+ regexp_parser (>= 1.8, < 3.0)
136
+ rexml (>= 3.2.5, < 4.0)
137
+ rubocop-ast (>= 1.19.1, < 2.0)
138
+ ruby-progressbar (~> 1.7)
139
+ unicode-display_width (>= 1.4.0, < 3.0)
140
+ rubocop-ast (1.19.1)
141
+ parser (>= 3.1.1.0)
142
+ ruby-progressbar (1.11.0)
143
+ ruby2_keywords (0.0.5)
144
+ sawyer (0.9.2)
145
+ addressable (>= 2.3.5)
146
+ faraday (>= 0.17.3, < 3)
147
+ shellany (0.0.1)
148
+ terminal-table (3.0.2)
149
+ unicode-display_width (>= 1.1.1, < 3)
150
+ thor (1.2.1)
151
+ unicode-display_width (2.2.0)
152
+ webrick (1.7.0)
153
+ yard (0.9.28)
154
+ webrick (~> 1.7.0)
155
+
156
+ PLATFORMS
157
+ x86_64-linux
158
+
159
+ DEPENDENCIES
160
+ bundler (~> 2.0)
161
+ danger-gfsm_commit_trailer!
162
+ guard (~> 2.14)
163
+ guard-rspec (~> 4.7)
164
+ listen (= 3.0.7)
165
+ pry
166
+ rake (~> 10.0)
167
+ rspec (~> 3.4)
168
+ rubocop
169
+ yard
170
+
171
+ BUNDLED WITH
172
+ 2.3.18
data/Guardfile ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A guardfile for making Danger Plugins
4
+ # For more info see https://github.com/guard/guard#readme
5
+
6
+ # To run, use `bundle exec guard`.
7
+
8
+ guard :rspec, cmd: "bundle exec rspec" do
9
+ require "guard/rspec/dsl"
10
+ dsl = Guard::RSpec::Dsl.new(self)
11
+
12
+ # RSpec files
13
+ rspec = dsl.rspec
14
+ watch(rspec.spec_helper) { rspec.spec_dir }
15
+ watch(rspec.spec_support) { rspec.spec_dir }
16
+ watch(rspec.spec_files)
17
+
18
+ # Ruby files
19
+ ruby = dsl.ruby
20
+ dsl.watch_spec_files_for(ruby.lib_files)
21
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2022 Marco Zille <marco.zille@gmail.com>
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.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # danger-gfsm_commit_trailer
2
+
3
+ Danger plugin to add on projects using GFSM in order to make sure each MR creates a CHANGELOG entry.
4
+
5
+ ## Installation
6
+
7
+ $ gem install danger-gfsm_commit_trailer
8
+
9
+ ## Usage
10
+
11
+ Methods and attributes from this plugin are available in
12
+ your `Dangerfile` under the `gfsm_commit_trailer` namespace.
13
+
14
+ ## Development
15
+
16
+ 1. Clone this repo
17
+ 2. Run `bundle install` to setup dependencies.
18
+ 3. Run `bundle exec rake spec` to run the tests.
19
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
20
+ 5. Make your changes.
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+
7
+ RSpec::Core::RakeTask.new(:specs)
8
+
9
+ task default: :specs
10
+
11
+ task :spec do
12
+ Rake::Task["specs"].invoke
13
+ Rake::Task["rubocop"].invoke
14
+ Rake::Task["spec_docs"].invoke
15
+ end
16
+
17
+ desc "Run RuboCop on the lib/specs directory"
18
+ RuboCop::RakeTask.new(:rubocop) do |task|
19
+ task.patterns = ["lib/**/*.rb", "spec/**/*.rb"]
20
+ end
21
+
22
+ desc "Ensure that the plugin passes `danger plugins lint`"
23
+ task :spec_docs do
24
+ sh "bundle exec danger plugins lint"
25
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "gfsm_commit_trailer/gem_version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "danger-gfsm_commit_trailer"
9
+ spec.version = GfsmCommitTrailer::VERSION
10
+ spec.authors = ["Zille Marco"]
11
+ spec.description = "Danger plugin to add on projects using GFSM in order to make sure each MR creates a CHANGELOG entry."
12
+ spec.summary = "Danger plugin to add on projects using GFSM in order to make sure each MR creates a CHANGELOG entry."
13
+ spec.homepage = "https://gitlab.com/zillemarco/danger-gfsm_commit_trailer"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = ">= 2.7.5"
22
+
23
+ spec.add_runtime_dependency "danger-plugin-api", "~> 1.0"
24
+
25
+ # General ruby development
26
+ spec.add_development_dependency "bundler", "~> 2.0"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+
29
+ # Testing support
30
+ spec.add_development_dependency "rspec", "~> 3.4"
31
+
32
+ # Linting code and docs
33
+ spec.add_development_dependency "rubocop"
34
+ spec.add_development_dependency "yard"
35
+
36
+ # Makes testing easy via `bundle exec guard`
37
+ spec.add_development_dependency "guard", "~> 2.14"
38
+ spec.add_development_dependency "guard-rspec", "~> 4.7"
39
+
40
+ # If you want to work on older builds of ruby
41
+ spec.add_development_dependency "listen", "3.0.7"
42
+
43
+ # This gives you the chance to run a REPL inside your tests
44
+ # via:
45
+ #
46
+ # require 'pry'
47
+ # binding.pry
48
+ #
49
+ # This will stop test execution and let you inspect the results
50
+ spec.add_development_dependency "pry"
51
+ end
data/gfsmrc.yml ADDED
@@ -0,0 +1,41 @@
1
+ change_types:
2
+ new_features:
3
+ title: "New features"
4
+ matcher: added
5
+ bump: minor
6
+ priority: 50
7
+ fixes:
8
+ title: "Fixes"
9
+ matcher: fixed
10
+ bump: patch
11
+ priority: 30
12
+ feature_changes:
13
+ title: "Feature changes"
14
+ matcher: changed
15
+ bump: minor
16
+ priority: 48
17
+ deprecations:
18
+ title: "Deprecations"
19
+ matcher: deprecated
20
+ bump: minor
21
+ priority: 40
22
+ feature_removals:
23
+ title: "Feature removals"
24
+ matcher: removed
25
+ bump: minor
26
+ priority: 45
27
+ security_fixes:
28
+ title: "Security fixes"
29
+ matcher: security
30
+ bump: patch
31
+ priority: 38
32
+ performance_improvements:
33
+ title: "Performance improvements"
34
+ matcher: performance
35
+ bump: patch
36
+ priority: 35
37
+ other:
38
+ title: "Other"
39
+ matcher: other
40
+ bump: patch
41
+ priority: 0
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "gfsm_commit_trailer/gem_version"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "gfsm_commit_trailer/plugin"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GfsmCommitTrailer
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Danger
4
+ # Run each commit in the MR through the check.
5
+ #
6
+ # GFSM Commit Tralier will make sure that at least one commit
7
+ # inside the MR has a 'CHANGELOG: ' trailer.
8
+ #
9
+ # @example Warn instead of fail
10
+ #
11
+ # gfsm_commit_trailer.check(:warn: true)
12
+ #
13
+ # @see danger/danger
14
+ class DangerGfsmCommitTrailer < Plugin
15
+ ERROR_MESSAGE = "This MR has no commits with a CHANGELOG trailer."
16
+ CHANGELOG_TRAILER_REGEX = /^(?<name>Changelog):\s*(?<category>.+)$/i.freeze
17
+
18
+ # Checks the commits using the config passed by the user
19
+ #
20
+ # Passing in a hash which contains the following keys
21
+ #
22
+ # * `warn` - boolean value to tell whether or not eventual errors
23
+ # should be reported as warnings
24
+ #
25
+ # @param [Hash] config
26
+ #
27
+ # @return [void]
28
+ def check(config = {})
29
+ unless changelog_trailers?
30
+ if config.key?(:warn) && config[:warn]
31
+ messaging.warn ERROR_MESSAGE
32
+ else
33
+ messaging.fail ERROR_MESSAGE
34
+ end
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def changelog_trailers?
41
+ git.commits.each do |commit|
42
+ trailer = commit.message.match(CHANGELOG_TRAILER_REGEX)
43
+ return true if trailer
44
+ end
45
+
46
+ false
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,185 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("spec_helper", __dir__)
4
+
5
+ TEST_MESSAGES = {
6
+ no_trailers: [
7
+ "First commit without trailer",
8
+ "Second commit without trailer"
9
+ ],
10
+ single_trailer: [
11
+ "Commit with a trailer\n\nCHANGELOG: fixed",
12
+ "Second commit without trailer"
13
+ ],
14
+ multiple_trailers: [
15
+ "First commit with a trailer\n\nCHANGELOG: fixed",
16
+ "Second commit with a trailer\n\nCHANGELOG: added"
17
+ ],
18
+ trailer_in_subject: [
19
+ "CHANGELOG: added"
20
+ ]
21
+ }.freeze
22
+
23
+ def report_counts(status_report)
24
+ status_report.values.flatten.count
25
+ end
26
+
27
+ def random_sha
28
+ (0...7).map { rand(65...91).chr }.join
29
+ end
30
+
31
+ module Danger
32
+ describe Danger::DangerGfsmCommitTrailer do
33
+ it "should be a plugin" do
34
+ expect(Danger::DangerGfsmCommitTrailer.new(nil)).to be_a Danger::Plugin
35
+ end
36
+
37
+ describe "when errors should be trated as errors" do
38
+ describe "where there are no trailers" do
39
+ it "reports errors" do
40
+ gfsm_commit_trailer = testing_dangerfile.gfsm_commit_trailer
41
+ commits = TEST_MESSAGES[:no_trailers].map do |message|
42
+ double(:commit, message: message, sha: random_sha)
43
+ end
44
+
45
+ allow(gfsm_commit_trailer.git).to receive(:commits).and_return(commits)
46
+
47
+ gfsm_commit_trailer.check
48
+
49
+ status_report = gfsm_commit_trailer.status_report
50
+ expect(report_counts(status_report)).to eq(1)
51
+ expect(status_report[:warnings]).to eq([])
52
+ expect(status_report[:errors]).to eq([Danger::DangerGfsmCommitTrailer::ERROR_MESSAGE])
53
+ end
54
+ end
55
+
56
+ describe "where there is a single trailer" do
57
+ it "does not report any error" do
58
+ gfsm_commit_trailer = testing_dangerfile.gfsm_commit_trailer
59
+ commits = TEST_MESSAGES[:single_trailer].map do |message|
60
+ double(:commit, message: message, sha: random_sha)
61
+ end
62
+
63
+ allow(gfsm_commit_trailer.git).to receive(:commits).and_return(commits)
64
+
65
+ gfsm_commit_trailer.check
66
+
67
+ status_report = gfsm_commit_trailer.status_report
68
+ expect(report_counts(status_report)).to eq(0)
69
+ expect(status_report[:warnings]).to eq([])
70
+ expect(status_report[:errors]).to eq([])
71
+ end
72
+ end
73
+
74
+ describe "where there are multiple trailers" do
75
+ it "does not report any error" do
76
+ gfsm_commit_trailer = testing_dangerfile.gfsm_commit_trailer
77
+ commits = TEST_MESSAGES[:multiple_trailers].map do |message|
78
+ double(:commit, message: message, sha: random_sha)
79
+ end
80
+
81
+ allow(gfsm_commit_trailer.git).to receive(:commits).and_return(commits)
82
+
83
+ gfsm_commit_trailer.check
84
+
85
+ status_report = gfsm_commit_trailer.status_report
86
+ expect(report_counts(status_report)).to eq(0)
87
+ expect(status_report[:warnings]).to eq([])
88
+ expect(status_report[:errors]).to eq([])
89
+ end
90
+ end
91
+
92
+ describe "when the trailer is on the subject" do
93
+ it "reports errors" do
94
+ gfsm_commit_trailer = testing_dangerfile.gfsm_commit_trailer
95
+ commits = TEST_MESSAGES[:trailer_in_subject].map do |message|
96
+ double(:commit, message: message, sha: random_sha)
97
+ end
98
+
99
+ allow(gfsm_commit_trailer.git).to receive(:commits).and_return(commits)
100
+
101
+ gfsm_commit_trailer.check
102
+
103
+ status_report = gfsm_commit_trailer.status_report
104
+ expect(report_counts(status_report)).to eq(0)
105
+ expect(status_report[:warnings]).to eq([])
106
+ expect(status_report[:errors]).to eq([])
107
+ end
108
+ end
109
+ end
110
+
111
+ describe "when errors should be trated as warnings" do
112
+ describe "where there are no trailers" do
113
+ it "reports errors" do
114
+ gfsm_commit_trailer = testing_dangerfile.gfsm_commit_trailer
115
+ commits = TEST_MESSAGES[:no_trailers].map do |message|
116
+ double(:commit, message: message, sha: random_sha)
117
+ end
118
+
119
+ allow(gfsm_commit_trailer.git).to receive(:commits).and_return(commits)
120
+
121
+ gfsm_commit_trailer.check(warn: true)
122
+
123
+ status_report = gfsm_commit_trailer.status_report
124
+ expect(report_counts(status_report)).to eq(1)
125
+ expect(status_report[:warnings]).to eq([Danger::DangerGfsmCommitTrailer::ERROR_MESSAGE])
126
+ expect(status_report[:errors]).to eq([])
127
+ end
128
+ end
129
+
130
+ describe "where there is a single trailer" do
131
+ it "does not report any error" do
132
+ gfsm_commit_trailer = testing_dangerfile.gfsm_commit_trailer
133
+ commits = TEST_MESSAGES[:single_trailer].map do |message|
134
+ double(:commit, message: message, sha: random_sha)
135
+ end
136
+
137
+ allow(gfsm_commit_trailer.git).to receive(:commits).and_return(commits)
138
+
139
+ gfsm_commit_trailer.check(warn: true)
140
+
141
+ status_report = gfsm_commit_trailer.status_report
142
+ expect(report_counts(status_report)).to eq(0)
143
+ expect(status_report[:warnings]).to eq([])
144
+ expect(status_report[:errors]).to eq([])
145
+ end
146
+ end
147
+
148
+ describe "where there are multiple trailers" do
149
+ it "does not report any error" do
150
+ gfsm_commit_trailer = testing_dangerfile.gfsm_commit_trailer
151
+ commits = TEST_MESSAGES[:multiple_trailers].map do |message|
152
+ double(:commit, message: message, sha: random_sha)
153
+ end
154
+
155
+ allow(gfsm_commit_trailer.git).to receive(:commits).and_return(commits)
156
+
157
+ gfsm_commit_trailer.check(warn: true)
158
+
159
+ status_report = gfsm_commit_trailer.status_report
160
+ expect(report_counts(status_report)).to eq(0)
161
+ expect(status_report[:warnings]).to eq([])
162
+ expect(status_report[:errors]).to eq([])
163
+ end
164
+ end
165
+
166
+ describe "when the trailer is on the subject" do
167
+ it "reports errors" do
168
+ gfsm_commit_trailer = testing_dangerfile.gfsm_commit_trailer
169
+ commits = TEST_MESSAGES[:trailer_in_subject].map do |message|
170
+ double(:commit, message: message, sha: random_sha)
171
+ end
172
+
173
+ allow(gfsm_commit_trailer.git).to receive(:commits).and_return(commits)
174
+
175
+ gfsm_commit_trailer.check(warn: true)
176
+
177
+ status_report = gfsm_commit_trailer.status_report
178
+ expect(report_counts(status_report)).to eq(0)
179
+ expect(status_report[:warnings]).to eq([])
180
+ expect(status_report[:errors]).to eq([])
181
+ end
182
+ end
183
+ end
184
+ end
185
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ ROOT = Pathname.new(File.expand_path("..", __dir__))
5
+ $:.unshift("#{ROOT}lib".to_s)
6
+ $:.unshift("#{ROOT}spec".to_s)
7
+
8
+ require "bundler/setup"
9
+ require "pry"
10
+
11
+ require "rspec"
12
+ require "danger"
13
+
14
+ if `git remote -v` == ""
15
+ puts "You cannot run tests without setting a local git remote on this repo"
16
+ puts "It's a weird side-effect of Danger's internals."
17
+ exit(0)
18
+ end
19
+
20
+ # Use coloured output, it's the best.
21
+ RSpec.configure do |config|
22
+ config.filter_gems_from_backtrace "bundler"
23
+ config.color = true
24
+ config.tty = true
25
+ end
26
+
27
+ require "danger_plugin"
28
+
29
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
30
+ # If you are expanding these files, see if it's already been done ^.
31
+
32
+ # A silent version of the user interface,
33
+ # it comes with an extra function `.string` which will
34
+ # strip all ANSI colours from the string.
35
+
36
+ # rubocop:disable Lint/NestedMethodDefinition
37
+ def testing_ui
38
+ @output = StringIO.new
39
+ def @output.winsize
40
+ [20, 9999]
41
+ end
42
+
43
+ cork = Cork::Board.new(out: @output)
44
+ def cork.string
45
+ out.string.gsub(/\e\[([;\d]+)?m/, "")
46
+ end
47
+ cork
48
+ end
49
+ # rubocop:enable Lint/NestedMethodDefinition
50
+
51
+ # Example environment (ENV) that would come from
52
+ # running a PR on TravisCI
53
+ def testing_env
54
+ {
55
+ "HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
56
+ "TRAVIS_PULL_REQUEST" => "800",
57
+ "TRAVIS_REPO_SLUG" => "artsy/eigen",
58
+ "TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
59
+ "DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
60
+ }
61
+ end
62
+
63
+ # A stubbed out Dangerfile for use in tests
64
+ def testing_dangerfile
65
+ env = Danger::EnvironmentManager.new(testing_env)
66
+ Danger::Dangerfile.new(env, testing_ui)
67
+ end
metadata ADDED
@@ -0,0 +1,204 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-gfsm_commit_trailer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Zille Marco
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-07-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: danger-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.7'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: listen
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 3.0.7
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 3.0.7
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Danger plugin to add on projects using GFSM in order to make sure each
154
+ MR creates a CHANGELOG entry.
155
+ email:
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".gitlab-ci.yml"
162
+ - ".rubocop.yml"
163
+ - ".tool-versions"
164
+ - Gemfile
165
+ - Gemfile.lock
166
+ - Guardfile
167
+ - LICENSE.txt
168
+ - README.md
169
+ - Rakefile
170
+ - danger-gfsm_commit_trailer.gemspec
171
+ - gfsmrc.yml
172
+ - lib/danger_gfsm_commit_trailer.rb
173
+ - lib/danger_plugin.rb
174
+ - lib/gfsm_commit_trailer/gem_version.rb
175
+ - lib/gfsm_commit_trailer/plugin.rb
176
+ - spec/gfsm_commit_trailer_spec.rb
177
+ - spec/spec_helper.rb
178
+ homepage: https://gitlab.com/zillemarco/danger-gfsm_commit_trailer
179
+ licenses:
180
+ - MIT
181
+ metadata: {}
182
+ post_install_message:
183
+ rdoc_options: []
184
+ require_paths:
185
+ - lib
186
+ required_ruby_version: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: 2.7.5
191
+ required_rubygems_version: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ requirements: []
197
+ rubygems_version: 3.1.6
198
+ signing_key:
199
+ specification_version: 4
200
+ summary: Danger plugin to add on projects using GFSM in order to make sure each MR
201
+ creates a CHANGELOG entry.
202
+ test_files:
203
+ - spec/gfsm_commit_trailer_spec.rb
204
+ - spec/spec_helper.rb