Skip to content

Commit

Permalink
Github CI (#1)
Browse files Browse the repository at this point in the history
* Github CI

* Split gemfile

* fix

* Rest of the gemfiles

* Rest of the gemfiles

* schema version

* Set queue adapter to inline on test env

* revert

* Drop 7.1

* Setup rubocop

* rubocop.gemfile

* revert mysql2

* rubocop todo
  • Loading branch information
mbajur authored Nov 24, 2024
1 parent 50a2561 commit 7c5fb5a
Show file tree
Hide file tree
Showing 68 changed files with 588 additions and 183 deletions.
157 changes: 157 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: CI

on:
push:
branches:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest

services:
postgresql:
image: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_DB: inner_performance_gem_test
POSTGRES_USER: inner_performance
POSTGRES_PASSWORD: inner_performance

mysql2:
image: mysql:8.0
env:
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: inner_performance_gem_test
MYSQL_USER: inner_performance
MYSQL_PASSWORD: inner_performance
MYSQL_ROOT_PASSWORD: inner_performance
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 3
ports:
- "3306:3306"

strategy:
fail-fast: false
matrix:
ruby: ["3.2", "3.3"]
rails_version: ["7.2", "8.0"]
db: [sqlite3, postgresql, mysql2]
exclude:
# Not needed version combinations (just to cut down on noise)
# 3.1 on 7.0 mainly
- ruby: 3.1
rails_version: 7.2
db: sqlite3
- ruby: 3.1
rails_version: 7.1
db: sqlite3
- ruby: 3.1
rails_version: 7.1
db: mysql2
- ruby: 3.1
rails_version: 7.2
db: mysql2

# 3.2 on 7.1 and 7.2 mainly
- ruby: 3.2
rails_version: 7.0
db: sqlite3
- ruby: 3.2
rails_version: 7.0
db: mysql2
- ruby: 3.2
rails_version: 7.0
db: sqlite3
- ruby: 3.2
rails_version: 8.0
db: sqlite3
- ruby: 3.2
rails_version: 8.0
db: mysql2
- ruby: 3.3
rails_version: edge

# 3.3 on 8.0/edge mainly
- ruby: 3.3
rails_version: 7.0
- ruby: 3.3
rails_version: 7.1
- ruby: 3.3
rails_version: 7.2
db: sqlite3
- ruby: 3.3
rails_version: 7.2
db: mysql2

# Not supported version combinations
- ruby: 3.1
rails_version: 8.0
- ruby: 3.1
rails_version: edge

env:
RAILS_ENV: test
COVERAGE: 1
FERRUM_DEFAULT_TIMEOUT: 20
BUNDLE_GEMFILE: "spec/gemfiles/rails_${{ matrix.rails_version }}.gemfile"
DB: ${{ matrix.db }}
DB_HOST: 127.0.0.1
DB_POOL: 5
DB_USERNAME: inner_performance
DB_PASSWORD: inner_performance

steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true # install gems and cache

- uses: browser-actions/setup-chrome@v1

- name: Setup DB
run: |
bundle exec rake db:create db:schema:load
- name: "Run Tests"
run: |
bundle exec rspec --force-color --format d
# - name: Test & publish code coverage
# uses: paambaati/[email protected]
# env:
# CC_TEST_REPORTER_ID: <code_climate_reporter_id>

rubocop:
runs-on: ubuntu-latest

env:
BUNDLE_GEMFILE: spec/gemfiles/rubocop.gemfile

steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true

- name: Rubocop
run: |
bundle exec rubocop
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
inherit_from: .rubocop_todo.yml
70 changes: 70 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-11-24 19:43:04 UTC using RuboCop version 1.68.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
Bundler/OrderedGems:
Exclude:
- 'spec/gemfiles/rails_8.0.gemfile'

# Offense count: 1
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'inner_performance.gemspec'

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 31

# Offense count: 4
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 29

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 27

# Offense count: 1
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 7

# Offense count: 13
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'app/controllers/inner_performance/dashboard_controller.rb'
- 'app/controllers/inner_performance/events_controller.rb'
- 'app/helpers/inner_performance/application_helper.rb'
- 'app/jobs/inner_performance/cleanup_job.rb'
- 'app/jobs/inner_performance/save_event_job.rb'
- 'app/mailers/inner_performance/application_mailer.rb'
- 'app/models/inner_performance/application_record.rb'
- 'app/models/inner_performance/event.rb'
- 'db/migrate/20241123121600_create_inner_performance_events.rb'
- 'db/migrate/20241124111458_add_type_to_inner_performance_events.rb'
- 'lib/inner_performance.rb'
- 'lib/inner_performance/configuration.rb'
- 'lib/inner_performance/engine.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 123
15 changes: 4 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
source "https://rubygems.org"
# frozen_string_literal: true

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

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

gem "puma"

gem "sqlite3"

gem "sprockets-rails"

gem 'simplecov', require: false, group: :test

# Start debugger with binding.b [https://github.com/ruby/debug]
# gem "debug", ">= 1.0.0"
eval_gemfile File.expand_path('spec/gemfiles/rails_8.0.gemfile', __dir__)
45 changes: 44 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ GEM
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
ast (2.4.2)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
Expand All @@ -101,6 +102,8 @@ GEM
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.8.2)
language_server-protocol (3.17.0.3)
logger (1.6.1)
loofah (2.23.1)
crass (~> 1.0.2)
Expand Down Expand Up @@ -136,6 +139,11 @@ GEM
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
pagy (9.3.1)
parallel (1.26.3)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
pg (1.5.9)
psych (5.2.0)
stringio
puma (6.5.0)
Expand Down Expand Up @@ -177,13 +185,15 @@ GEM
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
ransack (4.2.1)
activerecord (>= 6.1.5)
activesupport (>= 6.1.5)
i18n
rdoc (6.8.1)
psych (>= 4.0.0)
regexp_parser (2.9.2)
reline (0.5.11)
io-console (~> 0.5)
rspec-core (3.13.2)
Expand All @@ -203,6 +213,31 @@ GEM
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.1)
rubocop (1.68.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.36.1)
parser (>= 3.3.1.0)
rubocop-rails (2.27.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (3.2.0)
rubocop (~> 1.61)
rubocop-rspec_rails (2.30.0)
rubocop (~> 1.61)
rubocop-rspec (~> 3, >= 3.0.1)
rubocop-shopify (2.15.1)
rubocop (~> 1.51)
ruby-progressbar (1.13.0)
securerandom (0.3.2)
simplecov (0.22.0)
docile (~> 1.1)
Expand Down Expand Up @@ -232,6 +267,7 @@ GEM
timeout (0.4.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
uri (1.0.2)
useragent (0.16.10)
websocket-driver (0.7.6)
Expand All @@ -257,11 +293,18 @@ PLATFORMS

DEPENDENCIES
inner_performance!
pg (~> 1.1)
puma
rails (~> 8.0.0)
rspec-rails
rubocop
rubocop-rails
rubocop-rspec
rubocop-rspec_rails
rubocop-shopify
simplecov
sprockets-rails
sqlite3
sqlite3 (>= 2.1)

BUNDLED WITH
2.5.23
12 changes: 7 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
require "bundler/setup"
# frozen_string_literal: true

APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
load "rails/tasks/engine.rake"
require 'bundler/setup'

load "rails/tasks/statistics.rake"
APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
load 'rails/tasks/engine.rake'

require "bundler/gem_tasks"
load 'rails/tasks/statistics.rake'

require 'bundler/gem_tasks'
2 changes: 2 additions & 0 deletions app/controllers/inner_performance/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module InnerPerformance
class ApplicationController < ActionController::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/inner_performance/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module InnerPerformance
class DashboardController < ApplicationController
def index
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/inner_performance/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# frozen_string_literal: true

module InnerPerformance
class EventsController < ApplicationController
include Pagy::Backend

def index
@q = InnerPerformance::Event.all.ransack(params[:q])
@q.sorts = "created_at desc" if @q.sorts.empty?
@q.sorts = 'created_at desc' if @q.sorts.empty?
@pagy, @events = pagy(@q.result)
end
end
Expand Down
Loading

0 comments on commit 7c5fb5a

Please sign in to comment.