diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 861668f..fc42d5c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,15 +1,18 @@ --- name: Tests -'on': + +on: push: branches: - master pull_request: branches: - master + jobs: test_mysql: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 + services: mysql: image: mysql:5.7 @@ -22,50 +25,57 @@ jobs: --health-interval=10s --health-timeout=5s --health-retries=3 + strategy: fail-fast: false matrix: include: - - ruby: 2.5.3 - gemfile: Gemfile.5.0 - - ruby: 2.5.3 - gemfile: Gemfile.5.1 + - ruby: 2.7.3 + gemfile: Gemfile.6.1.mysql2 + - ruby: 2.7.3 + gemfile: Gemfile.7.1.mysql2 + - ruby: 3.3.0 + gemfile: Gemfile.6.1.mysql2 + - ruby: 3.3.0 + gemfile: Gemfile.7.1.mysql2 + env: - BUNDLE_GEMFILE: "${{ matrix.gemfile }}" + BUNDLE_GEMFILE: ${{ matrix.gemfile }} + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install ruby uses: ruby/setup-ruby@v1 with: - ruby-version: "${{ matrix.ruby }}" - - name: Bundle - run: | - gem install bundler:2.1.4 - bundle install --no-deployment + ruby-version: ${{ matrix.ruby }} + bundler-cache: true - name: Setup databases run: | mysql -e 'create database IF NOT EXISTS assignable_values_test;' -u root --password=password -P 3306 -h 127.0.0.1 - name: Run tests run: bundle exec rspec + test_pg: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 + services: postgres: image: postgres env: POSTGRES_PASSWORD: postgres - options: "--health-cmd pg_isready --health-interval 10s --health-timeout 5s - --health-retries 5" + POSTGRES_DB: assignable_values_test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 ports: - 5432:5432 + strategy: fail-fast: false matrix: include: - - ruby: 2.5.3 - gemfile: Gemfile.5.1.pg - - ruby: 2.5.3 - gemfile: Gemfile.6.1.pg - ruby: 2.7.3 gemfile: Gemfile.6.1.pg - ruby: 2.7.3 @@ -78,21 +88,14 @@ jobs: gemfile: Gemfile.8.0.pg env: - BUNDLE_GEMFILE: "${{ matrix.gemfile }}" + BUNDLE_GEMFILE: ${{ matrix.gemfile }} + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install ruby uses: ruby/setup-ruby@v1 with: - ruby-version: "${{ matrix.ruby }}" - - name: Setup database - run: | - sudo apt-get update - sudo apt-get install -y postgresql-client - PGPASSWORD=postgres psql -c 'create database assignable_values_test;' -U postgres -p 5432 -h localhost - - name: Bundle - run: | - gem install bundler:2.1.4 - bundle install --no-deployment + ruby-version: ${{ matrix.ruby }} + bundler-cache: true - name: Run tests run: bundle exec rspec diff --git a/Gemfile.5.0.lock b/Gemfile.5.0.lock deleted file mode 100644 index 5e2289a..0000000 --- a/Gemfile.5.0.lock +++ /dev/null @@ -1,68 +0,0 @@ -PATH - remote: . - specs: - assignable_values (1.1.1) - activerecord (>= 2.3) - -GEM - remote: https://rubygems.org/ - specs: - activemodel (5.0.7.2) - activesupport (= 5.0.7.2) - activerecord (5.0.7.2) - activemodel (= 5.0.7.2) - activesupport (= 5.0.7.2) - arel (~> 7.0) - activesupport (5.0.7.2) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - arel (7.1.4) - concurrent-ruby (1.1.7) - database_cleaner (1.8.5) - diff-lcs (1.4.4) - gemika (0.7.1) - i18n (1.8.5) - concurrent-ruby (~> 1.0) - minitest (5.14.2) - mysql2 (0.5.3) - rake (13.0.1) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.0) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-support (3.10.0) - rspec_candy (0.5.1) - rspec - sneaky-save - sneaky-save (0.1.3) - activerecord (>= 3.2.0) - thread_safe (0.3.6) - tzinfo (1.2.7) - thread_safe (~> 0.1) - -PLATFORMS - ruby - -DEPENDENCIES - activerecord (~> 5.0.0) - assignable_values! - database_cleaner - gemika - i18n - mysql2 - rake - rspec - rspec_candy - -BUNDLED WITH - 2.1.4 diff --git a/Gemfile.5.1.lock b/Gemfile.5.1.lock deleted file mode 100644 index e886794..0000000 --- a/Gemfile.5.1.lock +++ /dev/null @@ -1,68 +0,0 @@ -PATH - remote: . - specs: - assignable_values (1.1.1) - activerecord (>= 2.3) - -GEM - remote: https://rubygems.org/ - specs: - activemodel (5.1.7) - activesupport (= 5.1.7) - activerecord (5.1.7) - activemodel (= 5.1.7) - activesupport (= 5.1.7) - arel (~> 8.0) - activesupport (5.1.7) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - arel (8.0.0) - concurrent-ruby (1.1.7) - database_cleaner (1.8.5) - diff-lcs (1.4.4) - gemika (0.7.1) - i18n (1.8.5) - concurrent-ruby (~> 1.0) - minitest (5.14.2) - mysql2 (0.5.3) - rake (13.0.1) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.0) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-support (3.10.0) - rspec_candy (0.5.1) - rspec - sneaky-save - sneaky-save (0.1.3) - activerecord (>= 3.2.0) - thread_safe (0.3.6) - tzinfo (1.2.7) - thread_safe (~> 0.1) - -PLATFORMS - ruby - -DEPENDENCIES - activerecord (~> 5.1.0) - assignable_values! - database_cleaner - gemika - i18n - mysql2 - rake - rspec - rspec_candy - -BUNDLED WITH - 2.1.4 diff --git a/Gemfile.5.1.pg b/Gemfile.5.1.pg deleted file mode 100644 index b16e0f4..0000000 --- a/Gemfile.5.1.pg +++ /dev/null @@ -1,16 +0,0 @@ -source 'https://rubygems.org' - -# Runtime dependencies -gem 'activerecord', '~>5.1.0' -gem 'i18n' -gem 'pg', '<1' - -# Development dependencies -gem 'rake' -gem 'database_cleaner' -gem 'rspec' -gem 'rspec_candy' -gem 'gemika' - -# Gem under test -gem 'assignable_values', :path => '.' diff --git a/Gemfile.5.1.pg.lock b/Gemfile.5.1.pg.lock deleted file mode 100644 index da57595..0000000 --- a/Gemfile.5.1.pg.lock +++ /dev/null @@ -1,68 +0,0 @@ -PATH - remote: . - specs: - assignable_values (1.1.1) - activerecord (>= 2.3) - -GEM - remote: https://rubygems.org/ - specs: - activemodel (5.1.4) - activesupport (= 5.1.4) - activerecord (5.1.4) - activemodel (= 5.1.4) - activesupport (= 5.1.4) - arel (~> 8.0) - activesupport (5.1.4) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (~> 0.7) - minitest (~> 5.1) - tzinfo (~> 1.1) - arel (8.0.0) - concurrent-ruby (1.0.5) - database_cleaner (1.6.1) - diff-lcs (1.3) - gemika (0.7.1) - i18n (0.9.0) - concurrent-ruby (~> 1.0) - minitest (5.10.3) - pg (0.21.0) - rake (12.1.0) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.0) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.0) - rspec_candy (0.4.1) - rspec - sneaky-save - sneaky-save (0.1.2) - activerecord (>= 3.2.0) - thread_safe (0.3.6) - tzinfo (1.2.3) - thread_safe (~> 0.1) - -PLATFORMS - ruby - -DEPENDENCIES - activerecord (~> 5.1.0) - assignable_values! - database_cleaner - gemika - i18n - pg (< 1) - rake - rspec - rspec_candy - -BUNDLED WITH - 2.1.4 diff --git a/Gemfile.5.0 b/Gemfile.6.1.mysql2 similarity index 80% rename from Gemfile.5.0 rename to Gemfile.6.1.mysql2 index 6a9b666..9983f1c 100644 --- a/Gemfile.5.0 +++ b/Gemfile.6.1.mysql2 @@ -1,7 +1,7 @@ source 'https://rubygems.org' # Runtime dependencies -gem 'activerecord', '~>5.0.0' +gem 'activerecord', '~>6.1.3' gem 'i18n' gem 'mysql2' @@ -10,7 +10,7 @@ gem 'rake' gem 'database_cleaner' gem 'rspec' gem 'rspec_candy' -gem 'gemika' +gem 'gemika', '~> 0.8.0' # Gem under test gem 'assignable_values', :path => '.' diff --git a/Gemfile.6.1.mysql2.lock b/Gemfile.6.1.mysql2.lock new file mode 100644 index 0000000..55b9f8f --- /dev/null +++ b/Gemfile.6.1.mysql2.lock @@ -0,0 +1,72 @@ +PATH + remote: . + specs: + assignable_values (1.1.1) + activerecord (>= 2.3) + +GEM + remote: https://rubygems.org/ + specs: + activemodel (6.1.7.10) + activesupport (= 6.1.7.10) + activerecord (6.1.7.10) + activemodel (= 6.1.7.10) + activesupport (= 6.1.7.10) + activesupport (6.1.7.10) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + concurrent-ruby (1.3.4) + database_cleaner (2.1.0) + database_cleaner-active_record (>= 2, < 3) + database_cleaner-active_record (2.2.0) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0.0) + database_cleaner-core (2.0.1) + diff-lcs (1.6.0) + gemika (0.8.4) + i18n (1.14.7) + concurrent-ruby (~> 1.0) + minitest (5.25.4) + mysql2 (0.5.6) + rake (13.2.1) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.3) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.2) + rspec_candy (0.5.1) + rspec + sneaky-save + sneaky-save (0.1.3) + activerecord (>= 3.2.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + zeitwerk (2.4.2) + +PLATFORMS + ruby + +DEPENDENCIES + activerecord (~> 6.1.3) + assignable_values! + database_cleaner + gemika (~> 0.8.0) + i18n + mysql2 + rake + rspec + rspec_candy + +BUNDLED WITH + 2.2.15 diff --git a/Gemfile.5.1 b/Gemfile.7.1.mysql2 similarity index 80% rename from Gemfile.5.1 rename to Gemfile.7.1.mysql2 index b87b07e..e3e2a7c 100644 --- a/Gemfile.5.1 +++ b/Gemfile.7.1.mysql2 @@ -1,7 +1,7 @@ source 'https://rubygems.org' # Runtime dependencies -gem 'activerecord', '~>5.1.0' +gem 'activerecord', '~>7.1.3' gem 'i18n' gem 'mysql2' @@ -10,7 +10,7 @@ gem 'rake' gem 'database_cleaner' gem 'rspec' gem 'rspec_candy' -gem 'gemika' +gem 'gemika', '~> 0.8.0' # Gem under test gem 'assignable_values', :path => '.' diff --git a/Gemfile.7.1.mysql2.lock b/Gemfile.7.1.mysql2.lock new file mode 100644 index 0000000..0f2e0f1 --- /dev/null +++ b/Gemfile.7.1.mysql2.lock @@ -0,0 +1,88 @@ +PATH + remote: . + specs: + assignable_values (1.1.1) + activerecord (>= 2.3) + +GEM + remote: https://rubygems.org/ + specs: + activemodel (7.1.5.1) + activesupport (= 7.1.5.1) + activerecord (7.1.5.1) + activemodel (= 7.1.5.1) + activesupport (= 7.1.5.1) + timeout (>= 0.4.0) + activesupport (7.1.5.1) + base64 + benchmark (>= 0.3) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + logger (>= 1.4.2) + minitest (>= 5.1) + mutex_m + securerandom (>= 0.3) + tzinfo (~> 2.0) + base64 (0.2.0) + benchmark (0.4.0) + bigdecimal (3.1.9) + concurrent-ruby (1.3.5) + connection_pool (2.5.0) + database_cleaner (2.1.0) + database_cleaner-active_record (>= 2, < 3) + database_cleaner-active_record (2.2.0) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0.0) + database_cleaner-core (2.0.1) + diff-lcs (1.6.0) + drb (2.2.1) + gemika (0.8.4) + i18n (1.14.7) + concurrent-ruby (~> 1.0) + logger (1.6.6) + minitest (5.25.4) + mutex_m (0.3.0) + mysql2 (0.5.6) + rake (13.2.1) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.3) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.2) + rspec_candy (0.5.1) + rspec + sneaky-save + securerandom (0.3.2) + sneaky-save (0.1.3) + activerecord (>= 3.2.0) + timeout (0.4.3) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + +PLATFORMS + ruby + +DEPENDENCIES + activerecord (~> 7.1.3) + assignable_values! + database_cleaner + gemika (~> 0.8.0) + i18n + mysql2 + rake + rspec + rspec_candy + +BUNDLED WITH + 2.2.15 diff --git a/README.md b/README.md index b082a3c..dd783bc 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ We carefully enhanced the core enum functionality with small tweaks that are useful for web forms, internationalized applications and common authorization patterns. -`assignable_values` is tested with Rails 5.1, 6.1 and 7.1 on Ruby 2.5, 2.7 and 3.3. +`assignable_values` is tested with Rails 6.1, 7.1 and 8.0 on Ruby 2.7 and 3.3. Restricting scalar attributes @@ -443,7 +443,7 @@ Development There are tests in `spec`. We only accept PRs with tests. To run tests: -- Install Ruby 2.3.8 +- Install Ruby 3.3.0 - Create a local test database `assignable_values_test` in both MySQL and PostgreSQL (see `.github/workflows/test.yml` for commands to do so) - Copy `spec/support/database.sample.yml` to `spec/support/database.yml` and enter your local @@ -459,7 +459,7 @@ We recommend to test large changes against multiple versions of Ruby and multipl Note that we have configured GitHub Actions to automatically run tests in all supported Ruby versions and dependency sets after each push. We will only merge pull requests after a green GitHub Actions run. -I'm very eager to keep this gem leightweight and on topic. If you're unsure whether a change would make it into the gem, [talk to me beforehand](mailto:henning.koch@makandra.de). +I'm very eager to keep this gem lightweight and on topic. If you're unsure whether a change would make it into the gem, [talk to me beforehand](mailto:henning.koch@makandra.de). Credits diff --git a/spec/support/database.rb b/spec/support/database.rb index 098a2fa..b2eaa8c 100644 --- a/spec/support/database.rb +++ b/spec/support/database.rb @@ -10,7 +10,11 @@ t.string :genre t.integer :year t.integer :duration - t.string :multi_genres, :array => true + if defined?(Mysql2) + t.string :multi_genres + else + t.string :multi_genres, :array => true + end t.json :metadata end