Skip to content

Commit 4a81efa

Browse files
authored
Merge pull request #2 from OpsLevel/run-tests
Run tests using GitHub Actions
2 parents b816694 + 9ea773d commit 4a81efa

File tree

6 files changed

+116
-11
lines changed

6 files changed

+116
-11
lines changed

.github/workflows/tests.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
name: Tests
3+
4+
on:
5+
push:
6+
branches: [ "master" ]
7+
pull_request:
8+
branches: [ "**" ]
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-20.04
13+
14+
services:
15+
postgres:
16+
image: "postgres:13"
17+
ports: ["5432:5432"]
18+
env:
19+
POSTGRES_PASSWORD: postgres
20+
POSTGRES_DB: closure_tree
21+
options: >-
22+
--health-cmd pg_isready
23+
--health-interval 10s
24+
--health-timeout 5s
25+
--health-retries 5
26+
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
ruby:
31+
- "3.2.5"
32+
rails:
33+
- activerecord_7.0
34+
adapter:
35+
- sqlite3
36+
- mysql2
37+
- postgresql
38+
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
43+
- name: Setup Ruby
44+
uses: ruby/setup-ruby@v1
45+
with:
46+
ruby-version: ${{ matrix.ruby }}
47+
48+
- name: Set DB Adapter
49+
env:
50+
RAILS_VERSION: ${{ matrix.rails }}
51+
DB_ADAPTER: ${{ matrix.adapter }}
52+
53+
# See: https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#mysql
54+
run: |
55+
if [ "${DB_ADAPTER}" = "mysql2" ]; then
56+
sudo systemctl start mysql.service
57+
mysql -u root -proot -e "create database closure_tree;"
58+
fi
59+
60+
- name: Bundle
61+
env:
62+
RAILS_VERSION: ${{ matrix.rails }}
63+
DB_ADAPTER: ${{ matrix.adapter }}
64+
BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
65+
run: |
66+
gem install bundler
67+
bundle config path vendor/bundle
68+
bundle install --jobs 4 --retry 3
69+
70+
- name: RSpec
71+
env:
72+
RAILS_VERSION: ${{ matrix.rails }}
73+
DB_ADAPTER: ${{ matrix.adapter }}
74+
BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
75+
WITH_ADVISORY_LOCK_PREFIX: ${{ github.run_id }}
76+
run: bin/rake --trace spec:all

Appraisals

+15
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ appraise 'activerecord-6.1' do
8989
end
9090
end
9191

92+
appraise 'activerecord-7.0' do
93+
gem 'activerecord', '~> 7.0'
94+
platforms :ruby do
95+
gem 'mysql2'
96+
gem 'pg'
97+
gem 'sqlite3'
98+
end
99+
100+
platforms :jruby do
101+
gem 'activerecord-jdbcmysql-adapter'
102+
gem 'activerecord-jdbcpostgresql-adapter'
103+
gem 'activerecord-jdbcsqlite3-adapter'
104+
end
105+
end
106+
92107
appraise 'activerecord-edge' do
93108
gem 'activerecord', github: 'rails/rails'
94109
platforms :ruby do

Rakefile

-9
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,3 @@ namespace :spec do
2626
task.pattern = 'spec/generators/*_spec.rb'
2727
end
2828
end
29-
30-
require 'github_changelog_generator/task'
31-
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
32-
config.user = 'ClosureTree'
33-
config.project = 'closure_tree'
34-
config.issues = false
35-
config.future_release = '5.2.0'
36-
config.since_tag = 'v7.3.0'
37-
end

gemfiles/activerecord_7.0.gemfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "bump", "~> 0.10.0"
6+
gem "github_changelog_generator", "~> 1.16"
7+
gem "activerecord", "~> 7.0"
8+
9+
platforms :ruby do
10+
gem "mysql2"
11+
gem "pg"
12+
gem "sqlite3"
13+
end
14+
15+
platforms :jruby do
16+
gem "activerecord-jdbcmysql-adapter"
17+
gem "activerecord-jdbcpostgresql-adapter"
18+
gem "activerecord-jdbcsqlite3-adapter"
19+
end
20+
21+
gemspec path: "../"

spec/support/models.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ContractType < ActiveRecord::Base
7878
has_many :contracts, inverse_of: :contract_type
7979
end
8080

81-
class Block < ApplicationRecord
81+
class Block < ActiveRecord::Base
8282
acts_as_tree order: :column_whereby_ordering_is_inferred, # <- symbol, and not "sort_order"
8383
numeric_order: true,
8484
dependent: :destroy,

spec/support/schema.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@
3030
add_foreign_key(:tag_hierarchies, :tags, :column => 'descendant_id')
3131

3232
create_table "uuid_tags", :id => false do |t|
33-
t.string "uuid", :unique => true
33+
t.string "uuid"
3434
t.string "name"
3535
t.string "title"
3636
t.string "parent_uuid"
3737
t.integer "sort_order"
3838
t.timestamps null: false
3939
end
4040

41+
add_index "uuid_tags", :uuid, unique: true
42+
4143
create_table "uuid_tag_hierarchies", :id => false do |t|
4244
t.string "ancestor_id", :null => false
4345
t.string "descendant_id", :null => false

0 commit comments

Comments
 (0)