circleci-bundle-update-pr 1.16.0 → 2.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fbe8bbe94a5d748796b73ddf80bcfc9df4a1cd83478a31e056275a95e6f1f37
4
- data.tar.gz: 1cbe85ff25928c0503a974f03ae11d7f0332e675d5f93b0434cc53dd63a863c1
3
+ metadata.gz: ca0f586fe71477f8f9e4e1ea9d7a5459283b63cccfbb51dc38406a48ea0a543a
4
+ data.tar.gz: 324a4619c170a0cfdb495d503eef5a178742c736f4304c8e298ceb20a8456952
5
5
  SHA512:
6
- metadata.gz: 64873c5e921eb91012104d263751f1c3ab12239d83595278d2c227e7a7abf07f04d3ca698a2fbee32f4ad301ad44c43b3fc64b18d0a1a15dbcf5bb31db9cb3f1
7
- data.tar.gz: e90fa41fd9d91e056aad2f61abe0949c3b70e8d82dad95c8db73a0119009cfd508f7b8eb829a62692d2023a17ee6f961c18594af3ee8f0b0b03c6117e526f6c3
6
+ metadata.gz: 2a7514514afd1cc031b42efb488b5db935e64aa52294c5695dc2aa6f61ed4a56dde6bc3af7fe9cd9b36154954289320ebd60086c513d503eed6c3794ac436c93
7
+ data.tar.gz: 133c87fe7015b10c71acf4b0f53e94ed16ad4b79223f308f4063af4a86e06cdc53ffe190fcab3489ce2a0e73375055282e4d2fe3ace1ed5620c2bbcdf9d13238
@@ -1,139 +1,131 @@
1
- version: 2
1
+ version: 2.1
2
2
 
3
- references:
4
- - &setup_requirements
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:beta3
24
5
 
25
- jobs:
26
- build_on_ruby2_3:
6
+ executors:
7
+ default:
8
+ parameters:
9
+ ruby_version:
10
+ type: enum
11
+ enum: ['2.4', '2.5', '2.6', '2.7']
27
12
  docker:
28
- - image: ruby:2.3-alpine
29
- working_directory: /work
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
- - run: *setup_requirements
32
- - run: *set_timezone
33
- - checkout
34
- - restore_cache:
35
- name: Restore bundler cache
36
- keys:
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:
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
+ fail_only: true
24
+ only_for_branches: master
25
+ setup_requirements:
51
26
  steps:
52
- - run: *setup_requirements
53
- - run: *set_timezone
54
- - checkout
55
- - restore_cache:
56
- name: Restore bundler cache
57
- keys:
58
- - gems-ruby2.4-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
59
- - gems-ruby2.4-{{ .Environment.COMMON_CACHE_KEY }}-
60
- - run: *bundle_install
61
- - save_cache:
62
- name: Save bundler cache
63
- key: gems-ruby2.4-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
64
- paths:
65
- - /usr/local/bundle
66
- - run: *rubocop
67
- - run: *rspec
68
- build_on_ruby2_5:
69
- docker:
70
- - image: ruby:2.5-alpine
71
- working_directory: /work
27
+ - run:
28
+ name: Install System Dependencies
29
+ command: |
30
+ # for cimg/ruby:2.4
31
+ sudo apt update -q
32
+ sudo apt install -q tzdata
33
+ - run:
34
+ name: Set timezone to Asia/Tokyo
35
+ command: sudo cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
36
+ restore_bundle_cache:
37
+ parameters:
38
+ ruby_version:
39
+ type: enum
40
+ enum: ['2.4', '2.5', '2.6', '2.7']
72
41
  steps:
73
- - run: *setup_requirements
74
- - run: *set_timezone
75
- - checkout
76
42
  - restore_cache:
77
- name: Restore bundler cache
43
+ name: Restore bundle cache
78
44
  keys:
79
- - gems-ruby2.5-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
80
- - gems-ruby2.5-{{ .Environment.COMMON_CACHE_KEY }}-
81
- - run: *bundle_install
45
+ - gems-ruby<< parameters.ruby_version >>-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
46
+ - gems-ruby<< parameters.ruby_version >>-{{ .Environment.COMMON_CACHE_KEY }}-
47
+ save_bundle_cache:
48
+ parameters:
49
+ ruby_version:
50
+ type: enum
51
+ enum: ['2.4', '2.5', '2.6', '2.7']
52
+ steps:
82
53
  - save_cache:
83
- name: Save bundler cache
84
- key: gems-ruby2.5-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
54
+ name: Save bundle cache
55
+ key: gems-ruby<< parameters.ruby_version >>-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
85
56
  paths:
86
- - /usr/local/bundle
87
- - run: *rubocop
88
- - run: *rspec
89
- build_on_ruby2_6:
90
- docker: &docker_ruby2_6
91
- - image: ruby:2.6-alpine
92
- working_directory: /work
57
+ - ~/repo/vendor/bundle
58
+ install_bundler:
93
59
  steps:
94
- - run: *setup_requirements
95
- - run: *set_timezone
60
+ - run:
61
+ name: install bundler
62
+ command: gem install -N bundler:1.17.3 # same version as Gemfile.lock
63
+
64
+ jobs:
65
+ build:
66
+ parameters:
67
+ ruby_version:
68
+ type: enum
69
+ enum: ['2.4', '2.5', '2.6', '2.7']
70
+ executor:
71
+ name: default
72
+ ruby_version: << parameters.ruby_version >>
73
+ steps:
74
+ - setup_requirements
96
75
  - checkout
97
- - restore_cache: &restore_cache_ruby2_6
98
- name: Restore bundler cache
99
- keys:
100
- - gems-ruby2.6-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
101
- - gems-ruby2.6-{{ .Environment.COMMON_CACHE_KEY }}-
102
- - run: *bundle_install
103
- - save_cache:
104
- name: Save bundler cache
105
- key: gems-ruby2.6-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
106
- paths:
107
- - /usr/local/bundle
108
- - run: *rubocop
109
- - run: *rspec
76
+ - restore_bundle_cache:
77
+ ruby_version: << parameters.ruby_version >>
78
+ - install_bundler
79
+ - run:
80
+ name: bundle install
81
+ command: |
82
+ bundle check || bundle install --jobs=4 --retry=3 --path=vendor/bundle
83
+ bundle clean
84
+ - save_bundle_cache:
85
+ ruby_version: << parameters.ruby_version >>
86
+ - run: bundle exec rubocop
87
+ - run: bundle exec rspec
88
+ - notify_on_failure_on_default_branch
110
89
  continuous_bundle_update:
111
- docker: *docker_ruby2_6
112
- working_directory: /work
90
+ executor:
91
+ name: default
92
+ ruby_version: '2.7'
113
93
  steps:
114
- - run: *setup_requirements
115
- - run: *set_timezone
94
+ - setup_requirements
116
95
  - checkout
117
- - restore_cache: *restore_cache_ruby2_6
96
+ - restore_bundle_cache:
97
+ ruby_version: '2.7'
98
+ - install_bundler
118
99
  - run:
119
- name: Setup requirements for continuous bundle update
120
- command: gem install -N circleci-bundle-update-pr
100
+ name: Install edge circleci-bundle-update-pr
101
+ command: |
102
+ gem install -N specific_install
103
+ gem specific_install https://github.com/masutaka/circleci-bundle-update-pr.git
121
104
  - deploy:
122
- name: Continuous bundle update
105
+ name: Run circleci-bundle-update-pr
123
106
  command: circleci-bundle-update-pr CircleCI circleci@example.com $CIRCLE_BRANCH
107
+ - notify_on_failure_on_default_branch
124
108
 
125
109
  workflows:
126
110
  version: 2
127
111
  ordinary:
128
112
  jobs:
129
- - build_on_ruby2_3
130
- - build_on_ruby2_4
131
- - build_on_ruby2_5
132
- - build_on_ruby2_6
113
+ - build:
114
+ name: ruby-2.4
115
+ ruby_version: '2.4'
116
+ - build:
117
+ name: ruby-2.5
118
+ ruby_version: '2.5'
119
+ - build:
120
+ name: ruby-2.6
121
+ ruby_version: '2.6'
122
+ - build:
123
+ name: ruby-2.7
124
+ ruby_version: '2.7'
133
125
  nightly:
134
126
  triggers:
135
127
  - schedule:
136
- cron: "00 10 * * 5"
128
+ cron: "00 10 * * 2"
137
129
  filters:
138
130
  branches:
139
131
  only: master
@@ -3,7 +3,11 @@ require: rubocop-rspec
3
3
 
4
4
  AllCops:
5
5
  DisplayCopNames: true
6
- TargetRubyVersion: 2.3
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'
@@ -1,4 +1,4 @@
1
- Layout/IndentHeredoc:
1
+ Layout/HeredocIndentation:
2
2
  Exclude:
3
3
  - 'lib/circleci/bundle/update/pr.rb'
4
4
 
@@ -1,68 +1,76 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- circleci-bundle-update-pr (1.16.0)
4
+ circleci-bundle-update-pr (2.0.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.5.2)
12
- public_suffix (>= 2.0.2, < 4.0)
13
- ast (2.4.0)
14
- compare_linker (1.4.3)
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.3)
18
- faraday (0.15.4)
17
+ diff-lcs (1.4.4)
18
+ faraday (1.1.0)
19
19
  multipart-post (>= 1.2, < 3)
20
+ ruby2_keywords
20
21
  httpclient (2.8.3)
21
- jaro_winkler (1.5.2)
22
- multipart-post (2.0.0)
23
- octokit (4.14.0)
22
+ multipart-post (2.1.1)
23
+ octokit (4.19.0)
24
+ faraday (>= 0.9)
24
25
  sawyer (~> 0.8.0, >= 0.5.3)
25
- parallel (1.17.0)
26
- parser (2.6.2.1)
27
- ast (~> 2.4.0)
28
- psych (3.1.0)
29
- public_suffix (3.0.3)
26
+ parallel (1.19.2)
27
+ parser (2.7.2.0)
28
+ ast (~> 2.4.1)
29
+ public_suffix (4.0.6)
30
30
  rainbow (3.0.0)
31
- rake (12.3.2)
32
- rspec (3.8.0)
33
- rspec-core (~> 3.8.0)
34
- rspec-expectations (~> 3.8.0)
35
- rspec-mocks (~> 3.8.0)
36
- rspec-core (3.8.0)
37
- rspec-support (~> 3.8.0)
38
- rspec-expectations (3.8.2)
31
+ rake (13.0.1)
32
+ regexp_parser (1.8.2)
33
+ rexml (3.2.4)
34
+ rspec (3.9.0)
35
+ rspec-core (~> 3.9.0)
36
+ rspec-expectations (~> 3.9.0)
37
+ rspec-mocks (~> 3.9.0)
38
+ rspec-core (3.9.3)
39
+ rspec-support (~> 3.9.3)
40
+ rspec-expectations (3.9.3)
39
41
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.8.0)
41
- rspec-mocks (3.8.0)
42
+ rspec-support (~> 3.9.0)
43
+ rspec-mocks (3.9.1)
42
44
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.8.0)
44
- rspec-support (3.8.0)
45
- rubocop (0.67.2)
46
- jaro_winkler (~> 1.5.1)
45
+ rspec-support (~> 3.9.0)
46
+ rspec-support (3.9.4)
47
+ rubocop (0.93.1)
47
48
  parallel (~> 1.10)
48
- parser (>= 2.5, != 2.5.1.1)
49
- psych (>= 3.1.0)
49
+ parser (>= 2.7.1.5)
50
50
  rainbow (>= 2.2.2, < 4.0)
51
+ regexp_parser (>= 1.8)
52
+ rexml
53
+ rubocop-ast (>= 0.6.0)
51
54
  ruby-progressbar (~> 1.7)
52
- unicode-display_width (>= 1.4.0, < 1.6)
53
- rubocop-rspec (1.32.0)
54
- rubocop (>= 0.60.0)
55
- ruby-progressbar (1.10.0)
56
- sawyer (0.8.1)
57
- addressable (>= 2.3.5, < 2.6)
58
- faraday (~> 0.8, < 1.0)
59
- unicode-display_width (1.5.0)
55
+ unicode-display_width (>= 1.4.0, < 2.0)
56
+ rubocop-ast (1.1.0)
57
+ parser (>= 2.7.1.5)
58
+ rubocop-rspec (1.44.1)
59
+ rubocop (~> 0.87)
60
+ rubocop-ast (>= 0.7.1)
61
+ ruby-progressbar (1.10.1)
62
+ ruby2_keywords (0.0.2)
63
+ sawyer (0.8.2)
64
+ addressable (>= 2.3.5)
65
+ faraday (> 0.8, < 2.0)
66
+ unicode-display_width (1.7.0)
60
67
 
61
68
  PLATFORMS
62
69
  ruby
63
70
  x86_64-darwin-16
64
71
  x86_64-darwin-17
65
72
  x86_64-darwin-18
73
+ x86_64-darwin-19
66
74
 
67
75
  DEPENDENCIES
68
76
  bundler
@@ -73,4 +81,4 @@ DEPENDENCIES
73
81
  rubocop-rspec
74
82
 
75
83
  BUNDLED WITH
76
- 1.17.2
84
+ 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/#adding-required-and-custom-tools-or-files
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,6 +19,8 @@ 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
 
@@ -38,7 +38,7 @@ module Circleci
38
38
  end
39
39
 
40
40
  BRANCH_PREFIX = ENV['BRANCH_PREFIX'] || 'bundle-update-'.freeze
41
- TITLE_PREFIX = 'bundle update at '.freeze
41
+ TITLE_PREFIX = ENV['TITLE_PREFIX'] || 'bundle update at '.freeze
42
42
 
43
43
  def self.raise_if_env_unvalid!
44
44
  raise "$CIRCLE_PROJECT_USERNAME isn't set" unless ENV['CIRCLE_PROJECT_USERNAME']
@@ -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
- `git status -sb 2> /dev/null`.include?('Gemfile.lock')
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
- remote = "https://#{github_access_token}@#{github_host}/#{repo_full_name}"
105
- system("git remote add github-url-with-token #{remote}")
106
- system("git config user.name '#{git_username}'")
107
- system("git config user.email #{git_email}")
108
- system('git add Gemfile.lock')
109
- system("git commit -m '$ bundle update && bundle update --ruby'")
110
- system("git branch -M #{branch}")
111
- system("git push -q github-url-with-token #{branch}")
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
@@ -4,7 +4,7 @@ module Circleci
4
4
  module Bundle
5
5
  module Update
6
6
  module Pr
7
- VERSION = '1.16.0'
7
+ VERSION = '2.0.0'
8
8
  end
9
9
  end
10
10
  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) {}
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.16.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Masuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-16 00:00:00.000000000 Z
11
+ date: 2020-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: compare_linker
@@ -146,14 +146,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
146
  requirements:
147
147
  - - ">="
148
148
  - !ruby/object:Gem::Version
149
- version: '0'
149
+ version: 2.4.0
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubygems_version: 3.0.3
156
+ rubygems_version: 3.1.2
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: Provide continues bundle update using CircleCI