Skip to content

Commit

Permalink
Merge pull request #159 from rainforestapp/upgrade_ruby_313
Browse files Browse the repository at this point in the history
Upgrade to Ruby 3.1.3
  • Loading branch information
sebaherrera07 authored Jan 2, 2023
2 parents 7914dfd + 37ef831 commit 8a6758b
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.1
jobs:
test:
docker:
- image: circleci/ruby:2.7
- image: cimg/ruby:3.1.3
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_TOKEN
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
command: bundle exec exe/circlemator test-security --base-branch=master
push_to_rubygems:
docker:
- image: circleci/ruby:2.7
- image: cimg/ruby:3.1.3
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_TOKEN
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.4
3.1.3
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 3.1.3
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:2.7.4
FROM ruby:3.1.3
RUN apt-get update -y && apt-get install -y cmake

# Set default locale for Ruby to avoid encoding errors
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in circlemator.gemspec
gemspec

gem 'rf-stylez'
gem 'rf-stylez', git: 'https://github.com/rainforestapp/rf-stylez.git', branch: 'upgrade_versions'
gem 'rspec_junit_formatter'
54 changes: 31 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
GIT
remote: https://github.com/rainforestapp/rf-stylez.git
revision: 5cddb5b1b9f4164c4bfec412ebd2bab02b87f463
branch: upgrade_versions
specs:
rf-stylez (0.16.0)
get_env (~> 0.2.0)
reek (~> 6.1)
rubocop (= 1.15.0)
rubocop-rails (= 2.10.1)
rubocop-rspec (= 2.3.0)
unparser (~> 0.6)

PATH
remote: .
specs:
Expand All @@ -12,18 +25,17 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (6.1.4.1)
activesupport (7.0.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
brakeman (5.1.1)
coderay (1.1.2)
concurrent-ruby (1.1.9)
concurrent-ruby (1.1.10)
crack (0.4.5)
rexml
diff-lcs (1.4.4)
Expand All @@ -47,7 +59,7 @@ GEM
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
ffi (1.11.1)
ffi (1.15.5)
formatador (0.2.5)
get_env (0.2.0)
gitlab (4.17.0)
Expand All @@ -71,20 +83,21 @@ GEM
httparty (0.18.1)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.8.10)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
imagen (0.1.8)
parser (>= 2.5, != 2.5.1.1)
json (2.3.0)
listen (3.2.0)
kwalify (0.7.2)
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
lumberjack (1.0.13)
method_source (0.9.2)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0704)
minitest (5.14.4)
minitest (5.16.3)
multi_xml (0.6.0)
multipart-post (2.1.1)
nenv (0.3.0)
Expand All @@ -94,8 +107,8 @@ GEM
octokit (4.21.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
parallel (1.20.2)
parser (3.0.2.0)
parallel (1.22.1)
parser (3.1.2.1)
ast (~> 2.4.1)
pronto (0.11.0)
gitlab (~> 4.4, >= 4.4.0)
Expand All @@ -120,21 +133,18 @@ GEM
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (4.0.6)
rack (2.2.3)
rack (3.0.3)
rainbow (3.0.0)
rake (13.0.6)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
reek (6.1.2)
kwalify (~> 0.7.0)
parser (~> 3.1.0)
rainbow (>= 2.0, < 4.0)
regexp_parser (2.1.1)
rexml (3.2.5)
rf-stylez (0.12.0)
get_env (~> 0.2.0)
rubocop (= 1.15.0)
rubocop-rails (= 2.10.1)
rubocop-rspec (= 2.3.0)
semantic_versioning (~> 0.2)
unparser (~> 0.6)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
Expand Down Expand Up @@ -174,7 +184,6 @@ GEM
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
semantic_versioning (0.2.0)
shellany (0.0.1)
simplecov (0.17.1)
docile (~> 1.1)
Expand All @@ -184,22 +193,21 @@ GEM
simplecov-lcov (0.8.0)
terminal-table (1.6.0)
thor (1.1.0)
tzinfo (2.0.4)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
undercover (0.3.4)
imagen (>= 0.1.8)
rainbow (>= 2.1, < 4.0)
rugged (>= 0.27, < 1.1)
unicode-display_width (2.0.0)
unparser (0.6.0)
unparser (0.6.5)
diff-lcs (~> 1.3)
parser (>= 3.0.0)
parser (>= 3.1.0)
vcr (6.0.0)
webmock (3.14.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
zeitwerk (2.4.2)

PLATFORMS
ruby
Expand All @@ -209,7 +217,7 @@ DEPENDENCIES
circlemator!
guard-rspec (~> 4.7.3)
rake (~> 13.0)
rf-stylez
rf-stylez!
rspec (~> 3.10.0)
rspec_junit_formatter
rubocop
Expand Down
37 changes: 31 additions & 6 deletions exe/circlemator
Original file line number Diff line number Diff line change
Expand Up @@ -68,45 +68,70 @@ when 'self-merge'
require_opt options, :github_auth_token
require_opt options, :base_branch
require_opt options, :compare_branch
options[:github_repo] = Circlemator::GithubRepo.new(options)
options[:github_repo] = Circlemator::GithubRepo.new(
user: options[:user],
repo: options[:repo],
github_auth_token: options[:github_auth_token]
)

Circlemator::SelfMerger.new(options).merge!
when 'cancel-old'
options[:current_build] = require_env('CIRCLE_BUILD_NUM').to_i
options[:circle_api_token] ||= ENV['CIRCLE_API_TOKEN']
require_opt options, :circle_api_token

Circlemator::BuildCanceler.new(options).cancel_old_builds!
Circlemator::BuildCanceler.new(
user: options[:user],
repo: options[:repo],
current_build: options[:current_build],
circle_api_token: options[:circle_api_token]
).cancel_old_builds!
when 'style-check'
options[:sha] = require_env 'CIRCLE_SHA1'
options[:compare_branch] ||= require_env 'CIRCLE_BRANCH'
require_opt options, :github_auth_token
require_opt options, :base_branch
options[:github_repo] = Circlemator::GithubRepo.new(options)
options[:github_repo] = Circlemator::GithubRepo.new(
user: options[:user],
repo: options[:repo],
github_auth_token: options[:github_auth_token]
)

Circlemator::CodeAnalyser.new(options).check_style
when 'test-coverage'
options[:sha] = require_env 'CIRCLE_SHA1'
options[:compare_branch] ||= require_env 'CIRCLE_BRANCH'
require_opt options, :github_auth_token
require_opt options, :base_branch
options[:github_repo] = Circlemator::GithubRepo.new(options)
options[:github_repo] = Circlemator::GithubRepo.new(
user: options[:user],
repo: options[:repo],
github_auth_token: options[:github_auth_token]
)

Circlemator::CodeAnalyser.new(options).check_coverage
when 'test-security'
options[:sha] = require_env 'CIRCLE_SHA1'
options[:compare_branch] ||= require_env 'CIRCLE_BRANCH'
require_opt options, :github_auth_token
require_opt options, :base_branch
options[:github_repo] = Circlemator::GithubRepo.new(options)
options[:github_repo] = Circlemator::GithubRepo.new(
user: options[:user],
repo: options[:repo],
github_auth_token: options[:github_auth_token]
)

Circlemator::CodeAnalyser.new(options).check_security
when 'comment'
options[:sha] = require_env 'CIRCLE_SHA1'
options[:compare_branch] ||= require_env 'CIRCLE_BRANCH'
require_opt options, :github_auth_token
require_opt options, :base_branch
options[:github_repo] = Circlemator::GithubRepo.new(options)
options[:github_repo] = Circlemator::GithubRepo.new(
user: options[:user],
repo: options[:repo],
github_auth_token: options[:github_auth_token]
)

unless ARGV[1]
puts 'Please add some text to the comment!'
Expand Down
2 changes: 1 addition & 1 deletion lib/circlemator/build_canceler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Circlemator
class BuildCanceler
def initialize(user:, repo:, current_build:, circle_api_token:, **_opts)
def initialize(user:, repo:, current_build:, circle_api_token:)
@user = user
@repo = repo
@current_build = current_build
Expand Down
7 changes: 6 additions & 1 deletion lib/circlemator/code_analyser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ def run_pronto
end

def formatter
pr_number, _ = PrFinder.new(**@opts).find_pr
pr_number, _ = PrFinder.new(
github_repo: @opts[:github_repo],
base_branch: @opts[:base_branch],
compare_branch: @opts[:compare_branch],
sha: @opts[:sha]
).find_pr
if pr_number
ENV['PRONTO_PULL_REQUEST_ID'] = pr_number.to_s
Pronto::Formatter::GithubPullRequestFormatter.new
Expand Down
2 changes: 1 addition & 1 deletion lib/circlemator/github_repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def initialize(url, repo)

base_uri 'https://api.github.com/repos'

def initialize(user:, repo:, github_auth_token:, **_opts)
def initialize(user:, repo:, github_auth_token:)
@user = user
@repo = repo
@auth_token = github_auth_token
Expand Down
7 changes: 6 additions & 1 deletion lib/circlemator/pr_commenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ def initialize(opts)
end

def comment(text)
_, pr_url = PrFinder.new(**@opts).find_pr
_, pr_url = PrFinder.new(
github_repo: @opts[:github_repo],
base_branch: @opts[:base_branch],
compare_branch: @opts[:compare_branch],
sha: @opts[:sha]
).find_pr
raise 'PR not found!' unless pr_url

response = @github_repo.post "#{pr_url}/reviews", body: { commit_id: @sha,
Expand Down
2 changes: 1 addition & 1 deletion lib/circlemator/pr_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(response)
end
end

def initialize(github_repo:, base_branch:, compare_branch:, sha:, **_opts)
def initialize(github_repo:, base_branch:, compare_branch:, sha:)
@github_repo = github_repo
@base_branch = base_branch
@compare_branch = compare_branch
Expand Down
7 changes: 6 additions & 1 deletion lib/circlemator/self_merger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ def initialize(opts)
end

def merge!
pr_number, pr_url = PrFinder.new(**@opts).find_pr
pr_number, pr_url = PrFinder.new(
github_repo: @opts[:github_repo],
base_branch: @opts[:base_branch],
compare_branch: @opts[:compare_branch],
sha: @opts[:sha]
).find_pr
return if pr_number.nil? || pr_url.nil?

response = @github_repo.put "#{pr_url}/merge",
Expand Down

0 comments on commit 8a6758b

Please sign in to comment.