Skip to content

Commit

Permalink
Setup GitHub actions (#3)
Browse files Browse the repository at this point in the history
Way too many PRs
  • Loading branch information
sophiedeziel authored Mar 19, 2022
1 parent 6594a8e commit f43e8fd
Show file tree
Hide file tree
Showing 78 changed files with 541 additions and 319 deletions.
31 changes: 19 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@
name: "Ruby on Rails CI"
on:
push:
branches: [ $default-branch ]
branches: [ 'main' ]
pull_request:
branches: [ $default-branch ]
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
image: mysql:8
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: tentacles_test
MYSQL_PASSWORD: tentacles_test
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: tentacles_test
ports:
- 3306
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
env:
RAILS_ENV: test
Expand All @@ -33,11 +34,17 @@ jobs:
uses: ruby/setup-ruby@8f312efe1262fb463d906e9bf040319394c18d3e # v1.92
with:
bundler-cache: true
# Add or replace database setup steps here
- name: Set up database schema
run: bin/rails db:schema:load
# Add or replace test runners here
- name: Setup database
env:
RAILS_ENV: test
DB_USER: tentacles_test
DB_PASSWORD: tentacles_test
run: bin/rails db:schema:load
- name: Run tests
env:
RAILS_ENV: test
DB_USER: tentacles_test
DB_PASSWORD: tentacles_test
run: bin/rake

lint:
Expand All @@ -54,5 +61,5 @@ jobs:
# run: bin/bundler-audit --update
# - name: Security audit application code
# run: bin/brakeman -q -w2
# - name: Lint Ruby files
# run: bin/rubocop --parallel
- name: Lint Ruby files
run: bin/rubocop --parallel
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
19 changes: 19 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require: rubocop-rails
AllCops:
NewCops: enable
Exclude:
- 'db/schema.rb'
- 'node_modules/**/*'
- 'vendor/**/*'
- 'bin/**/*'

Metrics/MethodLength:
Exclude:
- 'db/migrate/*'

Metrics/AbcSize:
Exclude:
- 'db/migrate/*'

Style/Documentation:
Enabled: false
49 changes: 27 additions & 22 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
source "https://rubygems.org"
# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.0.2"
ruby '3.0.2'

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.2", ">= 7.0.2.2"
gem 'rails', '~> 7.0.2', '>= 7.0.2.2'

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
gem 'sprockets-rails'

# Use sqlite3 as the database for Active Record
#gem "sqlite3", "~> 1.4"
# gem "sqlite3", "~> 1.4"

gem 'mysql2', '~> 0.5.3'

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"
gem 'puma', '~> 5.0'

# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"
gem 'importmap-rails'

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"
gem 'jbuilder'

# Use Redis adapter to run Action Cable in production
gem "redis", "~> 4.0"
gem 'redis', '~> 4.0'

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"
Expand All @@ -33,34 +35,37 @@ gem "redis", "~> 4.0"
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
gem 'bootsnap', require: false

# Use Sass to process CSS
# gem "sassc-rails"

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

gem 'octoprint', :github => 'sophiedeziel/octoprint', :branch => 'main' # For prototype purposes
gem "graphql"
gem 'apollo_upload_server'
gem 'graphql'
gem 'octoprint', github: 'sophiedeziel/octoprint', branch: 'main' # For prototype purposes

gem "react_on_rails"
gem "shakapacker", "~> 6.1"
gem 'mini_racer', platforms: :ruby
gem 'react_on_rails'
gem 'shakapacker', '~> 6.1'

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
gem "graphiql-rails"
gem 'debug', platforms: %i[mri mingw x64_mingw]
gem 'graphiql-rails'
gem 'rspec-rails'
gem 'rubocop', '~> 1.26', require: false
gem 'rubocop-rails', '~> 2.14', require: false
end

group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
gem 'web-console'

# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
# gem "rack-mini-profiler"
Expand All @@ -72,7 +77,7 @@ end

group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
gem "webdrivers"
end
gem 'capybara'
gem 'selenium-webdriver'
gem 'webdrivers'
end
46 changes: 46 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ GEM
apollo_upload_server (2.1.0)
actionpack (>= 4.2)
graphql (>= 1.8)
ast (2.4.2)
bindex (0.8.1)
bootsnap (1.10.3)
msgpack (~> 1.2)
Expand All @@ -100,6 +101,7 @@ GEM
debug (1.4.0)
irb (>= 1.3.6)
reline (>= 0.2.7)
diff-lcs (1.5.0)
digest (3.1.0)
erubi (1.10.0)
execjs (2.8.1)
Expand All @@ -126,6 +128,7 @@ GEM
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
libv8-node (16.10.0.0-x86_64-darwin)
libv8-node (16.10.0.0-x86_64-linux)
loofah (2.14.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand Down Expand Up @@ -158,6 +161,11 @@ GEM
nio4r (2.5.8)
nokogiri (1.13.3-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.3-x86_64-linux)
racc (~> 1.4)
parallel (1.21.0)
parser (3.1.1.0)
ast (~> 2.4.1)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -209,6 +217,39 @@ GEM
reline (0.3.1)
io-console (~> 0.5)
rexml (3.2.5)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-rails (5.1.1)
actionpack (>= 5.2)
activesupport (>= 5.2)
railties (>= 5.2)
rspec-core (~> 3.10)
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.11.0)
rubocop (1.26.0)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.16.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.16.0)
parser (>= 3.1.1.0)
rubocop-rails (2.14.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
selenium-webdriver (4.1.0)
Expand All @@ -233,6 +274,7 @@ GEM
timeout (0.2.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.1.0)
web-console (4.2.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -251,6 +293,7 @@ GEM

PLATFORMS
x86_64-darwin-20
x86_64-linux

DEPENDENCIES
apollo_upload_server
Expand All @@ -269,6 +312,9 @@ DEPENDENCIES
rails (~> 7.0.2, >= 7.0.2.2)
react_on_rails
redis (~> 4.0)
rspec-rails
rubocop (~> 1.26)
rubocop-rails (~> 2.14)
selenium-webdriver
shakapacker (~> 6.1)
sprockets-rails
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

# 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_relative "config/application"
require_relative 'config/application'

Rails.application.load_tasks
2 changes: 2 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
end
14 changes: 10 additions & 4 deletions app/controllers/graphql_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class GraphqlController < ApplicationController
# If accessing from outside this domain, nullify the session
# This allows for outside API access while preventing CSRF attacks,
Expand All @@ -16,12 +18,14 @@ def execute
render json: result
rescue StandardError => e
raise e unless Rails.env.development?

handle_error_in_development(e)
end

private

# Handle variables in form data, JSON body, or a blank value
# rubocop:disable Metrics/MethodLength
def prepare_variables(variables_param)
case variables_param
when String
Expand All @@ -40,11 +44,13 @@ def prepare_variables(variables_param)
raise ArgumentError, "Unexpected parameter: #{variables_param}"
end
end
# rubocop:enable Metrics/MethodLength

def handle_error_in_development(e)
logger.error e.message
logger.error e.backtrace.join("\n")
def handle_error_in_development(error)
logger.error error.message
logger.error error.backtrace.join("\n")

render json: { errors: [{ message: e.message, backtrace: e.backtrace }], data: {} }, status: 500
render json: { errors: [{ message: error.message, backtrace: error.backtrace }], data: {} },
status: :internal_server_error
end
end
7 changes: 4 additions & 3 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class HomeController < ApplicationController
def index
end
end
def index; end
end
14 changes: 9 additions & 5 deletions app/graphql/input_objects/upload_file_attributes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
class InputObjects::UploadFileAttributes < Types::BaseInputObject
description "Attributes for uploading a file"
argument :notes, String, required: false
argument :file, ::Types::FileType, required: true
end
# frozen_string_literal: true

module InputObjects
class UploadFileAttributes < Types::BaseInputObject
description 'Attributes for uploading a file'
argument :notes, String, required: false
argument :file, ::Types::FileType, required: true
end
end
2 changes: 2 additions & 0 deletions app/graphql/mutations/base_mutation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Mutations
class BaseMutation < GraphQL::Schema::RelayClassicMutation
argument_class Types::BaseArgument
Expand Down
Loading

0 comments on commit f43e8fd

Please sign in to comment.