circleci-bundle-update-pr 1.16.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +104 -110
- data/.rubocop.yml +8 -1
- data/.rubocop_todo.yml +1 -1
- data/Gemfile.lock +52 -41
- data/README.md +50 -1
- data/circleci-bundle-update-pr.gemspec +4 -1
- data/lib/circleci/bundle/update/pr.rb +54 -14
- data/lib/circleci/bundle/update/pr/version.rb +1 -1
- data/spec/circleci/bundle/update/pr_spec.rb +61 -0
- metadata +25 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4064052a0e9c870a53a20a780e08b6029a425ae39412427e3e2131caca05769f
|
4
|
+
data.tar.gz: 67c9498808dd3310240116f173b365e76e4336540458f334f4609d9e5a1373e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d69e9d58356f09fa2609030b13182475f9b92d438064983244253895cb56af5b8c7dee2a25b6e2fc438fbba38ca34ead4b297b5d65315859ef714e77de1dbda
|
7
|
+
data.tar.gz: 46e99f5fab63cd2c3a6d3e7a3965341e060aead0e971b7d4ae10950e91b6e8a8f7e28f85ddbbb18ae5cc8868570e6b3566dd84e9cb964fcf1ff3571634878582
|
data/.circleci/config.yml
CHANGED
@@ -1,139 +1,133 @@
|
|
1
|
-
version: 2
|
1
|
+
version: 2.1
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
name: Install System Dependencies
|
6
|
-
command: |
|
7
|
-
# See also https://circleci.com/docs/2.0/custom-images/#adding-required-and-custom-tools-or-files
|
8
|
-
apk add --update --no-cache --no-progress git openssh-client tar gzip ca-certificates \
|
9
|
-
build-base tzdata
|
10
|
-
- &set_timezone
|
11
|
-
name: Set timezone to Asia/Tokyo
|
12
|
-
command: cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
|
13
|
-
- &bundle_install
|
14
|
-
name: Install Ruby Dependencies
|
15
|
-
command: |
|
16
|
-
bundle check || bundle install --jobs=4 --retry=3
|
17
|
-
bundle clean
|
18
|
-
- &rubocop
|
19
|
-
name: Run RuboCop
|
20
|
-
command: rubocop
|
21
|
-
- &rspec
|
22
|
-
name: Run RSpec
|
23
|
-
command: rspec
|
3
|
+
orbs:
|
4
|
+
pushover: masutaka/pushover@dev:beta5
|
24
5
|
|
25
|
-
|
26
|
-
|
6
|
+
executors:
|
7
|
+
default:
|
8
|
+
parameters:
|
9
|
+
ruby_version:
|
10
|
+
type: enum
|
11
|
+
enum: ['2.4', '2.5', '2.6', '2.7', '3.0']
|
27
12
|
docker:
|
28
|
-
|
29
|
-
working_directory:
|
13
|
+
- image: cimg/ruby:<< parameters.ruby_version >>
|
14
|
+
working_directory: ~/repo
|
15
|
+
|
16
|
+
commands:
|
17
|
+
notify_on_failure_on_default_branch:
|
30
18
|
steps:
|
31
|
-
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
- gems-ruby2.3-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
|
38
|
-
- gems-ruby2.3-{{ .Environment.COMMON_CACHE_KEY }}-
|
39
|
-
- run: *bundle_install
|
40
|
-
- save_cache:
|
41
|
-
name: Save bundler cache
|
42
|
-
key: gems-ruby2.3-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
|
43
|
-
paths:
|
44
|
-
- /usr/local/bundle
|
45
|
-
- run: *rubocop
|
46
|
-
- run: *rspec
|
47
|
-
build_on_ruby2_4:
|
48
|
-
docker:
|
49
|
-
- image: ruby:2.4-alpine
|
50
|
-
working_directory: /work
|
19
|
+
- pushover/notify-on-failure:
|
20
|
+
title: "Failed: ${CIRCLE_PROJECT_REPONAME}'s job (${CIRCLE_JOB})"
|
21
|
+
message: "failed ${CIRCLE_USERNAME:Bot}'s build (#${CIRCLE_BUILD_NUM}) in ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} (${CIRCLE_BRANCH})"
|
22
|
+
priority: 1 # high
|
23
|
+
only_for_branches: master
|
24
|
+
setup_requirements:
|
51
25
|
steps:
|
52
|
-
- run:
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
- run: *rubocop
|
67
|
-
- run: *rspec
|
68
|
-
build_on_ruby2_5:
|
69
|
-
docker:
|
70
|
-
- image: ruby:2.5-alpine
|
71
|
-
working_directory: /work
|
26
|
+
- run:
|
27
|
+
name: Install System Dependencies
|
28
|
+
command: |
|
29
|
+
# for cimg/ruby:2.4
|
30
|
+
sudo apt update -q
|
31
|
+
sudo apt install -q tzdata
|
32
|
+
- run:
|
33
|
+
name: Set timezone to Asia/Tokyo
|
34
|
+
command: sudo cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
|
35
|
+
restore_bundle_cache:
|
36
|
+
parameters:
|
37
|
+
ruby_version:
|
38
|
+
type: enum
|
39
|
+
enum: ['2.4', '2.5', '2.6', '2.7', '3.0']
|
72
40
|
steps:
|
73
|
-
- run: *setup_requirements
|
74
|
-
- run: *set_timezone
|
75
|
-
- checkout
|
76
41
|
- restore_cache:
|
77
|
-
name: Restore
|
42
|
+
name: Restore bundle cache
|
78
43
|
keys:
|
79
|
-
- gems-
|
80
|
-
- gems-
|
81
|
-
|
44
|
+
- gems-ruby<< parameters.ruby_version >>-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
|
45
|
+
- gems-ruby<< parameters.ruby_version >>-{{ .Environment.COMMON_CACHE_KEY }}-
|
46
|
+
save_bundle_cache:
|
47
|
+
parameters:
|
48
|
+
ruby_version:
|
49
|
+
type: enum
|
50
|
+
enum: ['2.4', '2.5', '2.6', '2.7', '3.0']
|
51
|
+
steps:
|
82
52
|
- save_cache:
|
83
|
-
name: Save
|
84
|
-
key: gems-
|
53
|
+
name: Save bundle cache
|
54
|
+
key: gems-ruby<< parameters.ruby_version >>-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
|
85
55
|
paths:
|
86
|
-
- /
|
87
|
-
|
88
|
-
- run: *rspec
|
89
|
-
build_on_ruby2_6:
|
90
|
-
docker: &docker_ruby2_6
|
91
|
-
- image: ruby:2.6-alpine
|
92
|
-
working_directory: /work
|
56
|
+
- ~/repo/vendor/bundle
|
57
|
+
install_bundler:
|
93
58
|
steps:
|
94
|
-
- run:
|
95
|
-
|
59
|
+
- run:
|
60
|
+
name: install bundler
|
61
|
+
command: gem install -N bundler:1.17.3 # same version as Gemfile.lock
|
62
|
+
|
63
|
+
jobs:
|
64
|
+
build:
|
65
|
+
parameters:
|
66
|
+
ruby_version:
|
67
|
+
type: enum
|
68
|
+
enum: ['2.4', '2.5', '2.6', '2.7', '3.0']
|
69
|
+
executor:
|
70
|
+
name: default
|
71
|
+
ruby_version: << parameters.ruby_version >>
|
72
|
+
steps:
|
73
|
+
- setup_requirements
|
96
74
|
- checkout
|
97
|
-
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
- run:
|
109
|
-
-
|
75
|
+
- restore_bundle_cache:
|
76
|
+
ruby_version: << parameters.ruby_version >>
|
77
|
+
- install_bundler
|
78
|
+
- run:
|
79
|
+
name: bundle install
|
80
|
+
command: |
|
81
|
+
bundle check || bundle install --jobs=4 --retry=3 --path=vendor/bundle
|
82
|
+
bundle clean
|
83
|
+
- save_bundle_cache:
|
84
|
+
ruby_version: << parameters.ruby_version >>
|
85
|
+
- run: bundle exec rubocop
|
86
|
+
- run: bundle exec rspec
|
87
|
+
- notify_on_failure_on_default_branch
|
110
88
|
continuous_bundle_update:
|
111
|
-
|
112
|
-
|
89
|
+
executor:
|
90
|
+
name: default
|
91
|
+
ruby_version: '3.0'
|
113
92
|
steps:
|
114
|
-
-
|
115
|
-
- run: *set_timezone
|
93
|
+
- setup_requirements
|
116
94
|
- checkout
|
117
|
-
-
|
95
|
+
- restore_bundle_cache:
|
96
|
+
ruby_version: '3.0'
|
97
|
+
- install_bundler
|
118
98
|
- run:
|
119
|
-
name:
|
120
|
-
command:
|
99
|
+
name: Install edge circleci-bundle-update-pr
|
100
|
+
command: |
|
101
|
+
gem install -N specific_install
|
102
|
+
gem specific_install https://github.com/masutaka/circleci-bundle-update-pr.git
|
121
103
|
- deploy:
|
122
|
-
name:
|
104
|
+
name: Run circleci-bundle-update-pr
|
123
105
|
command: circleci-bundle-update-pr CircleCI circleci@example.com $CIRCLE_BRANCH
|
106
|
+
- notify_on_failure_on_default_branch
|
124
107
|
|
125
108
|
workflows:
|
126
109
|
version: 2
|
127
110
|
ordinary:
|
128
111
|
jobs:
|
129
|
-
-
|
130
|
-
|
131
|
-
|
132
|
-
-
|
112
|
+
- build:
|
113
|
+
name: ruby-2.4
|
114
|
+
ruby_version: '2.4'
|
115
|
+
- build:
|
116
|
+
name: ruby-2.5
|
117
|
+
ruby_version: '2.5'
|
118
|
+
- build:
|
119
|
+
name: ruby-2.6
|
120
|
+
ruby_version: '2.6'
|
121
|
+
- build:
|
122
|
+
name: ruby-2.7
|
123
|
+
ruby_version: '2.7'
|
124
|
+
- build:
|
125
|
+
name: ruby-3.0
|
126
|
+
ruby_version: '3.0'
|
133
127
|
nightly:
|
134
128
|
triggers:
|
135
129
|
- schedule:
|
136
|
-
cron: "00 10 * *
|
130
|
+
cron: "00 10 * * 2"
|
137
131
|
filters:
|
138
132
|
branches:
|
139
133
|
only: master
|
data/.rubocop.yml
CHANGED
@@ -3,7 +3,11 @@ require: rubocop-rspec
|
|
3
3
|
|
4
4
|
AllCops:
|
5
5
|
DisplayCopNames: true
|
6
|
-
|
6
|
+
NewCops: enable
|
7
|
+
TargetRubyVersion: 2.4
|
8
|
+
|
9
|
+
Layout/LineLength:
|
10
|
+
Enabled: false
|
7
11
|
|
8
12
|
Metrics:
|
9
13
|
Enabled: false
|
@@ -11,6 +15,9 @@ Metrics:
|
|
11
15
|
RSpec/DescribedClass:
|
12
16
|
Enabled: false
|
13
17
|
|
18
|
+
RSpec/NamedSubject:
|
19
|
+
Enabled: false
|
20
|
+
|
14
21
|
Style/BlockComments:
|
15
22
|
Exclude:
|
16
23
|
- 'spec/spec_helper.rb'
|
data/.rubocop_todo.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,76 +1,87 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
circleci-bundle-update-pr (1.
|
4
|
+
circleci-bundle-update-pr (2.1.0)
|
5
5
|
compare_linker (>= 1.4.0)
|
6
6
|
octokit
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
addressable (2.
|
12
|
-
public_suffix (>= 2.0.2, <
|
13
|
-
ast (2.4.
|
14
|
-
compare_linker (1.4.
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
ast (2.4.1)
|
14
|
+
compare_linker (1.4.4)
|
15
15
|
httpclient
|
16
16
|
octokit
|
17
|
-
diff-lcs (1.
|
18
|
-
faraday (
|
17
|
+
diff-lcs (1.4.4)
|
18
|
+
faraday (1.3.0)
|
19
|
+
faraday-net_http (~> 1.0)
|
19
20
|
multipart-post (>= 1.2, < 3)
|
21
|
+
ruby2_keywords
|
22
|
+
faraday-net_http (1.0.0)
|
20
23
|
httpclient (2.8.3)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
multipart-post (2.1.1)
|
25
|
+
octokit (4.20.0)
|
26
|
+
faraday (>= 0.9)
|
24
27
|
sawyer (~> 0.8.0, >= 0.5.3)
|
25
|
-
parallel (1.
|
26
|
-
parser (
|
27
|
-
ast (~> 2.4.
|
28
|
-
|
29
|
-
public_suffix (3.0.3)
|
28
|
+
parallel (1.19.2)
|
29
|
+
parser (3.0.0.0)
|
30
|
+
ast (~> 2.4.1)
|
31
|
+
public_suffix (4.0.6)
|
30
32
|
rainbow (3.0.0)
|
31
|
-
rake (
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
rspec-
|
36
|
-
|
37
|
-
rspec-
|
38
|
-
rspec-
|
33
|
+
rake (13.0.3)
|
34
|
+
regexp_parser (2.0.3)
|
35
|
+
rexml (3.2.4)
|
36
|
+
rspec (3.10.0)
|
37
|
+
rspec-core (~> 3.10.0)
|
38
|
+
rspec-expectations (~> 3.10.0)
|
39
|
+
rspec-mocks (~> 3.10.0)
|
40
|
+
rspec-core (3.10.1)
|
41
|
+
rspec-support (~> 3.10.0)
|
42
|
+
rspec-expectations (3.10.1)
|
39
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-mocks (3.
|
44
|
+
rspec-support (~> 3.10.0)
|
45
|
+
rspec-mocks (3.10.1)
|
42
46
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-support (3.
|
45
|
-
rubocop (
|
46
|
-
jaro_winkler (~> 1.5.1)
|
47
|
+
rspec-support (~> 3.10.0)
|
48
|
+
rspec-support (3.10.1)
|
49
|
+
rubocop (1.8.1)
|
47
50
|
parallel (~> 1.10)
|
48
|
-
parser (>=
|
49
|
-
psych (>= 3.1.0)
|
51
|
+
parser (>= 3.0.0.0)
|
50
52
|
rainbow (>= 2.2.2, < 4.0)
|
53
|
+
regexp_parser (>= 1.8, < 3.0)
|
54
|
+
rexml
|
55
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
51
56
|
ruby-progressbar (~> 1.7)
|
52
|
-
unicode-display_width (>= 1.4.0, <
|
53
|
-
rubocop-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
58
|
+
rubocop-ast (1.4.0)
|
59
|
+
parser (>= 2.7.1.5)
|
60
|
+
rubocop-rspec (2.1.0)
|
61
|
+
rubocop (~> 1.0)
|
62
|
+
rubocop-ast (>= 1.1.0)
|
63
|
+
ruby-progressbar (1.11.0)
|
64
|
+
ruby2_keywords (0.0.2)
|
65
|
+
sawyer (0.8.2)
|
66
|
+
addressable (>= 2.3.5)
|
67
|
+
faraday (> 0.8, < 2.0)
|
68
|
+
unicode-display_width (2.0.0)
|
60
69
|
|
61
70
|
PLATFORMS
|
62
71
|
ruby
|
63
72
|
x86_64-darwin-16
|
64
73
|
x86_64-darwin-17
|
65
74
|
x86_64-darwin-18
|
75
|
+
x86_64-darwin-19
|
66
76
|
|
67
77
|
DEPENDENCIES
|
68
78
|
bundler
|
69
79
|
circleci-bundle-update-pr!
|
80
|
+
parallel (< 1.20.0)
|
70
81
|
rake
|
71
|
-
rspec
|
82
|
+
rspec
|
72
83
|
rubocop
|
73
84
|
rubocop-rspec
|
74
85
|
|
75
86
|
BUNDLED WITH
|
76
|
-
1.17.
|
87
|
+
1.17.3
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ jobs:
|
|
52
52
|
- run:
|
53
53
|
name: Install System Dependencies
|
54
54
|
command: |
|
55
|
-
# See also https://circleci.com/docs/2.0/custom-images/#
|
55
|
+
# See also https://circleci.com/docs/2.0/custom-images/#required-tools-for-primary-containers
|
56
56
|
apk add --update --no-cache git openssh-client tar gzip ca-certificates \
|
57
57
|
tzdata
|
58
58
|
gem install -N bundler
|
@@ -153,6 +153,55 @@ Powered by [circleci-bundle-update-pr](https://rubygems.org/gems/circleci-bundle
|
|
153
153
|
|
154
154
|
`.circleci/BUNDLE_UPDATE_NOTE.md` or `CIRCLECI_BUNDLE_UPDATE_NOTE.md`, either one is OK. It gives priority `.circleci/BUNDLE_UPDATE_NOTE.md` over `CIRCLECI_BUNDLE_UPDATE_NOTE.md`.
|
155
155
|
|
156
|
+
### Run on GitHub Actions
|
157
|
+
Configure your `.github/workflows/bundle-update-pr.yml` to run circleci-bundle-update-pr, for example:
|
158
|
+
|
159
|
+
```yaml
|
160
|
+
name: bundle-update-pr
|
161
|
+
|
162
|
+
on:
|
163
|
+
schedule:
|
164
|
+
- cron: "00 10 * * 5" # JST 19:00 (Fri)
|
165
|
+
|
166
|
+
jobs:
|
167
|
+
build:
|
168
|
+
runs-on: ubuntu-latest
|
169
|
+
|
170
|
+
steps:
|
171
|
+
- uses: actions/checkout@v1
|
172
|
+
|
173
|
+
- name: Set up Ruby
|
174
|
+
uses: actions/setup-ruby@v1
|
175
|
+
with:
|
176
|
+
ruby-version: v2.6.x
|
177
|
+
|
178
|
+
- name: Install dependencies
|
179
|
+
run: |
|
180
|
+
set -x
|
181
|
+
gem install -N bundler circleci-bundle-update-pr
|
182
|
+
|
183
|
+
- name: Set timezone to Asia/Tokyo
|
184
|
+
run: |
|
185
|
+
set -x
|
186
|
+
cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
|
187
|
+
|
188
|
+
- name: run circleci-bundle-update-pr
|
189
|
+
run: |
|
190
|
+
set -x
|
191
|
+
|
192
|
+
export CIRCLE_BRANCH=$(echo $GITHUB_REF | sed -e 's!refs/heads/!!g')
|
193
|
+
export CIRCLE_PROJECT_USERNAME=$(echo $GITHUB_REPOSITORY | cut -d "/" -f 1)
|
194
|
+
export CIRCLE_PROJECT_REPONAME=$(echo $GITHUB_REPOSITORY | cut -d "/" -f 2)
|
195
|
+
|
196
|
+
git checkout -b $CIRCLE_BRANCH
|
197
|
+
|
198
|
+
circleci-bundle-update-pr "${GIT_USER_NAME}" "${GIT_USER_EMAIL}"
|
199
|
+
env:
|
200
|
+
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
201
|
+
GIT_USER_NAME: "your name"
|
202
|
+
GIT_USER_EMAIL: "ci@example.com"
|
203
|
+
```
|
204
|
+
|
156
205
|
## Contributing
|
157
206
|
|
158
207
|
1. Fork it ( https://github.com/masutaka/circleci-bundle-update-pr/fork )
|
@@ -19,12 +19,15 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
+
spec.required_ruby_version = '>= 2.4.0'
|
23
|
+
|
22
24
|
spec.add_dependency 'compare_linker', '>= 1.4.0'
|
23
25
|
spec.add_dependency 'octokit'
|
24
26
|
|
25
27
|
spec.add_development_dependency 'bundler'
|
28
|
+
spec.add_development_dependency 'parallel', '< 1.20.0' # parallel-1.20.0 requires ruby version >= 2.5, which used by rubocop
|
26
29
|
spec.add_development_dependency 'rake'
|
27
|
-
spec.add_development_dependency 'rspec'
|
30
|
+
spec.add_development_dependency 'rspec'
|
28
31
|
spec.add_development_dependency 'rubocop'
|
29
32
|
spec.add_development_dependency 'rubocop-rspec'
|
30
33
|
end
|
@@ -88,11 +88,15 @@ module Circleci
|
|
88
88
|
#
|
89
89
|
# @return [Boolean]
|
90
90
|
def self.need_to_commit?
|
91
|
+
old_lockfile = File.read('Gemfile.lock')
|
92
|
+
|
91
93
|
unless system('bundle update && bundle update --ruby')
|
92
94
|
raise 'Unable to execute `bundle update && bundle update --ruby`'
|
93
95
|
end
|
94
96
|
|
95
|
-
|
97
|
+
new_lockfile = File.read('Gemfile.lock')
|
98
|
+
|
99
|
+
old_lockfile != new_lockfile
|
96
100
|
end
|
97
101
|
private_class_method :need_to_commit?
|
98
102
|
|
@@ -101,14 +105,42 @@ module Circleci
|
|
101
105
|
# @return [String] remote branch name. e.g. bundle-update-20180929154455
|
102
106
|
def self.create_branch(git_username, git_email)
|
103
107
|
branch = "#{BRANCH_PREFIX}#{now.strftime('%Y%m%d%H%M%S')}"
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
108
|
+
|
109
|
+
current_ref = client.ref(repo_full_name, "heads/#{ENV['CIRCLE_BRANCH']}")
|
110
|
+
branch_ref = client.create_ref(repo_full_name, "heads/#{branch}", current_ref.object.sha)
|
111
|
+
|
112
|
+
branch_commit = client.commit(repo_full_name, branch_ref.object.sha)
|
113
|
+
|
114
|
+
lockfile = File.read('Gemfile.lock')
|
115
|
+
lockfile_blob_sha = client.create_blob(repo_full_name, lockfile)
|
116
|
+
tree = client.create_tree(
|
117
|
+
repo_full_name,
|
118
|
+
[
|
119
|
+
{
|
120
|
+
path: lockfile_path,
|
121
|
+
mode: '100644',
|
122
|
+
type: 'blob',
|
123
|
+
sha: lockfile_blob_sha
|
124
|
+
}
|
125
|
+
],
|
126
|
+
base_tree: branch_commit.commit.tree.sha
|
127
|
+
)
|
128
|
+
|
129
|
+
commit = client.create_commit(
|
130
|
+
repo_full_name,
|
131
|
+
'$ bundle update && bundle update --ruby',
|
132
|
+
tree.sha,
|
133
|
+
branch_ref.object.sha,
|
134
|
+
author: {
|
135
|
+
name: git_username,
|
136
|
+
email: git_email
|
137
|
+
}
|
138
|
+
)
|
139
|
+
|
140
|
+
client.update_ref(repo_full_name, "heads/#{branch}", commit.sha)
|
141
|
+
|
142
|
+
puts "#{branch} is created"
|
143
|
+
|
112
144
|
branch
|
113
145
|
end
|
114
146
|
private_class_method :create_branch
|
@@ -179,11 +211,6 @@ Powered by [circleci-bundle-update-pr](https://rubygems.org/gems/circleci-bundle
|
|
179
211
|
end
|
180
212
|
private_class_method :enterprise?
|
181
213
|
|
182
|
-
def self.github_access_token
|
183
|
-
enterprise? ? ENV['ENTERPRISE_OCTOKIT_ACCESS_TOKEN'] : ENV['GITHUB_ACCESS_TOKEN']
|
184
|
-
end
|
185
|
-
private_class_method :github_access_token
|
186
|
-
|
187
214
|
# Get repository full name
|
188
215
|
#
|
189
216
|
# @return [String] e.g. 'masutaka/circleci-bundle-update-pr'
|
@@ -209,6 +236,19 @@ Powered by [circleci-bundle-update-pr](https://rubygems.org/gems/circleci-bundle
|
|
209
236
|
@now ||= Time.now
|
210
237
|
end
|
211
238
|
private_class_method :now
|
239
|
+
|
240
|
+
# Get Gemfile.lock path relative to workdir
|
241
|
+
#
|
242
|
+
# @return [String]
|
243
|
+
def self.lockfile_path
|
244
|
+
workdir_env = ENV['CIRCLE_WORKING_DIRECTORY']
|
245
|
+
return 'Gemfile.lock' unless workdir_env
|
246
|
+
|
247
|
+
workdir = Pathname.new(workdir_env).expand_path
|
248
|
+
gemfile_lock = Pathname.new(File.expand_path('Gemfile.lock'))
|
249
|
+
gemfile_lock.relative_path_from(workdir).to_s
|
250
|
+
end
|
251
|
+
private_class_method :lockfile_path
|
212
252
|
end
|
213
253
|
end
|
214
254
|
end
|
@@ -52,4 +52,65 @@ describe Circleci::Bundle::Update::Pr do
|
|
52
52
|
it { is_expected.to be_falsy }
|
53
53
|
end
|
54
54
|
end
|
55
|
+
|
56
|
+
describe '.lockfile_path' do
|
57
|
+
subject { Circleci::Bundle::Update::Pr.send(:lockfile_path) }
|
58
|
+
|
59
|
+
let(:workdir_env) { Dir.getwd }
|
60
|
+
|
61
|
+
around do |e|
|
62
|
+
ENV['CIRCLE_WORKING_DIRECTORY'] = workdir_env
|
63
|
+
e.run
|
64
|
+
ENV['CIRCLE_WORKING_DIRECTORY'] = nil
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when Gemfile.lock is in the working dir' do
|
68
|
+
it { is_expected.to eq 'Gemfile.lock' }
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when ENV['CIRCLE_WORKING_DIRECTORY'] is not set" do
|
72
|
+
let(:workdir_env) { nil }
|
73
|
+
|
74
|
+
it { is_expected.to eq 'Gemfile.lock' }
|
75
|
+
end
|
76
|
+
|
77
|
+
context "when ENV['CIRCLE_WORKING_DIRECTORY'] is relative path" do
|
78
|
+
let(:workdir_env) do
|
79
|
+
project_dir = Pathname.getwd.to_s
|
80
|
+
home_dir = Pathname.new(ENV['HOME']).to_s
|
81
|
+
project_dir.sub(home_dir, '~')
|
82
|
+
end
|
83
|
+
let(:src_dir) { 'spec/tmp' }
|
84
|
+
|
85
|
+
around do |e|
|
86
|
+
FileUtils.mkdir_p(src_dir)
|
87
|
+
FileUtils.touch("#{src_dir}/Gemfile.lock")
|
88
|
+
e.run
|
89
|
+
FileUtils.rm_rf(src_dir)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'is "spec/tmp/Gemfile.lock"' do
|
93
|
+
Dir.chdir(src_dir) do
|
94
|
+
expect(subject).to eq 'spec/tmp/Gemfile.lock'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'when Gemfile.lock is in a nested dir' do
|
100
|
+
let(:src_dir) { 'spec/tmp' }
|
101
|
+
|
102
|
+
around do |e|
|
103
|
+
FileUtils.mkdir_p(src_dir)
|
104
|
+
FileUtils.touch("#{src_dir}/Gemfile.lock")
|
105
|
+
e.run
|
106
|
+
FileUtils.rm_rf(src_dir)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'is "spec/tmp/Gemfile.lock"' do
|
110
|
+
Dir.chdir(src_dir) do
|
111
|
+
expect(subject).to eq 'spec/tmp/Gemfile.lock'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
55
116
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: circleci-bundle-update-pr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Masuda
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: compare_linker
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: parallel
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "<"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.20.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "<"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.20.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,16 +84,16 @@ dependencies:
|
|
70
84
|
name: rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - "
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - "
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rubocop
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,7 +152,7 @@ homepage: https://github.com/masutaka/circleci-bundle-update-pr
|
|
138
152
|
licenses:
|
139
153
|
- MIT
|
140
154
|
metadata: {}
|
141
|
-
post_install_message:
|
155
|
+
post_install_message:
|
142
156
|
rdoc_options: []
|
143
157
|
require_paths:
|
144
158
|
- lib
|
@@ -146,15 +160,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
160
|
requirements:
|
147
161
|
- - ">="
|
148
162
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
163
|
+
version: 2.4.0
|
150
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
165
|
requirements:
|
152
166
|
- - ">="
|
153
167
|
- !ruby/object:Gem::Version
|
154
168
|
version: '0'
|
155
169
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
157
|
-
signing_key:
|
170
|
+
rubygems_version: 3.2.3
|
171
|
+
signing_key:
|
158
172
|
specification_version: 4
|
159
173
|
summary: Provide continues bundle update using CircleCI
|
160
174
|
test_files:
|