Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Origin/ruby 3 #69

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/rubyonrails.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This workflow uses actions that are not certified by GitHub. They are
# provided by a third-party and are governed by separate terms of service,
# privacy policy, and support documentation.
#
# This workflow will install a prebuilt Ruby version, install dependencies, and
# run tests and linters.
name: "Ruby on Rails CI"
on:
push:
branches: [ master, ruby3 ]
pull_request:
branches: [ master, ruby3 ]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11-alpine
ports:
- "5432:5432"
env:
POSTGRES_DB: rails_test
POSTGRES_USER: rails
POSTGRES_PASSWORD: password
env:
RAILS_ENV: test
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
# Runners
- name: Set up database schema
run: RAILS_ENV=test bundle exec rake db:prepare
- name: Run tests
run: bundle exec rspec spec
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
# Runners
- name: Run Rubocop
run: bundle exec rubocop --parallel --format github --format progress
40 changes: 8 additions & 32 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
AllCops:
NewCops: enable
Exclude:
- '*.md'
- 'Gemfile'
- 'Gemfile.lock'
- db/schema.rb
- config/**/*.rb
- script/rails

Layout/IndentationWidth:
Enabled: false
- 'db/schema.rb'
- 'config/**/*.rb'
- 'script/rails'
- 'vendor/**/*'

Metrics/LineLength:
Max: 130
Exclude:
- '*.gemspec'

Style/RescueModifier:
Enabled: false

Layout/TrailingBlankLines:
Enabled: false

Lint/UnusedBlockArgument:
Exclude:
- 'spec/tmp/**/*.rb'
Expand All @@ -29,31 +22,14 @@ Style/BlockComments:
Exclude:
- 'spec/spec_helper.rb'

Style/FrozenStringLiteralComment:
Enabled: false

Metrics/BlockLength:
Exclude:
Exclude:
- 'spec/**/*.rb'

Layout/AlignParameters:
EnforcedStyle: 'with_fixed_indentation'

Layout/MultilineMethodCallIndentation:
EnforcedStyle: 'indented'

Style/Documentation:
Exclude:
- 'db/migrate/*.rb'
- 'spec/**/*.rb'

# These may break ruby 1.9 support:

Layout/IndentHeredoc:
Enabled: false

Style/HashSyntax:
Enabled: false

Style/ExpandPathArguments:
Enabled: false
Gemspec/DevelopmentDependencies:
EnforcedStyle: "gemspec"
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.0
3.0.4
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env rake
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require File.expand_path('config/application', __dir__)

AfterParty::Application.load_tasks
28 changes: 17 additions & 11 deletions after_party.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# frozen_string_literal: true

require_relative 'lib/version'

Gem::Specification.new do |gem|
gem.name = 'after_party'
gem.version = '1.11.2'
gem.date = '2019-03-25'
gem.version = Version::VERSION

gem.authors = 'Steve Mitchell'
gem.description = 'Automated post-deploy tasks for Ruby/Rails. Your deployment is the party. This is the after party'
Expand All @@ -13,12 +16,15 @@ Gem::Specification.new do |gem|
gem.files = Dir['lib/**/**']
gem.require_path = 'lib'

gem.add_development_dependency 'activerecord'
gem.add_development_dependency 'factory_bot'
gem.add_development_dependency 'generator_spec'
gem.add_development_dependency 'mongoid'
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'rspec-rails', '~> 3.4'
gem.add_development_dependency 'rubocop'
gem.add_development_dependency 'sqlite3', '~> 1.3.6'
end
gem.required_ruby_version = '~> 3.0'

gem.add_development_dependency 'activerecord', '~> 7'
gem.add_development_dependency 'factory_bot', '~> 6'
gem.add_development_dependency 'generator_spec', '~> 0'
gem.add_development_dependency 'mongoid', '~> 7'
gem.add_development_dependency 'pg', '~> 1'
gem.add_development_dependency 'rspec', '~> 3'
gem.add_development_dependency 'rspec-rails', '~> 5'
gem.add_development_dependency 'rubocop', '~> 1'
gem.metadata['rubygems_mfa_required'] = 'true'
end
4 changes: 3 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
require File.expand_path('config/environment', __dir__)
run AfterParty::Application
7 changes: 3 additions & 4 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ class Application < Rails::Application

ActiveRecord::SchemaDumper.ignore_tables = /^ar_internal*/

if ActiveRecord::VERSION::MAJOR >= 5
config.active_record.sqlite3.represent_boolean_as_integer = true
end

# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql


config.active_record.legacy_connection_handling = false
end
end
22 changes: 4 additions & 18 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
adapter: postgresql
database: after_party_dev
pool: 5
timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
adapter: postgresql
database: after_party_test
pool: 5
timeout: 5000
7 changes: 7 additions & 0 deletions config/initializers/after_party.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
AfterParty.setup do |config|
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default) and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
require 'after_party/active_record.rb'
end
10 changes: 6 additions & 4 deletions db/migrate/20130208204820_create_task_records.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# frozen_string_literal: true

if ActiveRecord::VERSION::MAJOR >= 5
class CreateTaskRecords < ActiveRecord::Migration[4.2]
def change
create_table :task_records, :id => false do |t|
t.string :version, :null => false
create_table :task_records, id: false do |t|
t.string :version, null: false
end
end
end

else
class CreateTaskRecords < ActiveRecord::Migration
def change
create_table :task_records, :id => false do |t|
t.string :version, :null => false
create_table :task_records, id: false do |t|
t.string :version, null: false
end
end
end
Expand Down
13 changes: 6 additions & 7 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2013_02_08_204820) do

ActiveRecord::Schema[7.0].define(version: 2013_02_08_204820) do
create_table "task_records", id: false, force: :cascade do |t|
t.string "version", null: false
end
Expand Down
6 changes: 4 additions & 2 deletions lib/after_party.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

# AfterParty is a moduke defined by gem after_party
module AfterParty
require 'after_party/railtie.rb' if defined?(Rails)
require 'after_party/railtie' if defined?(Rails)

def self.setup
yield self
end
end
end
4 changes: 3 additions & 1 deletion lib/after_party/active_record.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
require 'after_party/models/active_record/task_record.rb'
# frozen_string_literal: true

require 'after_party/models/active_record/task_record'
4 changes: 3 additions & 1 deletion lib/after_party/models/active_record/task_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module AfterParty
# Task Record is a persisted object recorded when a taks is run.
class TaskRecord < ActiveRecord::Base
Expand All @@ -7,4 +9,4 @@ def self.completed_task?(version)
all.any? { |t| t.version == version }
end
end
end
end
4 changes: 3 additions & 1 deletion lib/after_party/models/mongoid/task_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module AfterParty
# Task Record is a persisted object recorded when a taks is run.
class TaskRecord
Expand All @@ -10,4 +12,4 @@ def self.completed_task?(version)
all.any? { |t| t.version == version }
end
end
end
end
8 changes: 5 additions & 3 deletions lib/after_party/models/task_recorder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module AfterParty
# Task Recorder is responsible for collecting pending tasks and recording their execution
class TaskRecorder
Expand All @@ -8,8 +10,8 @@ class TaskRecorder

def self.pending_files
Dir[FILE_MASK].collect { |f| TaskRecorder.new(f) }
.select(&:pending?)
.sort_by(&:timestamp)
.select(&:pending?)
.sort_by(&:timestamp)
end

def initialize(filename = '')
Expand All @@ -28,4 +30,4 @@ def parse_filename
end
end
end
end
end
4 changes: 3 additions & 1 deletion lib/after_party/mongoid.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
require 'after_party/models/mongoid/task_record.rb'
# frozen_string_literal: true

require 'after_party/models/mongoid/task_record'
4 changes: 3 additions & 1 deletion lib/after_party/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'after_party'
require 'rails'
module AfterParty
Expand All @@ -16,4 +18,4 @@ class Railtie < Rails::Railtie
load 'generators/install/install_generator.rb'
end
end
end
end
Loading