Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
3f0efce0d8 | |||
eeedc57cd3 | |||
164eea1bde | |||
85fe3b0b38 | |||
519955e57a | |||
96b746822c | |||
eac833fd6d | |||
ad391c84a4 | |||
641c9315bc |
3
.gitignore
vendored
3
.gitignore
vendored
@ -65,3 +65,6 @@ node_modules/
|
||||
# Compiled assets
|
||||
public/css/
|
||||
public/js/
|
||||
|
||||
# Ignore production configuration files to protect against credential leaks
|
||||
config/production.yaml
|
||||
|
@ -1,11 +1,32 @@
|
||||
pipeline:
|
||||
steps:
|
||||
setup:
|
||||
image: ruby:3.4
|
||||
env:
|
||||
RACK_ENV: testing
|
||||
commands:
|
||||
- gem install rake
|
||||
- bundle config set --local path "vendor/bundle"
|
||||
- bundle install
|
||||
- rake db:migrate
|
||||
|
||||
test_ruby34:
|
||||
image: ruby:3.4
|
||||
env:
|
||||
RACK_ENV: testing
|
||||
commands:
|
||||
- gem install rake
|
||||
- bundle config set --local path "vendor/bundle"
|
||||
- rake test:unit
|
||||
group: tests
|
||||
|
||||
style:
|
||||
image: ruby:3.4
|
||||
env:
|
||||
RACK_ENV: testing
|
||||
commands:
|
||||
- 'gem install rake'
|
||||
- 'bundle config set --local path "vendor/bundle"'
|
||||
- 'bundle install'
|
||||
- 'rake test:rubocop'
|
||||
- gem install rake
|
||||
- bundle config set --local path "vendor/bundle"
|
||||
- rake test:lint
|
||||
|
||||
gitea_release:
|
||||
image: plugins/gitea-release
|
||||
@ -15,5 +36,5 @@ pipeline:
|
||||
base_url: https://git.metaunix.net
|
||||
title: "${CI_COMMIT_TAG}"
|
||||
when:
|
||||
event: tag
|
||||
|
||||
event:
|
||||
- tag
|
||||
|
15
Rakefile
15
Rakefile
@ -3,18 +3,22 @@ require 'bundler/setup'
|
||||
namespace :db do
|
||||
desc 'Run migrations'
|
||||
task :migrate, [:version] do |t, args|
|
||||
require "sequel/core"
|
||||
require 'sequel/core'
|
||||
# load configuration
|
||||
require_relative 'src/config'
|
||||
conf = Config.new()
|
||||
|
||||
Sequel.extension :migration
|
||||
version = args[:version].to_i if args[:version]
|
||||
Sequel.connect('sqlite://data/gamedata.db') do |db|
|
||||
Sequel::Migrator.run(db, "db/migrations", target: version)
|
||||
Sequel.connect(adapter: conf.get('database.adapter'), database: conf.get('database.database')) do |db|
|
||||
Sequel::Migrator.run(db, 'db/migrations', target: version)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :server do
|
||||
task :start do
|
||||
ENV['APP_ENV'] = 'production'
|
||||
ENV['RACK_ENV'] = 'production'
|
||||
system("puma")
|
||||
end
|
||||
|
||||
@ -28,8 +32,7 @@ namespace :test do
|
||||
system("rspec")
|
||||
end
|
||||
|
||||
task :rubocop do
|
||||
task :lint do
|
||||
system("rubocop src/ spec/")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
database:
|
||||
adapter: 'sqlite'
|
||||
database: 'data/gamedata.db'
|
||||
server:
|
||||
host: '0.0.0.0'
|
||||
port: '9292'
|
||||
|
||||
testing:
|
||||
minimum_results_required: 3
|
||||
|
3
config/development.yaml
Normal file
3
config/development.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
database:
|
||||
adapter: 'sqlite'
|
||||
database: 'data/gamedata.db'
|
@ -3,7 +3,9 @@ directory app_dir
|
||||
|
||||
environment ENV.fetch('RACK_ENV', 'development')
|
||||
|
||||
bind 'tcp://0.0.0.0:9292'
|
||||
require_relative '../src/config'
|
||||
conf = Config.new()
|
||||
|
||||
bind "tcp://#{conf.get('server.host')}:#{conf.get('server.port')}"
|
||||
workers 2
|
||||
threads 1, 5
|
||||
|
||||
|
3
config/testing.yaml
Normal file
3
config/testing.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
database:
|
||||
adapter: 'sqlite'
|
||||
database: 'data/gamedata_testing.db'
|
@ -7,8 +7,11 @@ RSpec.describe(BenchmarkController) do
|
||||
describe 'GET /benchmark' do
|
||||
before { get '/benchmark' }
|
||||
|
||||
it 'Benchmark base route redirects to /benchmark/list' do
|
||||
it 'Benchmark base route is a redirect' do
|
||||
expect(last_response).to(be_redirect)
|
||||
end
|
||||
|
||||
it 'Benchmark base route Location header points to /benchmark/list' do
|
||||
expect(last_response['Location']).to(eq("#{BASE_URL}/benchmark/list"))
|
||||
end
|
||||
end
|
||||
|
@ -7,8 +7,11 @@ RSpec.describe(HardwareController) do
|
||||
describe 'GET /hardware' do
|
||||
before { get '/hardware' }
|
||||
|
||||
it 'Hardware base route redirects to /hardware/list' do
|
||||
it 'Hardware base route is a redirect' do
|
||||
expect(last_response).to(be_redirect)
|
||||
end
|
||||
|
||||
it 'Hardware base route Location header points to /hardware/list' do
|
||||
expect(last_response['Location']).to(eq("#{BASE_URL}/hardware/list"))
|
||||
end
|
||||
end
|
||||
|
@ -7,8 +7,11 @@ RSpec.describe(TestController) do
|
||||
describe 'GET /test' do
|
||||
before { get '/test' }
|
||||
|
||||
it 'Test base route redirects to /test/list' do
|
||||
it 'Test base route is a redirect' do
|
||||
expect(last_response).to(be_redirect)
|
||||
end
|
||||
|
||||
it 'Test base route Location header points to /test/list' do
|
||||
expect(last_response['Location']).to(eq("#{BASE_URL}/test/list"))
|
||||
end
|
||||
end
|
||||
|
@ -6,8 +6,9 @@ require 'yaml'
|
||||
class Config
|
||||
|
||||
DEFAULT_CONFIG = 'config/defaults.yaml'
|
||||
ENVIRONMENT_CONFIG = ENV.fetch('RACK_ENV', 'development')
|
||||
|
||||
def initialize(config_path)
|
||||
def initialize(config_path = "config/#{ENVIRONMENT_CONFIG}.yaml")
|
||||
@data = YAML.load_file(DEFAULT_CONFIG)
|
||||
|
||||
# merge in user-defined configuration if it exists
|
||||
|
@ -6,7 +6,8 @@ require 'sqlite3'
|
||||
|
||||
require_relative 'config'
|
||||
|
||||
$conf = Config.new(File.join(__dir__, 'config/defaults.yaml'))
|
||||
# Load configuration from environment config file
|
||||
$conf = Config.new()
|
||||
|
||||
# Load the Sequel timestamps plugin
|
||||
Sequel::Model.plugin(:timestamps)
|
||||
|
Reference in New Issue
Block a user