gitlabci-bundle-update-mr 0.3.0 → 1.1.1
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.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +38 -23
- data/.rubocop.yml +9 -5
- data/CHANGELOG.md +18 -1
- data/Gemfile +7 -2
- data/Gemfile.lock +92 -77
- data/README.md +33 -0
- data/exe/gitlabci-bundle-update-mr +3 -0
- data/gitlabci-bundle-update-mr.gemspec +6 -4
- data/gitlabci-templates/continuous_bundle_update.yml +5 -0
- data/lib/gitlabci/bundle/update/mr.rb +2 -0
- data/lib/gitlabci/bundle/update/mr/client.rb +69 -4
- data/lib/gitlabci/bundle/update/mr/version.rb +1 -1
- metadata +41 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d1206c8c3121aad2c45e26a171ea8dc1f4d63a63edf928c2c0461e5eee6c060
|
4
|
+
data.tar.gz: 37c562a6f10341664b39d6074900f801e922a207a941ba6a2a1037fa082cc9d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1946c3432b01d0de283c76e9e3cf66139e353b83cc931e2599efa0af6d7c2a4eab16de0b0688892c8212637e9a76cec3e2f12f31ed3c00ba9a585b30fce792d9
|
7
|
+
data.tar.gz: 2cfdbd4ef410037d08a69dbea805de4d38baf0ecece5797efeb084dee4fea40e9e7b3329fe4f375a474397c40632bbe89eb3a9bc627ebe8242a55310191f14a8
|
data/.gitlab-ci.yml
CHANGED
@@ -13,23 +13,21 @@ continuous_bundle_update:
|
|
13
13
|
GIT_EMAIL: "gitlabci@example.com"
|
14
14
|
GIT_USER: "GitLab CI"
|
15
15
|
OPTIONS: "--merge-when-pipeline-succeeds"
|
16
|
+
ASSIGNEES: "sue445"
|
16
17
|
|
17
18
|
before_script:
|
18
19
|
# Set timezone to Asia/Tokyo
|
19
20
|
- cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
|
20
21
|
|
21
|
-
|
22
|
-
- schedules
|
23
|
-
- web # Test for topic branch
|
24
|
-
|
25
|
-
.default: &default
|
22
|
+
.default:
|
26
23
|
cache:
|
27
24
|
key: "$CI_BUILD_NAME"
|
28
25
|
paths:
|
29
26
|
- vendor/bundle/
|
30
27
|
|
31
28
|
before_script:
|
32
|
-
- bundle
|
29
|
+
- bundle config --local path 'vendor/bundle'
|
30
|
+
- bundle install --retry=3 --jobs=$(nproc)
|
33
31
|
- bundle clean
|
34
32
|
|
35
33
|
except:
|
@@ -37,8 +35,8 @@ continuous_bundle_update:
|
|
37
35
|
- web
|
38
36
|
- tags
|
39
37
|
|
40
|
-
.test:
|
41
|
-
|
38
|
+
.test:
|
39
|
+
extends: .default
|
42
40
|
|
43
41
|
stage: build
|
44
42
|
|
@@ -46,34 +44,34 @@ continuous_bundle_update:
|
|
46
44
|
- bundle exec rspec
|
47
45
|
- bundle exec ./exe/gitlabci-bundle-update-mr --help
|
48
46
|
|
49
|
-
test:2.3:
|
50
|
-
<<: *test
|
51
|
-
|
52
|
-
image: ruby:2.3
|
53
|
-
|
54
|
-
test:2.4:
|
55
|
-
<<: *test
|
56
|
-
|
57
|
-
image: ruby:2.4
|
58
|
-
|
59
47
|
test:2.5:
|
60
|
-
|
48
|
+
extends: .test
|
61
49
|
|
62
50
|
image: ruby:2.5
|
63
51
|
|
64
52
|
test:2.6:
|
65
|
-
|
53
|
+
extends: .test
|
66
54
|
|
67
55
|
image: ruby:2.6
|
68
56
|
|
57
|
+
test:2.7:
|
58
|
+
extends: .test
|
59
|
+
|
60
|
+
image: ruby:2.7
|
61
|
+
|
62
|
+
test:3.0:
|
63
|
+
extends: .test
|
64
|
+
|
65
|
+
image: ruby:3.0
|
66
|
+
|
69
67
|
test:trunk:
|
70
|
-
|
68
|
+
extends: .test
|
71
69
|
|
72
70
|
image: rubylang/ruby:trunk-nightly-bionic
|
73
71
|
allow_failure: true
|
74
72
|
|
75
73
|
rubocop:
|
76
|
-
|
74
|
+
extends: .default
|
77
75
|
|
78
76
|
stage: build
|
79
77
|
|
@@ -83,7 +81,7 @@ rubocop:
|
|
83
81
|
- bundle exec rubocop -P
|
84
82
|
|
85
83
|
pages:
|
86
|
-
|
84
|
+
extends: .default
|
87
85
|
|
88
86
|
stage: deploy
|
89
87
|
|
@@ -96,3 +94,20 @@ pages:
|
|
96
94
|
- public
|
97
95
|
only:
|
98
96
|
- master
|
97
|
+
|
98
|
+
gitlab_awesome_release:
|
99
|
+
stage: build
|
100
|
+
|
101
|
+
image: ruby:alpine
|
102
|
+
|
103
|
+
script:
|
104
|
+
- gem install gitlab_awesome_release --no-doc
|
105
|
+
- gitlab_awesome_release create_latest_note
|
106
|
+
|
107
|
+
variables:
|
108
|
+
GITLAB_API_ENDPOINT: $CI_API_V4_URL
|
109
|
+
GITLAB_PROJECT_NAME: $CI_PROJECT_PATH
|
110
|
+
GITLAB_API_PRIVATE_TOKEN: $GITLAB_API_PRIVATE_TOKEN
|
111
|
+
|
112
|
+
only:
|
113
|
+
- web
|
data/.rubocop.yml
CHANGED
@@ -9,17 +9,21 @@ inherit_gem:
|
|
9
9
|
# - "config/rspec.yml"
|
10
10
|
|
11
11
|
AllCops:
|
12
|
-
TargetRubyVersion: 2.
|
12
|
+
TargetRubyVersion: 2.5
|
13
|
+
NewCops: enable
|
13
14
|
|
14
|
-
Layout/
|
15
|
+
Layout/HashAlignment:
|
15
16
|
EnforcedHashRocketStyle: table
|
16
17
|
EnforcedColonStyle: table
|
17
18
|
|
18
|
-
Layout/
|
19
|
+
Layout/IndentationConsistency:
|
20
|
+
EnforcedStyle: indented_internal_methods
|
21
|
+
|
22
|
+
Layout/FirstArrayElementIndentation:
|
19
23
|
EnforcedStyle: consistent
|
20
24
|
|
21
|
-
Layout/
|
25
|
+
Layout/FirstHashElementIndentation:
|
22
26
|
EnforcedStyle: consistent
|
23
27
|
|
24
28
|
Metrics/MethodLength:
|
25
|
-
Max:
|
29
|
+
Max: 22
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
## Unreleased
|
2
|
-
[full changelog](https://gitlab.com/sue445/gitlabci-bundle-update-mr/compare/
|
2
|
+
[full changelog](https://gitlab.com/sue445/gitlabci-bundle-update-mr/compare/v1.1.1...master)
|
3
|
+
|
4
|
+
## v1.1.1
|
5
|
+
[full changelog](https://gitlab.com/sue445/gitlabci-bundle-update-mr/compare/v1.1.0...v1.1.1)
|
6
|
+
|
7
|
+
* Add auto retry when `merge when pipeline succeeds` is failed [!128](https://gitlab.com/sue445/gitlabci-bundle-update-mr/merge_requests/128) *@sue445*
|
8
|
+
* [Resolved] `open': can't modify frozen Hash: {} (FrozenError) [!131](https://gitlab.com/sue445/gitlabci-bundle-update-mr/merge_requests/131) *@sue445*
|
9
|
+
|
10
|
+
## v1.1.0
|
11
|
+
[full changelog](https://gitlab.com/sue445/gitlabci-bundle-update-mr/compare/v1.0.0...v1.1.0)
|
12
|
+
|
13
|
+
* Support assignee [!113](https://gitlab.com/sue445/gitlabci-bundle-update-mr/merge_requests/113) *@sue445*
|
14
|
+
|
15
|
+
## v1.0.0
|
16
|
+
[full changelog](https://gitlab.com/sue445/gitlabci-bundle-update-mr/compare/v0.3.0...v1.0.0)
|
17
|
+
|
18
|
+
### Breaking changes :warning:
|
19
|
+
* Drop support ruby < 2.5 [!87](https://gitlab.com/sue445/gitlabci-bundle-update-mr/merge_requests/87) *@sue445*
|
3
20
|
|
4
21
|
## v0.3.0
|
5
22
|
[full changelog](https://gitlab.com/sue445/gitlabci-bundle-update-mr/compare/v0.2.2...v0.3.0)
|
data/Gemfile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
|
+
git_source(:github) {|repo| "https://github.com/#{repo}.git" }
|
2
3
|
|
3
4
|
# Specify your gem's dependencies in gitlabci-bundle-update-mr.gemspec
|
4
5
|
gemspec
|
@@ -8,6 +9,10 @@ gem "faraday", ">= 0.15.4"
|
|
8
9
|
gem "octokit", ">= 4.13.0"
|
9
10
|
gem "sawyer", ">= 0.8.1"
|
10
11
|
|
11
|
-
# TODO: Remove after
|
12
|
-
|
12
|
+
# TODO: Remove after following PR are merged
|
13
|
+
# * https://github.com/onk/onkcop/pull/62
|
14
|
+
# * https://github.com/onk/onkcop/pull/63
|
15
|
+
# * https://github.com/onk/onkcop/pull/65
|
16
|
+
# gem "onkcop", ">= 0.53.0.3", require: false
|
17
|
+
gem "onkcop", require: false, github: "sue445/onkcop", branch: "develop"
|
13
18
|
gem "rubocop", ">= 0.68.0"
|
data/Gemfile.lock
CHANGED
@@ -1,125 +1,139 @@
|
|
1
1
|
GIT
|
2
|
-
remote:
|
3
|
-
revision:
|
4
|
-
|
5
|
-
branch: rubocop_0.68.0
|
2
|
+
remote: https://github.com/sue445/onkcop.git
|
3
|
+
revision: d09f75a5eeb1969800cca160f653325771590fae
|
4
|
+
branch: develop
|
6
5
|
specs:
|
7
6
|
onkcop (0.53.0.3)
|
8
7
|
rubocop (>= 0.53.0)
|
9
|
-
rubocop-rspec (>= 1.
|
8
|
+
rubocop-rspec (>= 1.34.0)
|
10
9
|
|
11
10
|
PATH
|
12
11
|
remote: .
|
13
12
|
specs:
|
14
|
-
gitlabci-bundle-update-mr (
|
13
|
+
gitlabci-bundle-update-mr (1.1.1)
|
15
14
|
bundler
|
16
15
|
compare_linker (>= 1.4.3)
|
17
|
-
|
16
|
+
git (= 1.7.0)
|
17
|
+
gitlab (>= 4.14.1)
|
18
18
|
restore_bundled_with
|
19
19
|
|
20
20
|
GEM
|
21
21
|
remote: https://rubygems.org/
|
22
22
|
specs:
|
23
|
-
addressable (2.
|
24
|
-
public_suffix (>= 2.0.2, <
|
25
|
-
ast (2.4.
|
26
|
-
byebug (11.
|
27
|
-
coderay (1.1.
|
28
|
-
compare_linker (1.4.
|
23
|
+
addressable (2.7.0)
|
24
|
+
public_suffix (>= 2.0.2, < 5.0)
|
25
|
+
ast (2.4.1)
|
26
|
+
byebug (11.1.3)
|
27
|
+
coderay (1.1.3)
|
28
|
+
compare_linker (1.4.4)
|
29
29
|
httpclient
|
30
30
|
octokit
|
31
|
-
crack (0.4.
|
32
|
-
|
33
|
-
diff-lcs (1.
|
34
|
-
docile (1.3.
|
35
|
-
dotenv (2.7.
|
36
|
-
faraday (
|
31
|
+
crack (0.4.5)
|
32
|
+
rexml
|
33
|
+
diff-lcs (1.4.4)
|
34
|
+
docile (1.3.4)
|
35
|
+
dotenv (2.7.6)
|
36
|
+
faraday (1.2.0)
|
37
37
|
multipart-post (>= 1.2, < 3)
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
ruby2_keywords
|
39
|
+
git (1.7.0)
|
40
|
+
rchardet (~> 1.8)
|
41
|
+
gitlab (4.17.0)
|
42
|
+
httparty (~> 0.18)
|
41
43
|
terminal-table (~> 1.5, >= 1.5.1)
|
42
44
|
gitlab_awesome_release (1.0.2)
|
43
45
|
dotenv
|
44
46
|
gitlab (>= 4.0.0)
|
45
47
|
thor
|
46
|
-
hashdiff (0.
|
47
|
-
httparty (0.
|
48
|
+
hashdiff (1.0.1)
|
49
|
+
httparty (0.18.1)
|
48
50
|
mime-types (~> 3.0)
|
49
51
|
multi_xml (>= 0.5.2)
|
50
52
|
httpclient (2.8.3)
|
51
|
-
|
52
|
-
|
53
|
-
method_source (0.9.2)
|
54
|
-
mime-types (3.2.2)
|
53
|
+
method_source (1.0.0)
|
54
|
+
mime-types (3.3.1)
|
55
55
|
mime-types-data (~> 3.2015)
|
56
|
-
mime-types-data (3.
|
56
|
+
mime-types-data (3.2020.1104)
|
57
57
|
multi_xml (0.6.0)
|
58
|
-
multipart-post (2.
|
59
|
-
octokit (4.
|
58
|
+
multipart-post (2.1.1)
|
59
|
+
octokit (4.19.0)
|
60
|
+
faraday (>= 0.9)
|
60
61
|
sawyer (~> 0.8.0, >= 0.5.3)
|
61
|
-
parallel (1.
|
62
|
-
parser (
|
63
|
-
ast (~> 2.4.
|
64
|
-
pry (0.
|
65
|
-
coderay (~> 1.1
|
66
|
-
method_source (~>
|
67
|
-
pry-byebug (3.
|
62
|
+
parallel (1.20.1)
|
63
|
+
parser (3.0.0.0)
|
64
|
+
ast (~> 2.4.1)
|
65
|
+
pry (0.13.1)
|
66
|
+
coderay (~> 1.1)
|
67
|
+
method_source (~> 1.0)
|
68
|
+
pry-byebug (3.9.0)
|
68
69
|
byebug (~> 11.0)
|
69
|
-
pry (~> 0.
|
70
|
-
public_suffix (
|
70
|
+
pry (~> 0.13.0)
|
71
|
+
public_suffix (4.0.6)
|
71
72
|
rainbow (3.0.0)
|
72
|
-
rake (
|
73
|
+
rake (13.0.3)
|
74
|
+
rchardet (1.8.0)
|
75
|
+
regexp_parser (2.0.2)
|
73
76
|
restore_bundled_with (1.0.0)
|
74
77
|
git
|
75
78
|
thor
|
76
|
-
|
77
|
-
|
78
|
-
rspec-
|
79
|
-
rspec-
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
rexml (3.2.4)
|
80
|
+
rspec (3.10.0)
|
81
|
+
rspec-core (~> 3.10.0)
|
82
|
+
rspec-expectations (~> 3.10.0)
|
83
|
+
rspec-mocks (~> 3.10.0)
|
84
|
+
rspec-core (3.10.1)
|
85
|
+
rspec-support (~> 3.10.0)
|
86
|
+
rspec-expectations (3.10.1)
|
83
87
|
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
-
rspec-support (~> 3.
|
85
|
-
rspec-
|
88
|
+
rspec-support (~> 3.10.0)
|
89
|
+
rspec-its (1.3.0)
|
90
|
+
rspec-core (>= 3.0.0)
|
91
|
+
rspec-expectations (>= 3.0.0)
|
92
|
+
rspec-mocks (3.10.0)
|
86
93
|
diff-lcs (>= 1.2.0, < 2.0)
|
87
|
-
rspec-support (~> 3.
|
88
|
-
rspec-support (3.
|
94
|
+
rspec-support (~> 3.10.0)
|
95
|
+
rspec-support (3.10.1)
|
89
96
|
rspec-temp_dir (1.1.0)
|
90
97
|
rspec (>= 3.0)
|
91
|
-
rubocop (
|
92
|
-
jaro_winkler (~> 1.5.1)
|
98
|
+
rubocop (1.7.0)
|
93
99
|
parallel (~> 1.10)
|
94
|
-
parser (>= 2.
|
100
|
+
parser (>= 2.7.1.5)
|
95
101
|
rainbow (>= 2.2.2, < 4.0)
|
102
|
+
regexp_parser (>= 1.8, < 3.0)
|
103
|
+
rexml
|
104
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
96
105
|
ruby-progressbar (~> 1.7)
|
97
|
-
unicode-display_width (>= 1.4.0, <
|
98
|
-
rubocop-
|
99
|
-
|
100
|
-
rubocop-
|
101
|
-
rubocop (>= 0.
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
107
|
+
rubocop-ast (1.3.0)
|
108
|
+
parser (>= 2.7.1.5)
|
109
|
+
rubocop-performance (1.9.1)
|
110
|
+
rubocop (>= 0.90.0, < 2.0)
|
111
|
+
rubocop-ast (>= 0.4.0)
|
112
|
+
rubocop-rspec (2.1.0)
|
113
|
+
rubocop (~> 1.0)
|
114
|
+
rubocop-ast (>= 1.1.0)
|
115
|
+
rubocop_auto_corrector (0.4.1)
|
116
|
+
rubocop (>= 0.87.0)
|
117
|
+
ruby-progressbar (1.10.1)
|
118
|
+
ruby2_keywords (0.0.2)
|
119
|
+
sawyer (0.8.2)
|
120
|
+
addressable (>= 2.3.5)
|
121
|
+
faraday (> 0.8, < 2.0)
|
122
|
+
simplecov (0.20.0)
|
110
123
|
docile (~> 1.1)
|
111
|
-
|
112
|
-
|
113
|
-
simplecov-html (0.
|
124
|
+
simplecov-html (~> 0.11)
|
125
|
+
simplecov_json_formatter (~> 0.1)
|
126
|
+
simplecov-html (0.12.3)
|
127
|
+
simplecov_json_formatter (0.1.2)
|
114
128
|
terminal-table (1.8.0)
|
115
129
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
116
|
-
thor (0.
|
117
|
-
unicode-display_width (1.
|
118
|
-
webmock (3.
|
130
|
+
thor (1.0.1)
|
131
|
+
unicode-display_width (1.7.0)
|
132
|
+
webmock (3.11.0)
|
119
133
|
addressable (>= 2.3.6)
|
120
134
|
crack (>= 0.3.2)
|
121
|
-
hashdiff
|
122
|
-
yard (0.9.
|
135
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
136
|
+
yard (0.9.26)
|
123
137
|
|
124
138
|
PLATFORMS
|
125
139
|
ruby
|
@@ -132,8 +146,9 @@ DEPENDENCIES
|
|
132
146
|
octokit (>= 4.13.0)
|
133
147
|
onkcop!
|
134
148
|
pry-byebug
|
135
|
-
rake (
|
149
|
+
rake (>= 10.0)
|
136
150
|
rspec (~> 3.0)
|
151
|
+
rspec-its
|
137
152
|
rspec-temp_dir
|
138
153
|
rubocop (>= 0.68.0)
|
139
154
|
rubocop-performance
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Gitlabci::Bundle::Update::Mr
|
2
2
|
[](https://badge.fury.io/rb/gitlabci-bundle-update-mr)
|
3
|
+
[](https://gitlab.com/sue445/gitlabci-bundle-update-mr/commits/master)
|
4
|
+
[](https://gitlab.com/sue445/gitlabci-bundle-update-mr/commits/master)
|
3
5
|
|
4
6
|
Create MergeRequest of bundle update in GitLab CI
|
5
7
|
|
@@ -99,6 +101,7 @@ continuous_bundle_update:
|
|
99
101
|
GIT_EMAIL: "gitlabci@example.com"
|
100
102
|
GIT_USER: "GitLab CI"
|
101
103
|
LABELS: "bundle update"
|
104
|
+
ASSIGNEES: "foo, bar, baz"
|
102
105
|
OPTIONS: ""
|
103
106
|
|
104
107
|
before_script:
|
@@ -122,8 +125,38 @@ Usage: gitlabci-bundle-update-mr [options]
|
|
122
125
|
--update-bundled-with Whether to update `BUNDLED WITH` section in Gemfie.lock (default. false)
|
123
126
|
--merge-when-pipeline-succeeds
|
124
127
|
Whether to set 'Merge when pipeline succeeds' (default. false)
|
128
|
+
--assignees 'foo, bar' Add assignees to the MR
|
125
129
|
```
|
126
130
|
|
131
|
+
## ProTip
|
132
|
+
### Randomly assign one person to MergeRequest
|
133
|
+
```yml
|
134
|
+
include:
|
135
|
+
- remote: "https://gitlab.com/sue445/gitlabci-bundle-update-mr/raw/master/gitlabci-templates/continuous_bundle_update.yml"
|
136
|
+
|
137
|
+
continuous_bundle_update:
|
138
|
+
stage: build
|
139
|
+
|
140
|
+
before_script:
|
141
|
+
- ASSIGNEES=$(ruby -e 'print %w[foo bar baz].sample')
|
142
|
+
```
|
143
|
+
|
144
|
+
### Assign one person to MR on a weekly basis
|
145
|
+
```yml
|
146
|
+
include:
|
147
|
+
- remote: "https://gitlab.com/sue445/gitlabci-bundle-update-mr/raw/master/gitlabci-templates/continuous_bundle_update.yml"
|
148
|
+
|
149
|
+
continuous_bundle_update:
|
150
|
+
stage: build
|
151
|
+
|
152
|
+
before_script:
|
153
|
+
- ASSIGNEES=$(ruby -rtime -e 'a=%w[foo bar baz]; print a[Time.now.to_date.cweek% a.size]')
|
154
|
+
```
|
155
|
+
|
156
|
+
It will be assigned weekly in the following order.
|
157
|
+
|
158
|
+
`foo` -> `bar` -> `baz` -> `foo` -> `bar` -> `baz` -> ...
|
159
|
+
|
127
160
|
## Development
|
128
161
|
|
129
162
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -11,6 +11,7 @@ allow_dup_mr = false
|
|
11
11
|
mr_labels = []
|
12
12
|
update_bundled_with = false
|
13
13
|
merge_when_pipeline_succeeds = false
|
14
|
+
assignees = []
|
14
15
|
|
15
16
|
opt.on("--email EMAIL", "git email address (default. `git config user.email`)") {|v| author_email = v }
|
16
17
|
opt.on("--user USER", "git username (default. `git config user.name`)") {|v| author_name = v }
|
@@ -18,6 +19,7 @@ opt.on("-d", "--duplicate", "Make MR even if it has already existed (default. fa
|
|
18
19
|
opt.on("-l", "--labels 'In Review, Update'", Array, "Add labels to the MR") {|v| mr_labels = v.map(&:strip) }
|
19
20
|
opt.on("--update-bundled-with", "Whether to update `BUNDLED WITH` section in Gemfie.lock (default. false)") {|v| update_bundled_with = v }
|
20
21
|
opt.on("--merge-when-pipeline-succeeds", "Whether to set 'Merge when pipeline succeeds' (default. false)") {|v| merge_when_pipeline_succeeds = v }
|
22
|
+
opt.on("--assignees 'foo, bar'", Array, "Add assignees to the MR") {|v| assignees = v.map(&:strip) }
|
21
23
|
|
22
24
|
opt.parse!(ARGV)
|
23
25
|
|
@@ -37,4 +39,5 @@ client.perform(
|
|
37
39
|
mr_labels: mr_labels,
|
38
40
|
update_bundled_with: update_bundled_with,
|
39
41
|
merge_when_pipeline_succeeds: merge_when_pipeline_succeeds,
|
42
|
+
assignees: assignees,
|
40
43
|
)
|
@@ -34,22 +34,24 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
35
35
|
spec.require_paths = ["lib"]
|
36
36
|
|
37
|
-
spec.required_ruby_version = ">= 2.
|
37
|
+
spec.required_ruby_version = ">= 2.5.0"
|
38
38
|
|
39
39
|
spec.add_dependency "bundler"
|
40
40
|
spec.add_dependency "compare_linker", ">= 1.4.3"
|
41
|
-
spec.add_dependency "
|
41
|
+
spec.add_dependency "git", "1.7.0"
|
42
|
+
spec.add_dependency "gitlab", ">= 4.14.1"
|
42
43
|
spec.add_dependency "restore_bundled_with"
|
43
44
|
|
44
45
|
spec.add_development_dependency "dotenv"
|
45
46
|
spec.add_development_dependency "gitlab_awesome_release"
|
46
47
|
spec.add_development_dependency "onkcop"
|
47
48
|
spec.add_development_dependency "pry-byebug"
|
48
|
-
spec.add_development_dependency "rake", "
|
49
|
+
spec.add_development_dependency "rake", ">= 10.0"
|
49
50
|
spec.add_development_dependency "rspec", "~> 3.0"
|
51
|
+
spec.add_development_dependency "rspec-its"
|
50
52
|
spec.add_development_dependency "rspec-temp_dir"
|
51
|
-
spec.add_development_dependency "rubocop-performance"
|
52
53
|
spec.add_development_dependency "rubocop_auto_corrector"
|
54
|
+
spec.add_development_dependency "rubocop-performance"
|
53
55
|
spec.add_development_dependency "simplecov"
|
54
56
|
spec.add_development_dependency "webmock"
|
55
57
|
spec.add_development_dependency "yard"
|
@@ -6,6 +6,7 @@ continuous_bundle_update:
|
|
6
6
|
GIT_EMAIL: "gitlabci@example.com"
|
7
7
|
GIT_USER: "GitLab CI"
|
8
8
|
LABELS: "bundle update"
|
9
|
+
ASSIGNEES: ""
|
9
10
|
OPTIONS: ""
|
10
11
|
|
11
12
|
cache:
|
@@ -16,6 +17,10 @@ continuous_bundle_update:
|
|
16
17
|
script:
|
17
18
|
- bundle install --path vendor/bundle --clean
|
18
19
|
- gem install --no-doc gitlabci-bundle-update-mr
|
20
|
+
- |
|
21
|
+
if [ -n "$ASSIGNEES" ]; then
|
22
|
+
OPTIONS="--assignees $ASSIGNEES $OPTIONS"
|
23
|
+
fi
|
19
24
|
- gitlabci-bundle-update-mr --user="$GIT_USER" --email="$GIT_EMAIL" --labels="$LABELS" $OPTIONS
|
20
25
|
|
21
26
|
only:
|
@@ -5,6 +5,7 @@ module Gitlabci
|
|
5
5
|
class Client # rubocop:disable Metrics/ClassLength
|
6
6
|
BRANCH_PREFIX = "bundle-update-".freeze
|
7
7
|
TITLE_PREFIX = "bundle update at ".freeze
|
8
|
+
MAX_RETRY_COUNT = 3
|
8
9
|
|
9
10
|
# rubocop:disable Metrics/ParameterLists
|
10
11
|
|
@@ -28,12 +29,14 @@ module Gitlabci
|
|
28
29
|
# @param mr_labels [Array<String>]
|
29
30
|
# @param update_bundled_with [Boolean]
|
30
31
|
# @param merge_when_pipeline_succeeds [Boolean]
|
31
|
-
|
32
|
+
# @param assignees [Array<String>]
|
33
|
+
def perform(allow_dup_mr:, mr_labels:, update_bundled_with:, merge_when_pipeline_succeeds:, assignees:)
|
32
34
|
if !allow_dup_mr && exists_bundle_update_mr?
|
33
35
|
puts "Skip because it has already existed."
|
34
36
|
return
|
35
37
|
end
|
36
38
|
|
39
|
+
assignee_ids = get_assignee_ids(assignees)
|
37
40
|
old_lockfile = File.read(lockfile_name)
|
38
41
|
|
39
42
|
system!("bundle update")
|
@@ -51,7 +54,7 @@ module Gitlabci
|
|
51
54
|
commit_gemfile_lock(new_lockfile)
|
52
55
|
description = merge_request_description(old_lockfile, new_lockfile)
|
53
56
|
|
54
|
-
mr = create_merge_request(description: description, mr_labels: mr_labels)
|
57
|
+
mr = create_merge_request(description: description, mr_labels: mr_labels, assignee_ids: assignee_ids)
|
55
58
|
puts "MR is created: #{mr.web_url}"
|
56
59
|
|
57
60
|
if merge_when_pipeline_succeeds
|
@@ -81,7 +84,10 @@ module Gitlabci
|
|
81
84
|
|
82
85
|
# @param description [String]
|
83
86
|
# @param mr_labels [Array<String>]
|
84
|
-
|
87
|
+
# @param assignee_ids [Array<Integer>]
|
88
|
+
#
|
89
|
+
# @see https://docs.gitlab.com/ee/api/merge_requests.html#create-mr
|
90
|
+
def create_merge_request(description:, mr_labels:, assignee_ids:)
|
85
91
|
params = {
|
86
92
|
source_branch: new_branch,
|
87
93
|
target_branch: @branch,
|
@@ -93,6 +99,12 @@ module Gitlabci
|
|
93
99
|
params[:labels] = mr_labels.join(",")
|
94
100
|
end
|
95
101
|
|
102
|
+
if assignee_ids.length == 1
|
103
|
+
params[:assignee_id] = assignee_ids[0]
|
104
|
+
elsif assignee_ids.length >= 2
|
105
|
+
params[:assignee_ids] = assignee_ids
|
106
|
+
end
|
107
|
+
|
96
108
|
@gitlab.create_merge_request(
|
97
109
|
@project_name,
|
98
110
|
"#{TITLE_PREFIX}#{current_time.strftime("%Y-%m-%d %H:%M:%S %Z")}",
|
@@ -120,6 +132,33 @@ module Gitlabci
|
|
120
132
|
MARKDOWN
|
121
133
|
end
|
122
134
|
|
135
|
+
# @param username [String]
|
136
|
+
#
|
137
|
+
# @return [Gitlab::ObjectifiedHash]
|
138
|
+
# @return [nil] User isn't found
|
139
|
+
#
|
140
|
+
# @see https://docs.gitlab.com/ee/api/users.html#for-normal-users
|
141
|
+
def find_by_username(username)
|
142
|
+
@gitlab.users(username: username).first
|
143
|
+
end
|
144
|
+
|
145
|
+
# @param username [String]
|
146
|
+
#
|
147
|
+
# @return [Gitlab::ObjectifiedHash]
|
148
|
+
#
|
149
|
+
# @raise [Gitlabci::Bundle::Update::Mr::NotFoundUserError]
|
150
|
+
#
|
151
|
+
# @see https://docs.gitlab.com/ee/api/users.html#for-normal-users
|
152
|
+
def find_by_username!(username)
|
153
|
+
user = find_by_username(username)
|
154
|
+
|
155
|
+
unless user
|
156
|
+
raise NotFoundUserError, "#{username} isn't found"
|
157
|
+
end
|
158
|
+
|
159
|
+
user
|
160
|
+
end
|
161
|
+
|
123
162
|
private
|
124
163
|
|
125
164
|
def system!(command)
|
@@ -168,7 +207,33 @@ module Gitlabci
|
|
168
207
|
end
|
169
208
|
|
170
209
|
def accept_merge_request(mr_id)
|
171
|
-
|
210
|
+
with_retry do
|
211
|
+
@gitlab.accept_merge_request(@project_name, mr_id, merge_when_pipeline_succeeds: true, should_remove_source_branch: true)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def with_retry
|
216
|
+
retry_count ||= 0
|
217
|
+
|
218
|
+
yield
|
219
|
+
rescue Gitlab::Error::MethodNotAllowed => e
|
220
|
+
retry_count += 1
|
221
|
+
|
222
|
+
if retry_count > MAX_RETRY_COUNT
|
223
|
+
raise e
|
224
|
+
end
|
225
|
+
|
226
|
+
puts "Error is occurred and auto retry (#{retry_count}/#{MAX_RETRY_COUNT}): #{e}"
|
227
|
+
sleep 1
|
228
|
+
|
229
|
+
retry
|
230
|
+
end
|
231
|
+
|
232
|
+
def get_assignee_ids(assignees)
|
233
|
+
assignees.map do |username|
|
234
|
+
user = find_by_username!(username)
|
235
|
+
user.id
|
236
|
+
end
|
172
237
|
end
|
173
238
|
end
|
174
239
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlabci-bundle-update-mr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,20 +38,34 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.4.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: git
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.7.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.7.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: gitlab
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: 4.
|
61
|
+
version: 4.14.1
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: 4.
|
68
|
+
version: 4.14.1
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: restore_bundled_with
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,14 +140,14 @@ dependencies:
|
|
126
140
|
name: rake
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
|
-
- - "
|
143
|
+
- - ">="
|
130
144
|
- !ruby/object:Gem::Version
|
131
145
|
version: '10.0'
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
|
-
- - "
|
150
|
+
- - ">="
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '10.0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
@@ -151,7 +165,7 @@ dependencies:
|
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '3.0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
|
-
name: rspec-
|
168
|
+
name: rspec-its
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
171
|
- - ">="
|
@@ -165,7 +179,7 @@ dependencies:
|
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
182
|
+
name: rspec-temp_dir
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
185
|
- - ">="
|
@@ -192,6 +206,20 @@ dependencies:
|
|
192
206
|
- - ">="
|
193
207
|
- !ruby/object:Gem::Version
|
194
208
|
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rubocop-performance
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
195
223
|
- !ruby/object:Gem::Dependency
|
196
224
|
name: simplecov
|
197
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -270,7 +298,7 @@ metadata:
|
|
270
298
|
homepage_uri: https://gitlab.com/sue445/gitlabci-bundle-update-mr
|
271
299
|
source_code_uri: https://gitlab.com/sue445/gitlabci-bundle-update-mr
|
272
300
|
changelog_uri: https://gitlab.com/sue445/gitlabci-bundle-update-mr/blob/master/CHANGELOG.md
|
273
|
-
post_install_message:
|
301
|
+
post_install_message:
|
274
302
|
rdoc_options: []
|
275
303
|
require_paths:
|
276
304
|
- lib
|
@@ -278,15 +306,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
278
306
|
requirements:
|
279
307
|
- - ">="
|
280
308
|
- !ruby/object:Gem::Version
|
281
|
-
version: 2.
|
309
|
+
version: 2.5.0
|
282
310
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
283
311
|
requirements:
|
284
312
|
- - ">="
|
285
313
|
- !ruby/object:Gem::Version
|
286
314
|
version: '0'
|
287
315
|
requirements: []
|
288
|
-
rubygems_version: 3.
|
289
|
-
signing_key:
|
316
|
+
rubygems_version: 3.1.4
|
317
|
+
signing_key:
|
290
318
|
specification_version: 4
|
291
319
|
summary: Create MergeRequest of bundle update in GitLab CI
|
292
320
|
test_files: []
|