gitlabci-bundle-update-mr 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +15 -1
- data/CHANGELOG.md +11 -1
- data/Gemfile.lock +6 -4
- data/README.md +20 -7
- data/exe/gitlabci-bundle-update-mr +4 -2
- data/gitlabci-bundle-update-mr.gemspec +1 -0
- data/lib/gitlabci/bundle/update/mr.rb +2 -0
- data/lib/gitlabci/bundle/update/mr/client.rb +16 -1
- data/lib/gitlabci/bundle/update/mr/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d607680fe4d0fa78918da62e4777d8be1db5421949306682d83602bc538b3516
|
4
|
+
data.tar.gz: 692a716488d0553385164b0b8ad8a3ba78094764e72aad2608d6153aa073c242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fea1ef7556ef71806db573a3205c84689723641c0c9feb9279f0915601d2e0ab76ac8d38367e97335e6de27915bbdcbfbaecf77dd5dfe1a8bb88731d40d95b7
|
7
|
+
data.tar.gz: 735ea90e2f2cb29bf35a17490bbc8a074d13bee45f0de44f5df825a3371070b220569f029b2c140e89ba5902775ae56ffcc599cc7e4397f014d9ceb52263b2e2
|
data/.gitlab-ci.yml
CHANGED
@@ -46,12 +46,26 @@ test:2.6:
|
|
46
46
|
|
47
47
|
image: ruby:2.6
|
48
48
|
|
49
|
+
test:trunk:
|
50
|
+
<<: *test
|
51
|
+
|
52
|
+
image: rubylang/ruby:trunk-nightly-bionic
|
53
|
+
allow_failure: true
|
54
|
+
|
49
55
|
continuous_bundle_update:
|
50
56
|
stage: build
|
51
57
|
|
52
58
|
image: ruby
|
53
59
|
|
60
|
+
cache:
|
61
|
+
key: "$CI_BUILD_NAME"
|
62
|
+
paths:
|
63
|
+
- vendor/bundle/
|
64
|
+
|
54
65
|
before_script:
|
66
|
+
- bundle install --path vendor/bundle
|
67
|
+
- bundle clean
|
68
|
+
|
55
69
|
# Set timezone to Asia/Tokyo
|
56
70
|
- cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
|
57
71
|
|
@@ -61,7 +75,7 @@ continuous_bundle_update:
|
|
61
75
|
|
62
76
|
only:
|
63
77
|
- schedules
|
64
|
-
- web
|
78
|
+
- web # Test for topic branch
|
65
79
|
|
66
80
|
pages:
|
67
81
|
<<: *default
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
## Unreleased
|
2
|
-
[full changelog](https://gitlab.com/sue445/gitlabci-bundle-update-mr/compare/v0.
|
2
|
+
[full changelog](https://gitlab.com/sue445/gitlabci-bundle-update-mr/compare/v0.2.0...HEAD)
|
3
|
+
|
4
|
+
## v0.2.0
|
5
|
+
[full changelog](https://gitlab.com/sue445/gitlabci-bundle-update-mr/compare/v0.1.1...v0.2.0)
|
6
|
+
|
7
|
+
### Features
|
8
|
+
* Don't update `BUNDLED WITH` section when ` budnle update` [!25](https://gitlab.com/sue445/gitlabci-bundle-update-mr/merge_requests/25) *@sue445*
|
9
|
+
|
10
|
+
### Others
|
11
|
+
* Add screenshot [!22](https://gitlab.com/sue445/gitlabci-bundle-update-mr/merge_requests/22) *@sue445*
|
12
|
+
* Refactor continuous_bundle_update job [!23](https://gitlab.com/sue445/gitlabci-bundle-update-mr/merge_requests/23) *@sue445*
|
3
13
|
|
4
14
|
## v0.1.1
|
5
15
|
[full changelog](https://gitlab.com/sue445/gitlabci-bundle-update-mr/compare/v0.1.0...v0.1.1)
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gitlabci-bundle-update-mr (0.
|
4
|
+
gitlabci-bundle-update-mr (0.2.0)
|
5
5
|
bundler
|
6
6
|
compare_linker (>= 1.4.3)
|
7
7
|
gitlab (>= 4.0.0)
|
8
|
+
restore_bundled_with
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
@@ -23,6 +24,7 @@ GEM
|
|
23
24
|
dotenv (2.7.1)
|
24
25
|
faraday (0.15.4)
|
25
26
|
multipart-post (>= 1.2, < 3)
|
27
|
+
git (1.5.0)
|
26
28
|
gitlab (4.10.0)
|
27
29
|
httparty (~> 0.14, >= 0.14.0)
|
28
30
|
terminal-table (~> 1.5, >= 1.5.1)
|
@@ -52,6 +54,9 @@ GEM
|
|
52
54
|
pry (~> 0.10)
|
53
55
|
public_suffix (3.0.3)
|
54
56
|
rake (10.5.0)
|
57
|
+
restore_bundled_with (1.0.0)
|
58
|
+
git
|
59
|
+
thor
|
55
60
|
rspec (3.8.0)
|
56
61
|
rspec-core (~> 3.8.0)
|
57
62
|
rspec-expectations (~> 3.8.0)
|
@@ -103,6 +108,3 @@ DEPENDENCIES
|
|
103
108
|
simplecov
|
104
109
|
webmock
|
105
110
|
yard
|
106
|
-
|
107
|
-
BUNDLED WITH
|
108
|
-
1.17.3
|
data/README.md
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
# Gitlabci::Bundle::Update::Mr
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/gitlabci-bundle-update-mr.svg)](https://badge.fury.io/rb/gitlabci-bundle-update-mr)
|
3
|
+
|
2
4
|
Create MergeRequest of bundle update in GitLab CI
|
3
5
|
|
6
|
+
![gitlabci-bundle-update-mr](img/gitlabci-bundle-update-mr.png)
|
7
|
+
|
4
8
|
This is inspired by [circleci-bundle-update-pr](https://github.com/masutaka/circleci-bundle-update-pr)
|
5
9
|
|
6
|
-
|
10
|
+
## Requirements
|
11
|
+
* GitLab v9.0.0+
|
12
|
+
* GitLab API v4
|
13
|
+
* git
|
7
14
|
|
8
15
|
## Installation
|
9
16
|
```bash
|
@@ -17,7 +24,6 @@ The application on which you want to run continuous bundle update must be config
|
|
17
24
|
### Get GitHub personal access token
|
18
25
|
1. Go to [your account's settings page](https://github.com/settings/tokens/new?description=gitlabci-bundle-update-mr%20token)
|
19
26
|
2. Generate a personal access token with `repo` scope
|
20
|
-
3. Save environment variables as `OCTOKIT_ACCESS_TOKEN` to `https://YOUR-GITLAB/YOUR-NAME/REPO-NAME/settings/ci_cd`
|
21
27
|
|
22
28
|
![github_access_token](img/github_access_token.png)
|
23
29
|
|
@@ -25,12 +31,11 @@ The application on which you want to run continuous bundle update must be config
|
|
25
31
|
1. Go to `https://YOUR-GITLAB/profile/personal_access_tokens`
|
26
32
|
* e.g. https://gitlab.com/profile/personal_access_tokens
|
27
33
|
2. Generate a personal access token with `api` scope
|
28
|
-
3. Save environment variables as `GITLAB_API_PRIVATE_TOKEN` to `https://YOUR-GITLAB/YOUR-NAME/REPO-NAME/settings/ci_cd`
|
29
34
|
|
30
35
|
![gitlab_access_token](img/gitlab_access_token.png)
|
31
36
|
|
32
37
|
### Save CI environment variables
|
33
|
-
1. Go to `https://
|
38
|
+
1. Go to `https://YOUR-GITLAB/YOUR-NAME/REPO-NAME/settings/ci_cd`
|
34
39
|
2. Save environment variables
|
35
40
|
* `GITLAB_API_ENDPOINT` : GitLab API endpoint (e.g. `https://gitlab.com/api/v4`)
|
36
41
|
* `GITLAB_API_PRIVATE_TOKEN` : GitLab personal access token
|
@@ -48,9 +53,17 @@ stages:
|
|
48
53
|
continuous_bundle_update:
|
49
54
|
stage: build
|
50
55
|
|
51
|
-
image:
|
56
|
+
image: ruby
|
57
|
+
|
58
|
+
cache:
|
59
|
+
key: "$CI_BUILD_NAME"
|
60
|
+
paths:
|
61
|
+
- vendor/bundle/
|
52
62
|
|
53
63
|
before_script:
|
64
|
+
- bundle install --path vendor/bundle
|
65
|
+
- bundle clean
|
66
|
+
|
54
67
|
# Set timezone to Asia/Tokyo
|
55
68
|
- cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
|
56
69
|
|
@@ -60,7 +73,6 @@ continuous_bundle_update:
|
|
60
73
|
|
61
74
|
only:
|
62
75
|
- schedules
|
63
|
-
- web
|
64
76
|
```
|
65
77
|
|
66
78
|
And register scheduler to `https://YOUR-GITLAB/YOUR-NAME/REPO-NAME/pipeline_schedules`
|
@@ -73,8 +85,9 @@ $ gitlabci-bundle-update-mr --help
|
|
73
85
|
Usage: gitlabci-bundle-update-mr [options]
|
74
86
|
--email EMAIL git email address (default. `git config user.email`)
|
75
87
|
--user USER git username (default. `git config user.name`)
|
76
|
-
-d, --duplicate Make MR even if it has already existed
|
88
|
+
-d, --duplicate Make MR even if it has already existed (default. false)
|
77
89
|
-l, --labels 'In Review, Update' Add labels to the MR
|
90
|
+
--update-bundled-with Whether to update `BUNDLED WITH` section in Gemfie.lock (default. false)
|
78
91
|
```
|
79
92
|
|
80
93
|
## Development
|
@@ -9,11 +9,13 @@ author_email = `git config user.email`.strip
|
|
9
9
|
author_name = `git config user.name`.strip
|
10
10
|
allow_dup_mr = false
|
11
11
|
mr_labels = []
|
12
|
+
update_bundled_with = false
|
12
13
|
|
13
14
|
opt.on("--email EMAIL", "git email address (default. `git config user.email`)") { |v| author_email = v }
|
14
15
|
opt.on("--user USER", "git username (default. `git config user.name`)") { |v| author_name = v }
|
15
|
-
opt.on("-d", "--duplicate", "Make MR even if it has already existed") { |v| allow_dup_mr = v }
|
16
|
+
opt.on("-d", "--duplicate", "Make MR even if it has already existed (default. false)") { |v| allow_dup_mr = v }
|
16
17
|
opt.on("-l", "--labels 'In Review, Update'", Array, "Add labels to the MR") { |v| mr_labels = v.map(&:strip) }
|
18
|
+
opt.on("--update-bundled-with", "Whether to update `BUNDLED WITH` section in Gemfie.lock (default. false)") { |v| p v }
|
17
19
|
|
18
20
|
opt.parse!(ARGV)
|
19
21
|
|
@@ -28,4 +30,4 @@ client = Gitlabci::Bundle::Update::Mr::Client.new(
|
|
28
30
|
author_name: author_name,
|
29
31
|
)
|
30
32
|
|
31
|
-
client.perform(allow_dup_mr: allow_dup_mr, mr_labels: mr_labels)
|
33
|
+
client.perform(allow_dup_mr: allow_dup_mr, mr_labels: mr_labels, update_bundled_with: update_bundled_with)
|
@@ -41,6 +41,7 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_dependency "bundler"
|
42
42
|
spec.add_dependency "compare_linker", ">= 1.4.3"
|
43
43
|
spec.add_dependency "gitlab", ">= 4.0.0"
|
44
|
+
spec.add_dependency "restore_bundled_with"
|
44
45
|
|
45
46
|
spec.add_development_dependency "dotenv"
|
46
47
|
spec.add_development_dependency "gitlab_awesome_release"
|
@@ -23,7 +23,8 @@ module Gitlabci
|
|
23
23
|
|
24
24
|
# @param allow_dup_mr [Boolean]
|
25
25
|
# @param mr_labels [Array<String>]
|
26
|
-
|
26
|
+
# @param update_bundled_with [Boolean]
|
27
|
+
def perform(allow_dup_mr:, mr_labels:, update_bundled_with:)
|
27
28
|
if !allow_dup_mr && exists_bundle_update_mr?
|
28
29
|
puts "Skip because it has already existed."
|
29
30
|
return
|
@@ -34,6 +35,8 @@ module Gitlabci
|
|
34
35
|
system!("bundle update")
|
35
36
|
system!("bundle update --ruby")
|
36
37
|
|
38
|
+
restore_bundled_with unless update_bundled_with
|
39
|
+
|
37
40
|
new_lockfile = File.read(lockfile_name)
|
38
41
|
|
39
42
|
if old_lockfile == new_lockfile
|
@@ -90,6 +93,8 @@ module Gitlabci
|
|
90
93
|
|
91
94
|
# @param old_lockfile [String]
|
92
95
|
# @param new_lockfile [String]
|
96
|
+
#
|
97
|
+
# @return [String]
|
93
98
|
def merge_request_description(old_lockfile, new_lockfile)
|
94
99
|
compare_linker = CompareLinker.new("dummy", "dummy")
|
95
100
|
compare_linker.formatter = CompareLinker::Formatter::Markdown.new
|
@@ -114,6 +119,16 @@ module Gitlabci
|
|
114
119
|
raise "`#{command}` is failed" unless ret
|
115
120
|
end
|
116
121
|
|
122
|
+
def restore_bundled_with
|
123
|
+
RestoreBundledWith::CLI.new.invoke(
|
124
|
+
:restore,
|
125
|
+
[],
|
126
|
+
{
|
127
|
+
lockfile: lockfile_name,
|
128
|
+
},
|
129
|
+
)
|
130
|
+
end
|
131
|
+
|
117
132
|
def gemfile_name
|
118
133
|
return @gemfile_name if @gemfile_name
|
119
134
|
|
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: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 4.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: restore_bundled_with
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: dotenv
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|