circleci-bundle-update-pr 1.16.1 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75f3b64983d10d74e5d008d72b9e4980cbaa0f0be28fbb609c94e2ee5f3834ae
4
- data.tar.gz: f1070ba274c890e2799e397e1f2dac799c921677a2a853e5d3c28a642ff9d1d3
3
+ metadata.gz: 30b7ab3dbfc72e9b9324188c265d8d8157125777980c0df23374100b782bb551
4
+ data.tar.gz: a331c2a3ef23c8d28a59403f202d1bb5dfe81e569ffd385a11b8070bcf66d62e
5
5
  SHA512:
6
- metadata.gz: a25612558d02e70a45f5c7c96e0d43b116cd5d064d8e1711a88543ac0e7f863561a3629d0984954b6cadda6d4c686bafc23a43d3dee44659036a4767bc6a7774
7
- data.tar.gz: da28bc0185302f30ae7506cad0e8199c0d1d5eb425b1ecf9b01dfe70bec86fcd92807443ed3c0cb8a115543216cf054b12525d17606a4fb0d949544c37fdd5cc
6
+ metadata.gz: 29ea5efb9b178ad57a080f78da124fb520e28ce06e418e4ad6a63a1ff1edceaa80597a7871f05467c6e314522cd107a56a460ca918caa1d9c87f4feda39584dd
7
+ data.tar.gz: a1924bb344553c2f8176676d401534048a5d2bbcfbd16affef4cba96a6c9e40d757e70dcb2ea11eaa99c5435a9d80286821b024e9c8c7be77e57c74f5ae21fb1
data/.circleci/config.yml CHANGED
@@ -1,135 +1,107 @@
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
24
-
25
- jobs:
26
- build_on_ruby2_3:
3
+ executors:
4
+ default:
5
+ parameters:
6
+ ruby_version:
7
+ type: enum
8
+ enum: ['2.3', '2.4', '2.5', '2.6']
27
9
  docker:
28
- - image: ruby:2.3-alpine
10
+ - image: ruby:<< parameters.ruby_version >>-alpine
29
11
  working_directory: /work
12
+
13
+ commands:
14
+ setup_requirements:
30
15
  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
16
+ - run:
17
+ name: Install System Dependencies
18
+ command: |
19
+ # See also https://circleci.com/docs/2.0/custom-images/#adding-required-and-custom-tools-or-files
20
+ apk add --update-cache --no-cache --no-progress git openssh-client tar gzip ca-certificates \
21
+ build-base tzdata
22
+ - run:
23
+ name: Set timezone to Asia/Tokyo
24
+ command: cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
25
+ restore_bundle_cache:
26
+ parameters:
27
+ ruby_version:
28
+ type: enum
29
+ enum: ['2.3', '2.4', '2.5', '2.6']
51
30
  steps:
52
- - run: *setup_requirements
53
- - run: *set_timezone
54
- - checkout
55
31
  - restore_cache:
56
- name: Restore bundler cache
32
+ name: Restore bundle cache
57
33
  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
34
+ - gems-ruby<< parameters.ruby_version >>-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
35
+ - gems-ruby<< parameters.ruby_version >>-{{ .Environment.COMMON_CACHE_KEY }}-
36
+ save_bundle_cache:
37
+ parameters:
38
+ ruby_version:
39
+ type: enum
40
+ enum: ['2.3', '2.4', '2.5', '2.6']
72
41
  steps:
73
- - run: *setup_requirements
74
- - run: *set_timezone
75
- - checkout
76
- - restore_cache:
77
- name: Restore bundler cache
78
- keys:
79
- - gems-ruby2.5-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
80
- - gems-ruby2.5-{{ .Environment.COMMON_CACHE_KEY }}-
81
- - run: *bundle_install
82
42
  - save_cache:
83
- name: Save bundler cache
84
- key: gems-ruby2.5-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
43
+ name: Save bundle cache
44
+ key: gems-ruby<< parameters.ruby_version >>-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }}
85
45
  paths:
86
46
  - /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
47
+
48
+ jobs:
49
+ build:
50
+ parameters:
51
+ ruby_version:
52
+ type: enum
53
+ enum: ['2.3', '2.4', '2.5', '2.6']
54
+ executor:
55
+ name: default
56
+ ruby_version: << parameters.ruby_version >>
93
57
  steps:
94
- - run: *setup_requirements
95
- - run: *set_timezone
58
+ - setup_requirements
96
59
  - 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
60
+ - restore_bundle_cache:
61
+ ruby_version: << parameters.ruby_version >>
62
+ - run:
63
+ name: bundle install
64
+ command: |
65
+ bundle check || bundle install --jobs=4 --retry=3
66
+ bundle clean
67
+ - save_bundle_cache:
68
+ ruby_version: << parameters.ruby_version >>
69
+ - run: rubocop
70
+ - run: rspec
110
71
  continuous_bundle_update:
111
- docker: *docker_ruby2_6
112
- working_directory: /work
72
+ executor:
73
+ name: default
74
+ ruby_version: '2.6'
113
75
  steps:
114
- - run: *setup_requirements
115
- - run: *set_timezone
76
+ - setup_requirements
116
77
  - checkout
117
- - restore_cache: *restore_cache_ruby2_6
78
+ - restore_bundle_cache:
79
+ ruby_version: '2.6'
118
80
  - run:
119
- name: Setup requirements for continuous bundle update
120
- command: gem install -N circleci-bundle-update-pr
81
+ name: Install edge circleci-bundle-update-pr
82
+ command: |
83
+ gem install -N specific_install
84
+ gem specific_install https://github.com/masutaka/circleci-bundle-update-pr.git
121
85
  - deploy:
122
- name: Continuous bundle update
86
+ name: Run circleci-bundle-update-pr
123
87
  command: circleci-bundle-update-pr CircleCI circleci@example.com $CIRCLE_BRANCH
124
88
 
125
89
  workflows:
126
90
  version: 2
127
91
  ordinary:
128
92
  jobs:
129
- - build_on_ruby2_3
130
- - build_on_ruby2_4
131
- - build_on_ruby2_5
132
- - build_on_ruby2_6
93
+ - build:
94
+ name: ruby-2.3
95
+ ruby_version: '2.3'
96
+ - build:
97
+ name: ruby-2.4
98
+ ruby_version: '2.4'
99
+ - build:
100
+ name: ruby-2.5
101
+ ruby_version: '2.5'
102
+ - build:
103
+ name: ruby-2.6
104
+ ruby_version: '2.6'
133
105
  nightly:
134
106
  triggers:
135
107
  - schedule:
data/Gemfile.lock CHANGED
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- circleci-bundle-update-pr (1.16.1)
4
+ circleci-bundle-update-pr (1.17.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)
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
13
  ast (2.4.0)
14
14
  compare_linker (1.4.3)
15
15
  httpclient
@@ -19,44 +19,42 @@ GEM
19
19
  multipart-post (>= 1.2, < 3)
20
20
  httpclient (2.8.3)
21
21
  jaro_winkler (1.5.2)
22
- multipart-post (2.0.0)
22
+ multipart-post (2.1.1)
23
23
  octokit (4.14.0)
24
24
  sawyer (~> 0.8.0, >= 0.5.3)
25
25
  parallel (1.17.0)
26
- parser (2.6.2.1)
26
+ parser (2.6.3.0)
27
27
  ast (~> 2.4.0)
28
- psych (3.1.0)
29
- public_suffix (3.0.3)
28
+ public_suffix (4.0.1)
30
29
  rainbow (3.0.0)
31
30
  rake (12.3.2)
32
31
  rspec (3.8.0)
33
32
  rspec-core (~> 3.8.0)
34
33
  rspec-expectations (~> 3.8.0)
35
34
  rspec-mocks (~> 3.8.0)
36
- rspec-core (3.8.0)
35
+ rspec-core (3.8.1)
37
36
  rspec-support (~> 3.8.0)
38
- rspec-expectations (3.8.2)
37
+ rspec-expectations (3.8.4)
39
38
  diff-lcs (>= 1.2.0, < 2.0)
40
39
  rspec-support (~> 3.8.0)
41
- rspec-mocks (3.8.0)
40
+ rspec-mocks (3.8.1)
42
41
  diff-lcs (>= 1.2.0, < 2.0)
43
42
  rspec-support (~> 3.8.0)
44
- rspec-support (3.8.0)
45
- rubocop (0.67.2)
43
+ rspec-support (3.8.2)
44
+ rubocop (0.71.0)
46
45
  jaro_winkler (~> 1.5.1)
47
46
  parallel (~> 1.10)
48
- parser (>= 2.5, != 2.5.1.1)
49
- psych (>= 3.1.0)
47
+ parser (>= 2.6)
50
48
  rainbow (>= 2.2.2, < 4.0)
51
49
  ruby-progressbar (~> 1.7)
52
- unicode-display_width (>= 1.4.0, < 1.6)
53
- rubocop-rspec (1.32.0)
50
+ unicode-display_width (>= 1.4.0, < 1.7)
51
+ rubocop-rspec (1.33.0)
54
52
  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)
53
+ ruby-progressbar (1.10.1)
54
+ sawyer (0.8.2)
55
+ addressable (>= 2.3.5)
56
+ faraday (> 0.8, < 2.0)
57
+ unicode-display_width (1.6.0)
60
58
 
61
59
  PLATFORMS
62
60
  ruby
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,57 @@ 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_BRANCH | 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
+ GITHUB_BRANCH: ${{ github.ref }}
202
+ GITHUB_REPOSITORY: ${{ github.repository }}
203
+ GIT_USER_NAME: "your name"
204
+ GIT_USER_EMAIL: "ci@example.com"
205
+ ```
206
+
156
207
  ## Contributing
157
208
 
158
209
  1. Fork it ( https://github.com/masutaka/circleci-bundle-update-pr/fork )
@@ -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: 'Gemfile.lock',
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'
@@ -4,7 +4,7 @@ module Circleci
4
4
  module Bundle
5
5
  module Update
6
6
  module Pr
7
- VERSION = '1.16.1'
7
+ VERSION = '1.17.0'
8
8
  end
9
9
  end
10
10
  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.1
4
+ version: 1.17.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-17 00:00:00.000000000 Z
11
+ date: 2019-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: compare_linker