Skip to content

Commit

Permalink
sets up a very basic ci pipeline (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonneutert committed Oct 9, 2023
1 parent 825542b commit fa6aaaa
Show file tree
Hide file tree
Showing 15 changed files with 214 additions and 65 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: ruby

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
ruby-qa:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15-alpine
ports: ["5432:5432"]
env:
POSTGRES_USER: sinatra
POSTGRES_PASSWORD: sinatra
LC_ALL: C.UTF-8
LANG: en_US.UTF-8
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
RACK_ENV: test
DATABASE_URL: localhost
DATABASE_USER: sinatra
DATABASE_PASSWORD: sinatra

strategy:
fail-fast: false
matrix:
ruby: ["ruby-3.2"]
os: [macos-latest, ubuntu-latest]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Setup database
run: bundle exec rake db:setup

- name: Rubocop
run: bundle exec rubocop

- name: Run tests
run: bundle exec ruby test/run_test.rb
10 changes: 10 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
AllCops:
NewCops: enable

Style/Documentation:
Enabled: false

Style/FrozenStringLiteralComment:
Exclude:
- 'db/**/*'
- 'config.ru'
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby 3.1.3
ruby 3.2.2
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ruby:3.2-slim

# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs

WORKDIR /app

COPY Gemfile Gemfile.lock /app/
RUN bundle install

COPY . /app

CMD ["rackup", "-o", "0", "-p", "3000"]
35 changes: 19 additions & 16 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
source "https://rubygems.org"
# frozen_string_literal: true

ruby '3.1.3'
source 'https://rubygems.org'

gem 'sprockets'
ruby '3.2.2'

gem 'activerecord'
gem 'activesupport', '>= 6.0.3.1'
gem 'bcrypt'
gem 'coffee-script'
gem 'erubi', '~> 1.12'
gem 'haml'
gem 'pg', '~> 1.5'
gem 'rake'
gem 'sass'
gem 'sassc'
gem 'sinatra', '~> 3.1'
gem 'sinatra-activerecord'
gem 'sinatra-contrib', '~> 3.1'
gem 'sinatra-flash'
gem 'sprockets'
gem 'thin'
gem 'haml'
gem 'sass'
gem 'sassc'
gem 'turbolinks'
gem 'yui-compressor'
gem 'uglifier'
gem 'coffee-script'
gem "activesupport", ">= 6.0.3.1"
gem "activerecord"
gem "sinatra-activerecord"
gem "rake"
gem 'pg', '~> 1.5'
gem 'bcrypt'
gem 'warden'
gem 'yui-compressor'

group :test, :development do
gem 'pry'
gem 'rack-test', '~> 2.1'
gem 'rubocop', require: false
gem 'solargraph', require: false
gem 'test-unit', '~> 3.6'
end

gem "erubi", "~> 1.12"
59 changes: 39 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,72 +1,86 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (7.0.8)
activesupport (= 7.0.8)
activerecord (7.0.8)
activemodel (= 7.0.8)
activesupport (= 7.0.8)
activesupport (7.0.8)
activemodel (7.1.0)
activesupport (= 7.1.0)
activerecord (7.1.0)
activemodel (= 7.1.0)
activesupport (= 7.1.0)
timeout (>= 0.4.0)
activesupport (7.1.0)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
backport (1.2.0)
base64 (0.1.1)
bcrypt (3.1.19)
benchmark (0.2.1)
bigdecimal (3.1.4)
coderay (1.1.3)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
daemons (1.4.1)
diff-lcs (1.5.0)
drb (2.1.1)
ruby2_keywords
e2mmap (0.1.0)
erubi (1.12.0)
eventmachine (1.2.7)
execjs (2.8.1)
ffi (1.15.5)
haml (6.2.0)
execjs (2.9.1)
ffi (1.16.3)
haml (6.2.3)
temple (>= 0.8.2)
thor
tilt
i18n (1.14.1)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.4)
jaro_winkler (1.5.6)
json (2.6.3)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
language_server-protocol (3.17.0.3)
method_source (1.0.0)
mini_portile2 (2.8.1)
mini_portile2 (2.8.4)
minitest (5.20.0)
multi_json (1.15.0)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
nokogiri (1.14.3)
mini_portile2 (~> 2.8.0)
mutex_m (0.1.2)
nokogiri (1.15.4)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.14.3-arm64-darwin)
nokogiri (1.15.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.14.3-x86_64-linux)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
parallel (1.23.0)
parser (3.2.2.3)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
pg (1.5.4)
power_assert (2.0.3)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
racc (1.7.1)
rack (2.2.8)
rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4)
rack-test (2.1.0)
rack (>= 1.3)
rainbow (3.1.1)
rake (13.0.6)
rb-fsevent (0.11.2)
Expand Down Expand Up @@ -135,13 +149,16 @@ GEM
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
temple (0.10.2)
temple (0.10.3)
test-unit (3.6.1)
power_assert
thin (1.8.2)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (1.2.2)
tilt (2.3.0)
timeout (0.4.0)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
Expand All @@ -152,7 +169,7 @@ GEM
unicode-display_width (2.5.0)
warden (1.2.9)
rack (>= 2.0.9)
yard (0.9.32)
yard (0.9.34)
yui-compressor (0.12.0)

PLATFORMS
Expand All @@ -169,6 +186,7 @@ DEPENDENCIES
haml
pg (~> 1.5)
pry
rack-test (~> 2.1)
rake
rubocop
sass
Expand All @@ -179,14 +197,15 @@ DEPENDENCIES
sinatra-flash
solargraph
sprockets
test-unit (~> 3.6)
thin
turbolinks
uglifier
warden
yui-compressor

RUBY VERSION
ruby 3.1.3p185
ruby 3.2.2p53

BUNDLED WITH
2.3.26
2.4.20
3 changes: 1 addition & 2 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class MyApp < Sinatra::Base
# – like HTML form submission –
# that do not support the full range of HTTP methods.
use Rack::MethodOverride


set :method_override, true

Expand All @@ -54,7 +53,7 @@ class MyApp < Sinatra::Base

set :root, File.dirname(__FILE__)
# files in static are served on "root"
set :public_folder, File.dirname(__FILE__) + '/static'
set :public_folder, "#{File.dirname(__FILE__)}/static"
# set "/views/layout.erb" as the standard/global template wrapper (yield)
set :erb, format: :html5, layout: :layout

Expand Down
4 changes: 2 additions & 2 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# this file kicks up the app!
# run: "thin start"
require File.dirname(__FILE__) + '/app'
run MyApp
require "#{File.dirname(__FILE__)}/app"
run MyApp
17 changes: 15 additions & 2 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
# this code works on heroku as is
#
# please set your database name (and settings)

test:
host: localhost
adapter: postgresql
encoding: unicode
database: sinatras-skeleton
username: sinatra
password: sinatra
pool: 5

development:
host: localhost
adapter: postgresql
encoding: unicode
database: sinatras-skeleton
username: sinatra
password: sinatra
pool: 5

production:
host: localhost
adapter: postgresql
encoding: unicode
database: sinatras-skeleton
username: sinatra
password: sinatra
pool: 5
24 changes: 11 additions & 13 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2017_02_19_142151) do

ActiveRecord::Schema.define(version: 20_170_219_142_151) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension 'plpgsql'

create_table "skeletons", id: :serial, force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
create_table 'skeletons', id: :serial, force: :cascade do |t|
t.string 'name'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
end

create_table "users", id: :serial, force: :cascade do |t|
t.string "username", null: false
t.string "password", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
create_table 'users', id: :serial, force: :cascade do |t|
t.string 'username', null: false
t.string 'password', null: false
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
end

end
2 changes: 1 addition & 1 deletion lib/warden.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def authenticate!
end

get '/auth/login' do
erb :"users/login"
erb :'users/login'
end

post '/auth/login' do
Expand Down
Loading

0 comments on commit fa6aaaa

Please sign in to comment.