diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..4e7020ea --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,76 @@ +--- +name: Tests + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "**" ] + +jobs: + test: + runs-on: ubuntu-20.04 + + services: + postgres: + image: "postgres:13" + ports: ["5432:5432"] + env: + POSTGRES_PASSWORD: postgres + POSTGRES_DB: closure_tree + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + strategy: + fail-fast: false + matrix: + ruby: + - "3.2.5" + rails: + - activerecord_7.0 + adapter: + - sqlite3 + - mysql2 + - postgresql + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + + - name: Set DB Adapter + env: + RAILS_VERSION: ${{ matrix.rails }} + DB_ADAPTER: ${{ matrix.adapter }} + + # See: https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#mysql + run: | + if [ "${DB_ADAPTER}" = "mysql2" ]; then + sudo systemctl start mysql.service + mysql -u root -proot -e "create database closure_tree;" + fi + + - name: Bundle + env: + RAILS_VERSION: ${{ matrix.rails }} + DB_ADAPTER: ${{ matrix.adapter }} + BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile + run: | + gem install bundler + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + + - name: RSpec + env: + RAILS_VERSION: ${{ matrix.rails }} + DB_ADAPTER: ${{ matrix.adapter }} + BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile + WITH_ADVISORY_LOCK_PREFIX: ${{ github.run_id }} + run: bin/rake --trace spec:all \ No newline at end of file diff --git a/Appraisals b/Appraisals index 98d02c51..a88f6246 100644 --- a/Appraisals +++ b/Appraisals @@ -89,6 +89,21 @@ appraise 'activerecord-6.1' do end end +appraise 'activerecord-7.0' do + gem 'activerecord', '~> 7.0' + platforms :ruby do + gem 'mysql2' + gem 'pg' + gem 'sqlite3' + end + + platforms :jruby do + gem 'activerecord-jdbcmysql-adapter' + gem 'activerecord-jdbcpostgresql-adapter' + gem 'activerecord-jdbcsqlite3-adapter' + end +end + appraise 'activerecord-edge' do gem 'activerecord', github: 'rails/rails' platforms :ruby do diff --git a/Rakefile b/Rakefile index 58751bf1..bb87ad7c 100644 --- a/Rakefile +++ b/Rakefile @@ -26,12 +26,3 @@ namespace :spec do task.pattern = 'spec/generators/*_spec.rb' end end - -require 'github_changelog_generator/task' -GitHubChangelogGenerator::RakeTask.new :changelog do |config| - config.user = 'ClosureTree' - config.project = 'closure_tree' - config.issues = false - config.future_release = '5.2.0' - config.since_tag = 'v7.3.0' -end diff --git a/gemfiles/activerecord_7.0.gemfile b/gemfiles/activerecord_7.0.gemfile new file mode 100644 index 00000000..f50ebabc --- /dev/null +++ b/gemfiles/activerecord_7.0.gemfile @@ -0,0 +1,21 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "bump", "~> 0.10.0" +gem "github_changelog_generator", "~> 1.16" +gem "activerecord", "~> 7.0" + +platforms :ruby do + gem "mysql2" + gem "pg" + gem "sqlite3" +end + +platforms :jruby do + gem "activerecord-jdbcmysql-adapter" + gem "activerecord-jdbcpostgresql-adapter" + gem "activerecord-jdbcsqlite3-adapter" +end + +gemspec path: "../" diff --git a/spec/support/models.rb b/spec/support/models.rb index b9b45d7a..7c51aac1 100644 --- a/spec/support/models.rb +++ b/spec/support/models.rb @@ -78,7 +78,7 @@ class ContractType < ActiveRecord::Base has_many :contracts, inverse_of: :contract_type end -class Block < ApplicationRecord +class Block < ActiveRecord::Base acts_as_tree order: :column_whereby_ordering_is_inferred, # <- symbol, and not "sort_order" numeric_order: true, dependent: :destroy, diff --git a/spec/support/schema.rb b/spec/support/schema.rb index cf6a0331..5346a791 100644 --- a/spec/support/schema.rb +++ b/spec/support/schema.rb @@ -30,7 +30,7 @@ add_foreign_key(:tag_hierarchies, :tags, :column => 'descendant_id') create_table "uuid_tags", :id => false do |t| - t.string "uuid", :unique => true + t.string "uuid" t.string "name" t.string "title" t.string "parent_uuid" @@ -38,6 +38,8 @@ t.timestamps null: false end + add_index "uuid_tags", :uuid, unique: true + create_table "uuid_tag_hierarchies", :id => false do |t| t.string "ancestor_id", :null => false t.string "descendant_id", :null => false