Skip to content

Commit

Permalink
Merge branch 'master' into updates
Browse files Browse the repository at this point in the history
* master:
  Refresh dependencies and revise CI matrix
  0.5.0: Ability to ignore columns from a model (#17)
  Add ability to ignore columns from a model (#17)
  Enhance CI matrix to include optional head versions
  Migrate from Travis CI to Github Actions
  Fix loading of database.yml for tests in newer versions of Ruby
  Add missing `end` to the README example (#18) [ci skip]
  0.4.0: Ignore generated database columns (#16)
  Ignore virtual columns in insert statements (#16)
  Fix README typo (#14)
  • Loading branch information
Envek committed Jun 18, 2024
2 parents fad4ff7 + 10fde7d commit 5267e2b
Show file tree
Hide file tree
Showing 22 changed files with 158 additions and 212 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Tests

on:
push:
branches:
- '**'
tags-ignore:
- 'v*'
pull_request:

jobs:
test:
name: Ruby ${{ matrix.ruby }}, ActiveRecord ${{ matrix.activerecord }}, ${{ matrix.database }}
continue-on-error: ${{ matrix.ruby == 'head' }}
strategy:
fail-fast: false
matrix:
include:
- ruby: "head"
activerecord: "head"
database: sqlite
- ruby: "3.3"
activerecord: "7.1"
database: postgresql
- ruby: "3.3"
activerecord: "7.1"
database: mysql
- ruby: "3.3"
activerecord: "7.1"
database: sqlite
- ruby: "3.2"
activerecord: "7.0"
database: sqlite
- ruby: "3.1"
activerecord: "6.1"
database: sqlite
- ruby: "3.0"
activerecord: "6.0"
database: sqlite

runs-on: ubuntu-latest

services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:8.4
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: evil_seed_test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

env:
CI: true
ACTIVERECORD_VERSION: "${{ matrix.activerecord }}"
DB: "${{ matrix.database }}"
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rake
82 changes: 0 additions & 82 deletions .travis.yml

This file was deleted.

48 changes: 0 additions & 48 deletions Appraisals

This file was deleted.

13 changes: 13 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,16 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in evil-seed.gemspec
gemspec

activerecord_version = ENV.fetch("ACTIVERECORD_VERSION", "~> 7.1")
case activerecord_version.upcase
when "HEAD"
git "https://github.com/rails/rails.git" do
gem "activerecord"
gem "rails"
end
else
activerecord_version = "~> #{activerecord_version}.0" if activerecord_version.match?(/^\d+\.\d+$/)
gem "activerecord", activerecord_version
gem "sqlite3", "~> 1.4"
end
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,19 @@ EvilSeed.configure do |config|

# Anonymization is a handy DSL for transformations allowing you to transform model attributes in declarative fashion
# Please note that model setters will NOT be called: results of the blocks will be assigned to
config.anonymize("User")
config.anonymize("User") do
name { Faker::Name.name }
email { Faker::Internet.email }
login { |login| "#{login}-test" }
end

# You can ignore columns for any model. This is specially useful when working
# with encrypted columns.
#
# This will remove the columns even if the model is not a root node and is
# dumped via an association.
config.ignore_columns("Profile", :name)
end
```

### Creating dump
Expand Down
1 change: 0 additions & 1 deletion evil-seed.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'appraisal'
end
2 changes: 0 additions & 2 deletions gemfiles/.bundle/config

This file was deleted.

10 changes: 0 additions & 10 deletions gemfiles/activerecord_5_0.gemfile

This file was deleted.

10 changes: 0 additions & 10 deletions gemfiles/activerecord_5_1.gemfile

This file was deleted.

10 changes: 0 additions & 10 deletions gemfiles/activerecord_5_2.gemfile

This file was deleted.

10 changes: 0 additions & 10 deletions gemfiles/activerecord_6_0.gemfile

This file was deleted.

10 changes: 0 additions & 10 deletions gemfiles/activerecord_6_1.gemfile

This file was deleted.

10 changes: 0 additions & 10 deletions gemfiles/activerecord_master.gemfile

This file was deleted.

12 changes: 8 additions & 4 deletions lib/evil_seed/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
module EvilSeed
# This module holds configuration for creating dump: which models and their constraints
class Configuration
attr_accessor :record_dumper_class, :verbose, :verbose_sql, :unscoped, :dont_nullify, :skip_columns
attr_accessor :record_dumper_class, :verbose, :verbose_sql, :unscoped, :dont_nullify

def initialize
@record_dumper_class = RecordDumper
@verbose = false
@verbose_sql = false
@unscoped = true
@dont_nullify = false
@skip_columns = {}
@ignored_columns = Hash.new { |h, k| h[k] = [] }
end

def roots
Expand All @@ -38,14 +38,18 @@ def anonymize(model_class, &block)
customizers[model_class.to_s] << Anonymizer.new(model_class, &block)
end

def ignore_columns(model_class, *columns)
@ignored_columns[model_class] += columns
end

# Customizer objects for every model
# @return [Hash{String => Array<#call>}]
def customizers
@customizers ||= Hash.new { |h, k| h[k] = [] }
end

def add_skip_columns(table_name, column_names)
@skip_columns[table_name] = column_names
def ignored_columns_for(model_class)
@ignored_columns[model_class]
end
end
end
Loading

0 comments on commit 5267e2b

Please sign in to comment.