Skip to content

Commit

Permalink
Add ruby 3 support, drop ruby 2.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeSouthan committed Aug 9, 2021
1 parent 9783274 commit be99e73
Show file tree
Hide file tree
Showing 16 changed files with 188 additions and 182 deletions.
230 changes: 100 additions & 130 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,157 +1,127 @@
---
version: 2
version: 2.1

references:
steps: &steps
- checkout

- type: shell
name: Write RAILS_VERSION to a file so we can use it for caching purposes
command: echo "$RAILS_VERSION" > ~/RAILS_VERSION.txt

- type: cache-restore
key: statesman-{{ checksum "Gemfile" }}-{{ checksum "~/RAILS_VERSION.txt" }}

- run: gem install bundler -v 2.1.4
bundle_install: &bundle_install
run:
name: Bundle
command: |
gem install bundler --no-document && \
bundle config set no-cache 'true' && \
bundle config set jobs '4' && \
bundle config set retry '3' && \
bundle install
- run: bundle install --path vendor/bundle

- type: cache-save
key: statesman-{{ checksum "Gemfile" }}-{{ checksum "~/RAILS_VERSION.txt" }}
cache_bundle: &cache_bundle
save_cache:
key: bundle-<< parameters.ruby_version >>-<< parameters.rails_version >>-{{ checksum "statesman.gemspec" }}-{{ checksum "Gemfile" }}
paths:
- vendor/bundle

- run: bundle exec rubocop
restore_bundle: &restore_bundle
restore_cache:
key: bundle-<< parameters.ruby_version >>-<< parameters.rails_version >>-{{ checksum "statesman.gemspec" }}-{{ checksum "Gemfile" }}

steps: &steps
- add_ssh_keys
- checkout
- run:
name: "Add dependencies"
command: |
sudo apt-get update && sudo apt-get install -y sqlite3 libsqlite3-dev
- *restore_bundle
- *bundle_install
- *cache_bundle
- run: dockerize -wait tcp://localhost:$DATABASE_DEPENDENCY_PORT -timeout 1m
- run:
name: Run specs
command: |
bundle exec rspec $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) --profile --format progress --format RspecJunitFormatter -o /tmp/circle_artifacts/rspec.xml
- run:
name: "Rubocop"
command: bundle exec rubocop --extra-details --display-style-guide --parallel --force-exclusion
- store_artifacts:
path: /tmp/circle_artifacts/
- store_test_results:
path: /tmp/circle_artifacts/

- run: bundle exec rake
ruby_versions: &ruby_versions
- "2.5"
- "2.6"
- "2.7"
- "3.0"

- type: store_test_results
path: /tmp/test-results
rails_versions: &rails_versions
- "5.2.6"
- "6.0.4"
- "6.1.4"
- "main"

jobs:
build-ruby249-rails-524-mysql:
docker:
- image: circleci/ruby:2.4.9-node
environment:
- RAILS_VERSION=5.2.4
- DATABASE_URL=mysql2://[email protected]/statesman_test
- DATABASE_DEPENDENCY_PORT=3306
- image: circleci/mysql:5.7.18
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=true
- MYSQL_USER=root
- MYSQL_PASSWORD=
- MYSQL_DATABASE=statesman_test
steps: *steps
build-ruby249-rails-524-postgres:
docker:
- image: circleci/ruby:2.4.9-node
environment:
- RAILS_VERSION=5.2.4
- DATABASE_URL=postgres://postgres@localhost/statesman_test
- DATABASE_DEPENDENCY_PORT=5432
- image: circleci/postgres:9.6
environment:
- POSTGRES_USER=postgres
- POSTGRES_DB=statesman_test
- POSTGRES_PASSWORD=statesman
steps: *steps
mysql_versions: &mysql_versions
- "5.7.18"

build-ruby265-rails-602-mysql:
docker:
- image: circleci/ruby:2.6.5-node
environment:
- RAILS_VERSION=6.0.2
- DATABASE_URL=mysql2://[email protected]/statesman_test
- DATABASE_DEPENDENCY_PORT=3306
- image: circleci/mysql:5.7.18
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=true
- MYSQL_USER=root
- MYSQL_PASSWORD=
- MYSQL_DATABASE=statesman_test
steps: *steps
build-ruby265-rails-602-postgres:
docker:
- image: circleci/ruby:2.6.5-node
environment:
- RAILS_VERSION=6.0.2
- DATABASE_URL=postgres://postgres@localhost/statesman_test
- DATABASE_DEPENDENCY_PORT=5432
- image: circleci/postgres:9.6
environment:
- POSTGRES_USER=postgres
- POSTGRES_DB=statesman_test
- POSTGRES_PASSWORD=statesman
steps: *steps
psql_versions: &psql_versions
- "9.6"

build-ruby270-rails-602-mysql:
docker:
- image: circleci/ruby:2.7.0-node
environment:
- RAILS_VERSION=6.0.2
- DATABASE_URL=mysql2://[email protected]/statesman_test
- DATABASE_DEPENDENCY_PORT=3306
- image: circleci/mysql:5.7.18
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=true
- MYSQL_USER=root
- MYSQL_PASSWORD=
- MYSQL_DATABASE=statesman_test
steps: *steps
build-ruby270-rails-602-postgres:
docker:
- image: circleci/ruby:2.7.0-node
environment:
- RAILS_VERSION=6.0.2
- DATABASE_URL=postgres://postgres@localhost/statesman_test
- DATABASE_DEPENDENCY_PORT=5432
- image: circleci/postgres:9.6
environment:
- POSTGRES_USER=postgres
- POSTGRES_DB=statesman_test
- POSTGRES_PASSWORD=statesman
steps: *steps
build-ruby270-rails-main-mysql:
jobs:
rspec_mysql:
working_directory: /mnt/ramdisk
parameters:
ruby_version:
type: string
rails_version:
type: string
mysql_version:
type: string
docker:
- image: circleci/ruby:2.7.0-node
- image: cimg/ruby:<< parameters.ruby_version >>
environment:
- RAILS_VERSION=main
- DATABASE_URL=mysql2://root@127.0.0.1/statesman_test
- DATABASE_DEPENDENCY_PORT=3306
- image: circleci/mysql:5.7.18
CIRCLE_TEST_REPORTS: /tmp/circle_artifacts/
DATABASE_URL: mysql2://foobar:password@127.0.0.1/statesman_test
DATABASE_DEPENDENCY_PORT: "3306"
- image: circleci/mysql:<< parameters.mysql_version >>
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=true
- MYSQL_USER=root
- MYSQL_PASSWORD=
- MYSQL_DATABASE=statesman_test
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: foobar
MYSQL_PASSWORD: password
MYSQL_DATABASE: statesman_test
steps: *steps
build-ruby270-rails-main-postgres:

rspec_postgres:
working_directory: /mnt/ramdisk
parameters:
ruby_version:
type: string
rails_version:
type: string
psql_version:
type: string
docker:
- image: circleci/ruby:2.7.0-node
- image: cimg/ruby:<< parameters.ruby_version >>
environment:
- RAILS_VERSION=main
- DATABASE_URL=postgres://postgres@localhost/statesman_test
- EXCLUDE_MONGOID=true
- DATABASE_DEPENDENCY_PORT=5432
- image: circleci/postgres:9.6
CIRCLE_TEST_REPORTS: /tmp/circle_artifacts/
DATABASE_URL: postgres://postgres@localhost/statesman_test
DATABASE_DEPENDENCY_PORT: "5432"
- image: circleci/postgres:<< parameters.psql_version >>
environment:
- POSTGRES_USER=postgres
- POSTGRES_DB=statesman_test
- POSTGRES_PASSWORD=statesman
POSTGRES_USER: postgres
POSTGRES_DB: statesman_test
POSTGRES_PASSWORD: statesman
steps: *steps

workflows:
version: 2
tests:
jobs:
- build-ruby249-rails-524-mysql
- build-ruby249-rails-524-postgres
- build-ruby265-rails-602-mysql
- build-ruby265-rails-602-postgres
- build-ruby270-rails-602-mysql
- build-ruby270-rails-602-postgres
- build-ruby270-rails-main-mysql
- build-ruby270-rails-main-postgres
- rspec_mysql:
matrix:
parameters:
mysql_version: *mysql_versions
ruby_version: *ruby_versions
rails_version: *rails_versions
- rspec_postgres:
matrix:
parameters:
psql_version: *psql_versions
ruby_version: *ruby_versions
rails_version: *rails_versions
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2

updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: "daily"
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ inherit_gem:
gc_ruboconfig: rubocop.yml

AllCops:
TargetRubyVersion: 2.4
TargetRubyVersion: 3.0
65 changes: 37 additions & 28 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,55 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-08-17 15:19:58 +0100 using RuboCop version 0.61.1.
# on 2021-08-09 15:32:40 UTC using RuboCop version 1.18.4.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Enabled: false # We want to allow Ruby 2.2 even though we don't test on it
Exclude:
- 'statesman.gemspec'

# Offense count: 1
Lint/MissingSuper:
Exclude:
- 'lib/statesman/adapters/active_record_queries.rb'

# Offense count: 5
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 18
Max: 20

# Offense count: 1
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 8

# Offense count: 4
# Configuration parameters: CountComments, ExcludedMethods.
# Offense count: 3
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 14

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: SkipBlocks, EnforcedStyle.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
- 'spec/statesman/adapters/active_record_queries_spec.rb'

# Offense count: 7
# Configuration parameters: Max.
# Offense count: 11
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Exclude:
- 'spec/statesman/adapters/active_record_spec.rb'
- 'spec/statesman/adapters/shared_examples.rb'
- 'spec/statesman/machine_spec.rb'
Max: 14

# Offense count: 7
RSpec/ExpectInHook:
Exclude:
- 'spec/statesman/adapters/active_record_spec.rb'
- 'spec/statesman/machine_spec.rb'

# Offense count: 3
RSpec/ImplicitBlockExpectation:
# Offense count: 1
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
RSpec/FilePath:
Exclude:
- 'spec/statesman/adapters/active_record_spec.rb'
- 'spec/statesman/adapters/shared_examples.rb'
- 'spec/statesman/exceptions_spec.rb'

# Offense count: 1
# Configuration parameters: AssignmentOnly.
Expand Down Expand Up @@ -75,23 +80,27 @@ RSpec/MessageSpies:
Exclude:
- 'spec/statesman/callback_spec.rb'

# Offense count: 9
# Configuration parameters: AggregateFailuresByDefault.
# Offense count: 14
RSpec/MultipleExpectations:
Max: 3

# Offense count: 50
# Offense count: 49
RSpec/NestedGroups:
Max: 6

# Offense count: 16
# Offense count: 2
RSpec/RepeatedExampleGroupBody:
Exclude:
- 'spec/statesman/exceptions_spec.rb'

# Offense count: 12
RSpec/ScatteredSetup:
Exclude:
- 'spec/statesman/adapters/active_record_spec.rb'
- 'spec/statesman/adapters/shared_examples.rb'
- 'spec/statesman/machine_spec.rb'

# Offense count: 8
# Offense count: 7
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
Expand Down
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.2
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## v9.0.0 9th August 2021

### Added
- Added Ruby 3.0 support

### Breaking changes

- Removed Ruby 2.4

## v8.0.3 8th June 2021

### Added
Expand Down
Loading

0 comments on commit be99e73

Please sign in to comment.