Skip to content

Commit

Permalink
Feature/fixes from ci (#6)
Browse files Browse the repository at this point in the history
* fixes for env

* Gemfile double-quoted

* code style fixes

* more code style fixes

* updated ci database address

* updated ci database address - key not found

* updated ci database address - there are 2 envs

* scan ruby only on pr

* removed db health checks ci

* added one db health check
  • Loading branch information
23vbq authored Sep 10, 2024
1 parent 00122ce commit e9dc584
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/backend_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

jobs:
scan_ruby:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -76,7 +77,7 @@ jobs:
MYSQL_ROOT_PASSWORD: rootpasswd
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=5s --health-retries=1

# redis:
# image: redis
Expand Down Expand Up @@ -108,14 +109,14 @@ jobs:
working-directory: ./todo_backend
env:
RAILS_ENV: test
DATABASE_URL: mysql2://127.0.0.1:3306
DATABASE_ADDR: '127.0.0.1'
run: bin/rails db:create

- name: Run tests
working-directory: ./todo_backend
env:
RAILS_ENV: test
DATABASE_URL: mysql2://127.0.0.1:3306
DATABASE_ADDR: '127.0.0.1'
# REDIS_URL: redis://localhost:6379/0
run: bin/bundle exec rspec

Expand Down
12 changes: 5 additions & 7 deletions todo_backend/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ group :development, :test do
# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false

gem 'rspec-rails'
gem "rspec-rails"
end

group :test do
gem 'factory_bot_rails'
gem 'shoulda-matchers'
gem 'faker'
gem 'database_cleaner'
gem "factory_bot_rails"
gem "shoulda-matchers"
gem "faker"
gem "database_cleaner"
end


2 changes: 1 addition & 1 deletion todo_backend/app/models/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ class Group < ApplicationRecord

validates :name, presence: true
validates :name, uniqueness: { case_sensitive: true }
validates :name, length: {maximum: 20}
validates :name, length: { maximum: 20 }
end
2 changes: 1 addition & 1 deletion todo_backend/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default: &default
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: rootpasswd
host: <%= ENV.fetch("DATABASE_URL") %>
host: <%= ENV.fetch("DATABASE_ADDR") %>

development:
<<: *default
Expand Down
2 changes: 2 additions & 0 deletions todo_backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ services:
- .:/app/todo_backend
networks:
- todo_net
environment:
DATABASE_ADDR: "db"
command: rails s -b 0.0.0.0 -p 3000

db:
Expand Down
6 changes: 3 additions & 3 deletions todo_backend/spec/model/attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

RSpec.describe Attachment, type: :model do
# Associations tests
describe 'associations' do
it { should belong_to(:to_do) }
describe 'associations' do
it { should belong_to(:to_do) }
end
# Validation tests
describe 'validations' do
it { should validate_presence_of(:to_do_id) }
it { should validate_presence_of(:data) }
end
end
end
6 changes: 3 additions & 3 deletions todo_backend/spec/model/group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
RSpec.describe Group, type: :model do
# Associations tests
describe 'associations' do
it { should have_many(:to_dos) }
it { should have_many(:to_dos) }
end
# Validation tests
describe 'validations' do
it { should validate_presence_of(:name) }
it { should validate_uniqueness_of(:name) }
it { should validate_length_of(:name).is_at_most(20)}
it { should validate_length_of(:name).is_at_most(20) }
end
end
end
6 changes: 3 additions & 3 deletions todo_backend/spec/model/to_do_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
RSpec.describe ToDo, type: :model do
# Associations tests
describe 'associations' do
it { should have_many(:attachments) }
it { should belong_to(:group) }
it { should have_many(:attachments) }
it { should belong_to(:group) }
end
# Validation tests
describe 'validations' do
it { should validate_presence_of(:group) }
it { should validate_presence_of(:date_creation) }
it { should validate_presence_of(:title) }
end
end
end
1 change: 0 additions & 1 deletion todo_backend/spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,4 @@
example.run
end
end

end

0 comments on commit e9dc584

Please sign in to comment.