Skip to content

Run tests using GitHub Actions #2

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

Merged
merged 1 commit into from
Mar 19, 2025
Merged
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
76 changes: 76 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions gemfiles/activerecord_7.0.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
2 changes: 1 addition & 1 deletion spec/support/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ContractType < ActiveRecord::Base
has_many :contracts, inverse_of: :contract_type
end

class Block < ApplicationRecord
class Block < ActiveRecord::Base
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting an uninitialized constant for ApplicationRecord so I changed this to match what all the other models do

Copy link
Collaborator

@derek-etherton-opslevel derek-etherton-opslevel Mar 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ope good call, the version I forked back to is targeting an older Ruby version than the PR I copied from

acts_as_tree order: :column_whereby_ordering_is_inferred, # <- symbol, and not "sort_order"
numeric_order: true,
dependent: :destroy,
Expand Down
4 changes: 3 additions & 1 deletion spec/support/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@
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"
Copy link
Collaborator Author

@Farjaad Farjaad Mar 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why I needed to change this (or why it was valid in the first place)

t.string "name"
t.string "title"
t.string "parent_uuid"
t.integer "sort_order"
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
Expand Down
Loading