Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
39f95575da | |||
6e1ab89209 | |||
9cd6c78741 | |||
5b730df803 | |||
0ce4a3ecee | |||
12ece12394 | |||
05c20b5811 | |||
bd822664b0 | |||
3f0efce0d8 | |||
eeedc57cd3 | |||
164eea1bde | |||
85fe3b0b38 | |||
519955e57a | |||
96b746822c | |||
eac833fd6d | |||
ad391c84a4 | |||
641c9315bc |
3
.gitignore
vendored
3
.gitignore
vendored
@ -65,3 +65,6 @@ node_modules/
|
|||||||
# Compiled assets
|
# Compiled assets
|
||||||
public/css/
|
public/css/
|
||||||
public/js/
|
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:
|
style:
|
||||||
image: ruby:3.4
|
image: ruby:3.4
|
||||||
|
env:
|
||||||
|
RACK_ENV: testing
|
||||||
commands:
|
commands:
|
||||||
- 'gem install rake'
|
- gem install rake
|
||||||
- 'bundle config set --local path "vendor/bundle"'
|
- bundle config set --local path "vendor/bundle"
|
||||||
- 'bundle install'
|
- rake test:lint
|
||||||
- 'rake test:rubocop'
|
|
||||||
|
|
||||||
gitea_release:
|
gitea_release:
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
@ -15,5 +36,5 @@ pipeline:
|
|||||||
base_url: https://git.metaunix.net
|
base_url: https://git.metaunix.net
|
||||||
title: "${CI_COMMIT_TAG}"
|
title: "${CI_COMMIT_TAG}"
|
||||||
when:
|
when:
|
||||||
event: tag
|
event:
|
||||||
|
- tag
|
||||||
|
1
Gemfile
1
Gemfile
@ -22,4 +22,5 @@ end
|
|||||||
group :test do
|
group :test do
|
||||||
gem 'rspec'
|
gem 'rspec'
|
||||||
gem 'rack-test'
|
gem 'rack-test'
|
||||||
|
gem 'database_cleaner-sequel'
|
||||||
end
|
end
|
||||||
|
@ -4,6 +4,10 @@ GEM
|
|||||||
ast (2.4.3)
|
ast (2.4.3)
|
||||||
base64 (0.3.0)
|
base64 (0.3.0)
|
||||||
bigdecimal (3.2.2)
|
bigdecimal (3.2.2)
|
||||||
|
database_cleaner-core (2.0.1)
|
||||||
|
database_cleaner-sequel (2.0.2)
|
||||||
|
database_cleaner-core (~> 2.0.0)
|
||||||
|
sequel
|
||||||
diff-lcs (1.6.2)
|
diff-lcs (1.6.2)
|
||||||
ffi (1.17.2-aarch64-linux-gnu)
|
ffi (1.17.2-aarch64-linux-gnu)
|
||||||
ffi (1.17.2-aarch64-linux-musl)
|
ffi (1.17.2-aarch64-linux-musl)
|
||||||
@ -129,6 +133,7 @@ PLATFORMS
|
|||||||
x86_64-linux-musl
|
x86_64-linux-musl
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
database_cleaner-sequel
|
||||||
logger
|
logger
|
||||||
puma (~> 6.6)
|
puma (~> 6.6)
|
||||||
rack-test
|
rack-test
|
||||||
|
44
README.md
44
README.md
@ -1,5 +1,7 @@
|
|||||||
# Game Data
|
# Game Data
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
Web-based tool to store and organize PC hardware gaming benchmarks.
|
Web-based tool to store and organize PC hardware gaming benchmarks.
|
||||||
|
|
||||||
## Project Goals
|
## Project Goals
|
||||||
@ -7,28 +9,58 @@ Web-based tool to store and organize PC hardware gaming benchmarks.
|
|||||||
The goals of this project are to:
|
The goals of this project are to:
|
||||||
|
|
||||||
* Record benchmarking results from multiple devices - e.g. log from a laptop or a phone.
|
* Record benchmarking results from multiple devices - e.g. log from a laptop or a phone.
|
||||||
* Group results into tests - it's good practice to run a benchmark multiple times for accuracy.
|
* Group results into tests to keep track of different testing configurations.
|
||||||
|
* Encourage running tests multiple times - it's good practice to run a benchmark multiple times for accuracy.
|
||||||
* Create comparisons of hardware tests to compare performance.
|
* Create comparisons of hardware tests to compare performance.
|
||||||
* Generate graphs of hardware comparisons for usage in videos and articles.
|
* Generate graphs of hardware comparisons for usage in videos and articles.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Game Data runs on Ruby, and takes advantage of Bundler to manage code dependencies and Rake to run various tasks for maintaining the app. You can install them globally like so:
|
Game Data runs on Ruby, and takes advantage of [Bundler](https://bundler.io/) to manage code dependencies and [Rake](https://ruby.github.io/rake/) to run various tasks for maintaining the app. You can install them globally like so:
|
||||||
|
|
||||||
Debian/Ubuntu: `apt install -y ruby ruby-bundler rake`
|
Debian/Ubuntu: `apt install -y ruby ruby-bundler rake`
|
||||||
|
RedHat and clones: `dnf install -y ruby rubygem-bundler rubygem-rake`
|
||||||
|
|
||||||
|
## Production Deployment
|
||||||
|
|
||||||
|
**TBD**
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
Install dependencies via bundler:
|
### Via Docker
|
||||||
|
|
||||||
|
If you'd prefer not to install dependencies and such to your local OS, you can do the development via Docker. The scripts provided in `bin/` will build Docker images for running the Ruby app and building the front-end assets via Gulp. *Both containers will automatically watch for changes.*
|
||||||
|
|
||||||
|
**Note:** Using the scripts below, the Docker images will remove themselves when stopped. This is to make clean up a bit more streamlined.
|
||||||
|
|
||||||
|
1. [Install Docker](https://docs.docker.com/engine/install/) for your OS.
|
||||||
|
|
||||||
|
2. Build the docker images for Ruby and Gulp:
|
||||||
|
|
||||||
|
`bin/docker-build.sh`
|
||||||
|
|
||||||
|
3. Run the docker images:
|
||||||
|
|
||||||
|
`bin/docker-run.sh`
|
||||||
|
|
||||||
|
4. If everything is running successfully you can open your browser and go to https://localhost:9292.
|
||||||
|
|
||||||
|
### Local/Native Development
|
||||||
|
|
||||||
|
1. Install dependencies via bundler:
|
||||||
|
|
||||||
`bundle install`
|
`bundle install`
|
||||||
|
|
||||||
Perform database migrations:
|
2. Perform database migrations:
|
||||||
|
|
||||||
`rake db:migrate`
|
`rake db:migrate`
|
||||||
|
|
||||||
Run the server in development with auto-reloading:
|
3. Run the server in development with auto-reloading:
|
||||||
|
|
||||||
`rake server:dev`
|
`rake server:dev`
|
||||||
|
|
||||||
If everything is running successfully you can open your browser and go to https://localhost:9292.
|
4. If everything is running successfully you can open your browser and go to https://localhost:9292.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is available under the BSD 2-Clause license.
|
||||||
|
16
Rakefile
16
Rakefile
@ -3,18 +3,22 @@ require 'bundler/setup'
|
|||||||
namespace :db do
|
namespace :db do
|
||||||
desc 'Run migrations'
|
desc 'Run migrations'
|
||||||
task :migrate, [:version] do |t, args|
|
task :migrate, [:version] do |t, args|
|
||||||
require "sequel/core"
|
require 'sequel/core'
|
||||||
|
# load configuration
|
||||||
|
require_relative 'src/config'
|
||||||
|
conf = Config.new()
|
||||||
|
|
||||||
Sequel.extension :migration
|
Sequel.extension :migration
|
||||||
version = args[:version].to_i if args[:version]
|
version = args[:version].to_i if args[:version]
|
||||||
Sequel.connect('sqlite://data/gamedata.db') do |db|
|
Sequel.connect(adapter: conf.get('database.adapter'), database: conf.get('database.database')) do |db|
|
||||||
Sequel::Migrator.run(db, "db/migrations", target: version)
|
Sequel::Migrator.run(db, 'db/migrations', target: version)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :server do
|
namespace :server do
|
||||||
task :start do
|
task :start do
|
||||||
ENV['APP_ENV'] = 'production'
|
ENV['RACK_ENV'] = 'production'
|
||||||
system("puma")
|
system("puma")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -25,11 +29,11 @@ end
|
|||||||
|
|
||||||
namespace :test do
|
namespace :test do
|
||||||
task :unit do
|
task :unit do
|
||||||
|
ENV['RACK_ENV'] = 'testing'
|
||||||
system("rspec")
|
system("rspec")
|
||||||
end
|
end
|
||||||
|
|
||||||
task :rubocop do
|
task :lint do
|
||||||
system("rubocop src/ spec/")
|
system("rubocop src/ spec/")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
database:
|
server:
|
||||||
adapter: 'sqlite'
|
host: '0.0.0.0'
|
||||||
database: 'data/gamedata.db'
|
port: '9292'
|
||||||
|
|
||||||
testing:
|
testing:
|
||||||
minimum_results_required: 3
|
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')
|
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
|
workers 2
|
||||||
threads 1, 5
|
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
|
describe 'GET /benchmark' do
|
||||||
before { get '/benchmark' }
|
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)
|
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"))
|
expect(last_response['Location']).to(eq("#{BASE_URL}/benchmark/list"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,8 +7,11 @@ RSpec.describe(HardwareController) do
|
|||||||
describe 'GET /hardware' do
|
describe 'GET /hardware' do
|
||||||
before { get '/hardware' }
|
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)
|
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"))
|
expect(last_response['Location']).to(eq("#{BASE_URL}/hardware/list"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,8 +7,11 @@ RSpec.describe(TestController) do
|
|||||||
describe 'GET /test' do
|
describe 'GET /test' do
|
||||||
before { get '/test' }
|
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)
|
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"))
|
expect(last_response['Location']).to(eq("#{BASE_URL}/test/list"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
27
spec/models/benchmark_model_spec.rb
Normal file
27
spec/models/benchmark_model_spec.rb
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require_relative '../spec_helper'
|
||||||
|
|
||||||
|
RSpec.describe(Benchmark) do
|
||||||
|
describe 'Benchmark Creation' do
|
||||||
|
it 'Benchmark creation updates model count.' do
|
||||||
|
expect do
|
||||||
|
described_class.create(name: 'Test Benchmark', scoring: 'fps')
|
||||||
|
end.to(change(described_class, :count).by(1))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'Benchmark Read' do
|
||||||
|
before { described_class.create(name: 'Test Benchmark', scoring: 'fps') }
|
||||||
|
|
||||||
|
it 'Benchmark model has name.' do
|
||||||
|
bench = described_class.first()
|
||||||
|
expect(bench.name).to(eq('Test Benchmark'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Benchmark model has scoring.' do
|
||||||
|
bench = described_class.first()
|
||||||
|
expect(bench.scoring).to(eq('fps'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
25
spec/models/hardware_model_spec.rb
Normal file
25
spec/models/hardware_model_spec.rb
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require_relative '../spec_helper'
|
||||||
|
|
||||||
|
RSpec.describe(Hardware) do
|
||||||
|
describe 'Hardware Creation' do
|
||||||
|
it 'Hardware creation updates model count.' do
|
||||||
|
expect { described_class.create(name: 'Test Hardware', type: 'gpu') }.to(change(described_class, :count).by(1))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'Hardware Read' do
|
||||||
|
before { described_class.create(name: 'Test Hardware', type: 'gpu') }
|
||||||
|
|
||||||
|
it 'Hardware model has name.' do
|
||||||
|
hardware = described_class.first()
|
||||||
|
expect(hardware.name).to(eq('Test Hardware'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Hardware model has scoring.' do
|
||||||
|
hardware = described_class.first()
|
||||||
|
expect(hardware.type).to(eq('gpu'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
36
spec/models/test_model_spec.rb
Normal file
36
spec/models/test_model_spec.rb
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require_relative '../spec_helper'
|
||||||
|
|
||||||
|
RSpec.describe(Test) do
|
||||||
|
describe 'Test Creation' do
|
||||||
|
it 'Test creation updates model count.' do
|
||||||
|
expect { described_class.create(name: 'Test Test') }.to(change(described_class, :count).by(1))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'Test Read' do
|
||||||
|
before do
|
||||||
|
described_class.create(name: 'Test Test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Test model has name.' do
|
||||||
|
tst = described_class.first()
|
||||||
|
expect(tst.name).to(eq('Test Test'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'Test one-to-many association with Hardware' do
|
||||||
|
it 'Test model has Hardware associated with it.' do
|
||||||
|
hardware = Hardware.create(name: 'Test Hardware', type: 'gpu')
|
||||||
|
tst = described_class.create(name: 'Test Test', hardware_id: hardware.id)
|
||||||
|
expect(tst.hardware).to(eq(hardware))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Test model\'s hardware has name set.' do
|
||||||
|
hardware = Hardware.create(name: 'Test Hardware', type: 'gpu')
|
||||||
|
tst = described_class.create(name: 'Test Test', hardware_id: hardware.id)
|
||||||
|
expect(tst.hardware.name).to(eq('Test Hardware'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -5,6 +5,7 @@ ENV['APP_ENV'] = 'test'
|
|||||||
require_relative '../src/server'
|
require_relative '../src/server'
|
||||||
require 'rspec'
|
require 'rspec'
|
||||||
require 'rack/test'
|
require 'rack/test'
|
||||||
|
require 'database_cleaner/sequel'
|
||||||
|
|
||||||
# setting this here so all redirect tests can reference the same base URL
|
# setting this here so all redirect tests can reference the same base URL
|
||||||
BASE_URL = 'http://example.org'
|
BASE_URL = 'http://example.org'
|
||||||
@ -21,4 +22,14 @@ end
|
|||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.include(RSpecMixin)
|
config.include(RSpecMixin)
|
||||||
|
|
||||||
|
config.before(:suite) do
|
||||||
|
DatabaseCleaner.strategy = :transaction
|
||||||
|
end
|
||||||
|
|
||||||
|
config.around do |suite|
|
||||||
|
DatabaseCleaner.cleaning do
|
||||||
|
suite.run
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
module AppInfo
|
module AppInfo
|
||||||
|
|
||||||
VERSION = '0.1.1'
|
VERSION = '0.2.1'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -6,8 +6,9 @@ require 'yaml'
|
|||||||
class Config
|
class Config
|
||||||
|
|
||||||
DEFAULT_CONFIG = 'config/defaults.yaml'
|
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)
|
@data = YAML.load_file(DEFAULT_CONFIG)
|
||||||
|
|
||||||
# merge in user-defined configuration if it exists
|
# merge in user-defined configuration if it exists
|
||||||
|
@ -6,7 +6,8 @@ require 'sqlite3'
|
|||||||
|
|
||||||
require_relative 'config'
|
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
|
# Load the Sequel timestamps plugin
|
||||||
Sequel::Model.plugin(:timestamps)
|
Sequel::Model.plugin(:timestamps)
|
||||||
|
Reference in New Issue
Block a user