Skip to content

Add dummy Rails app test suite and add Github CI workflow #62

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
54 changes: 54 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test
on:
push:
branches: ['master']
pull_request:

jobs:
test:
runs-on: ubuntu-latest

env:
RAILS_ENV: test

strategy:
fail-fast: false
matrix:
include:
### TEST RUBY VERSIONS
- ruby: "2.5"
- ruby: "2.6"
- ruby: "2.7"
- ruby: "3.0"
- ruby: "3.1"
- ruby: "3.2"
### TEST RAILS VERSIONS
- ruby: "2.6"
env:
RAILS_VERSION: "5.2"
- ruby: "2.6"
env:
RAILS_VERSION: "6.0"
- ruby: "2.6"
env:
RAILS_VERSION: "6.1"
- ruby: "3.2"
env:
RAILS_VERSION: "7.0"
- ruby: "3.2"
env:
RAILS_VERSION: "7.1"

steps:
- uses: actions/checkout@v3

- name: Install ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "${{ matrix.ruby }}"
bundler-cache: false ### not compatible with ENV style gemfile

- name: Run test
run: |
bundle install
bundle exec rake test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
/test/*.sqlite3*
/production/*.sqlite3*
.DS_Store
/test/dummy_app/**/*.sqlite3*
/test/dummy_app/**/*.log
/test/dummy_app/tmp/
Gemfile.lock
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fix Litesearch tests
- Suppress chatty Litejob exit detector when there are no jobs in flight
- Tidy up the test folder
- [#xx](https://github.com/oldmoe/litestack/pull/xx) - Add dummy Rails app for test suite and Github CI workflow

## [0.4.1] - 2023-10-11

Expand Down
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ source "https://rubygems.org"

# Specify your gem's dependencies in litestack.gemspec
gemspec

def get_env(name)
(ENV[name] && !ENV[name].empty?) ? ENV[name] : nil
end

gem 'rails', get_env("RAILS_VERSION")
92 changes: 0 additions & 92 deletions Gemfile.lock

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
![litestack](https://github.com/oldmoe/litestack/blob/master/assets/litestack_logo_teal_large.png?raw=true)

<a href='https://github.com/oldmoe/litestack/actions' target='_blank'><img src="https://github.com/oldmoe/litestack/actions/workflows/test.yml/badge.svg?branch=master" style="max-width:100%;" height='21' style='border:0px;height:21px;' border='0' alt="CI Status"></a>

All your data infrastructure, in a gem!

Litestack is a Ruby gem that provides both Ruby and Ruby on Rails applications an all-in-one solution for web application data infrastructure. It exploits the power and embeddedness of SQLite to deliver a full-fledged SQL database, a fast cache , a robust job queue, a reliable message broker, a full text search engine and a metrics platform all in a single package.
Expand Down
7 changes: 7 additions & 0 deletions test/dummy_app/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Dummy::Application.load_tasks
3 changes: 3 additions & 0 deletions test/dummy_app/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css .scss
Empty file.
3 changes: 3 additions & 0 deletions test/dummy_app/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
*= require_self
*/
7 changes: 7 additions & 0 deletions test/dummy_app/app/channels/application_cable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end

class Connection < ActionCable::Connection::Base
end
end
3 changes: 3 additions & 0 deletions test/dummy_app/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationController < ActionController::Base
protect_from_forgery
end
2 changes: 2 additions & 0 deletions test/dummy_app/app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ApplicationJob < ActiveJob::Base
end
Empty file.
3 changes: 3 additions & 0 deletions test/dummy_app/app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
3 changes: 3 additions & 0 deletions test/dummy_app/app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Comment < ApplicationRecord
belongs_to :post
end
3 changes: 3 additions & 0 deletions test/dummy_app/app/models/post.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Post < ApplicationRecord
has_many :comments
end
14 changes: 14 additions & 0 deletions test/dummy_app/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy App</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>

<%= yield %>

</body>
</html>
4 changes: 4 additions & 0 deletions test/dummy_app/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Dummy::Application
48 changes: 48 additions & 0 deletions test/dummy_app/config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'

Bundler.require

module Dummy
class Application < Rails::Application
config.load_defaults Rails::VERSION::STRING.to_f

# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]

config.generators.test_framework = false
config.generators.helper = false
config.generators.stylesheets = false
config.generators.javascripts = false

config.after_initialize do
ActiveRecord::Migration.migrate(Rails.root.join("db/migrate/*").to_s)
end
end
end
10 changes: 10 additions & 0 deletions test/dummy_app/config/boot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'rubygems'
gemfile = File.expand_path('../../../../Gemfile', __FILE__)

if File.exist?(gemfile)
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
end

$:.unshift File.expand_path('../../../../lib', __FILE__)
6 changes: 6 additions & 0 deletions test/dummy_app/config/cable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
development:
adapter: litecable

test:
adapter: test
#adapter: litecable
7 changes: 7 additions & 0 deletions test/dummy_app/config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
development:
adapter: litedb
database: db/development/database.sqlite3.db

test:
adapter: litedb
database: db/test/database.sqlite3.db
5 changes: 5 additions & 0 deletions test/dummy_app/config/environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
Dummy::Application.initialize!
41 changes: 41 additions & 0 deletions test/dummy_app/config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true

# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }

# Log error messages when you accidentally call methods on nil
config.whiny_nils = true

# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false

# Raise exceptions instead of rendering exception templates
config.action_dispatch.show_exceptions = false

# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false

# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test

# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql

# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr

config.eager_load = false
end
8 changes: 8 additions & 0 deletions test/dummy_app/config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Be sure to restart your server when you modify this file.

Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
# Dummy::Application.config.session_store :active_record_store
14 changes: 14 additions & 0 deletions test/dummy_app/config/initializers/wrap_parameters.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.

# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json]
end

# Disable root element in JSON by default.
ActiveSupport.on_load(:active_record) do
self.include_root_in_json = false
end
2 changes: 2 additions & 0 deletions test/dummy_app/config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dummy::Application.routes.draw do
end
Loading