Skip to content

replace travis with github actions and update test configuration #3

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
79 changes: 79 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# .github/workflows/ci.yml
name: CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
env:
NOKOGIRI_USE_SYSTEM_LIBRARIES: true
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
strategy:
fail-fast: false
matrix:
include:
- gemfile: 6.0.gemfile
ruby: 2.7

- gemfile: 6.0.gemfile
ruby: 3.0

- gemfile: 6.0.gemfile
ruby: 3.1

- gemfile: 6.1.gemfile
ruby: 2.7

- gemfile: 6.1.gemfile
ruby: 3.0

- gemfile: 6.1.gemfile
ruby: 3.1

- gemfile: 7.0.gemfile
ruby: 2.7

- gemfile: 7.0.gemfile
ruby: 3.0

- gemfile: 7.0.gemfile
ruby: 3.1

name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}

steps:
- uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Bundle install
run: |
bundle config set gemfile "${GITHUB_WORKSPACE}/gemfiles/${{ matrix.gemfile }}"
bundle install --jobs 4 --retry 3

- name: Run tests
run: bundle exec rspec
env:
DB_HOST: localhost
DB_USERNAME: postgres
DB_PORT: 5432
DB_PASSWORD: postgres

- name: Rubocop
run: bundle exec rubocop
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec/internal/log/
/test/tmp/
/test/version_tmp/
/tmp/
Gemfile.lock
*.lock

# Used by dotenv library to load environment variables.
# .env
Expand Down Expand Up @@ -50,3 +50,7 @@ build-iPhoneSimulator/

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

.idea
.rspec_status
gemfiles/.bundle/
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
require: rubocop-rspec

AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 2.7
TargetRailsVersion: 4.0
Exclude:
- 'activerecord-data_integrity.gemspec'
- 'spec/support/*'
- 'tmp/**/*'
- 'gemfiles/*'
- 'spec/internal/**/*'
- 'vendor/**/*'

Metrics/LineLength:
Max: 110
Expand Down
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

12 changes: 6 additions & 6 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

appraise '5.0' do
gem 'activerecord', '~> 5.0'
appraise '6.0' do
gem 'activerecord', '~> 6.0'
end

appraise '5.1' do
gem 'activerecord', '~> 5.1'
appraise '6.1' do
gem 'activerecord', '~> 6.1'
end

appraise '5.2' do
gem 'activerecord', '~> 5.2'
appraise '7.0' do
gem 'activerecord', '~> 7.0'
end
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Gem Version](https://badge.fury.io/rb/activerecord-data_integrity.svg)](https://badge.fury.io/rb/activerecord-data_integrity)
[![Build Status](https://travis-ci.org/dsalahutdinov/activerecord-data_integrity.svg?branch=master)](https://travis-ci.org/dsalahutdinov/activerecord-data_integrity.svg?branch=master)
[![CI Status](https://github.com/dsalahutdinov/activerecord-data_integrity/workflows/CI/badge.svg?branch=master)](https://github.com/dsalahutdinov/activerecord-data_integrity/actions?query=workflow%3ACI+branch%3Amaster)

# ActiveRecord::DataIntegrity

Expand Down Expand Up @@ -80,8 +80,8 @@ Otherwise (without Docker) set up environment manually:
git checkout [email protected]:dsalahutdinov/activerecord-data_integrity.git
cd activerecord-data_integrity
bundle install
bundle appraisal
DB_HOST=localhost DB_NAME=testdb DB_USERNAME=postgres bundle appraisal rspec
bundle exec appraisal
DB_HOST=localhost DB_NAME=testdb DB_USERNAME=postgres bundle exec appraisal rspec
```

## License
Expand Down
12 changes: 6 additions & 6 deletions activerecord-data_integrity.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_runtime_dependency 'pg'
spec.add_runtime_dependency 'rails'
spec.add_runtime_dependency 'activerecord'
spec.add_runtime_dependency 'rainbow'

spec.add_development_dependency 'appraisal', '~> 2.2'
spec.add_development_dependency 'bundler', '~> 1.16'
spec.add_development_dependency 'combustion', '~> 1.0'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'appraisal', '~> 2.4'
spec.add_development_dependency 'bundler', '~> 2.2'
spec.add_development_dependency 'combustion', '~> 1.3'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.11'

spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rubocop-rspec'
Expand Down
7 changes: 7 additions & 0 deletions gemfiles/6.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activerecord", "~> 6.0"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/6.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activerecord", "~> 6.1"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/7.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activerecord", "~> 7.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion lib/active_record/data_integrity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'active_record/data_integrity/version'

require 'rails/all'
require 'active_record'
require 'active_record/data_integrity/cli'
require 'rainbow'

Expand Down
12 changes: 4 additions & 8 deletions lib/active_record/data_integrity/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ def initialize(options)
end

def cops
@cops ||= begin
ActiveRecord::DataIntegrity::Cop.descendants.select do |cop|
only.empty? || cop.cop_name.in?(only)
end
@cops ||= ActiveRecord::DataIntegrity::Cop.descendants.select do |cop|
only.empty? || cop.cop_name.in?(only)
end
end

def models
@models ||= begin
ActiveRecord::Base.descendants.select do |model|
model_names.empty? || model.name.in?(model_names)
end
@models ||= ActiveRecord::Base.descendants.select do |model|
model_names.empty? || model.name.in?(model_names)
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/active_record/data_integrity/cop/cop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module DataIntegrity
# Checking cop base class
class Cop
attr_reader :model

delegate :connection, to: :model

def initialize(model)
Expand Down
8 changes: 5 additions & 3 deletions spec/internal/config/database.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
test:
adapter: postgresql
host: <%= ENV.fetch("DB_HOST") %>
database: <%= ENV.fetch("DB_NAME") %>
username: <%= ENV.fetch("DB_USERNAME") %>
host: <%= ENV.fetch("DB_HOST", "localhost") %>
database: <%= ENV.fetch("DB_NAME", "ar_di_test") %>
username: <%= ENV.fetch("DB_USERNAME", "postgres") %>
port: <%= ENV.fetch("DB_PORT", 5432) %>
password: <%= ENV.fetch("DB_PASSWORD", "") %>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ def change
create_table :belongs_to_users, &:timestamps

create_table :belongs_to_user_settings do |t|
t.integer :user_id
t.references :user, foreign_key: { to_table: :belongs_to_users }
t.text :data

Expand Down
8 changes: 6 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
require 'byebug'

require 'combustion'
Combustion.initialize! :all,
database_reset: true, database_migrate: true, load_schema: false
Combustion.initialize!(
:active_record,
database_reset: true,
database_migrate: true,
load_schema: false
)

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
Expand Down