Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development to Main #2

Merged
merged 73 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
9f83928
Add Dockerfile for Ruby on Rails development
fabianoflorentino Mar 1, 2024
b50de1f
Add docker-compose.yml for Blackpearl service
fabianoflorentino Mar 1, 2024
c60168d
Add Gemfile and Gemfile.lock
fabianoflorentino Mar 1, 2024
22b5787
Add .pgpass and .env to .gitignore
fabianoflorentino Mar 1, 2024
9cc1008
Add initial project files and configurations
fabianoflorentino Mar 2, 2024
b34a1d4
Ignore log files in .gitignore
fabianoflorentino Mar 2, 2024
17d5c05
Add db/schema.rb file
fabianoflorentino Mar 2, 2024
2c6b765
Add UpController to check app status
fabianoflorentino Mar 2, 2024
6246f5f
Refactor application.rb file to remove unnecessary code
fabianoflorentino Mar 2, 2024
e1d7b5a
Update health check route in routes.rb
fabianoflorentino Mar 2, 2024
1e445b5
Add blackpearl-migration service to docker-compose.yml
fabianoflorentino Mar 2, 2024
2200992
Add RSpec configuration files
fabianoflorentino Mar 2, 2024
22c913a
Add Customer model with validations
fabianoflorentino Mar 2, 2024
474ad29
Add migration script
fabianoflorentino Mar 2, 2024
31316a6
Add customers table to schema.rb
fabianoflorentino Mar 2, 2024
0c80121
Add customer factory to spec/factories/customers.rb
fabianoflorentino Mar 2, 2024
4874694
Add customer model tests
fabianoflorentino Mar 2, 2024
59fe8a9
Add migration to create customers table
fabianoflorentino Mar 2, 2024
401c5ba
Add index for balance column in customers table
fabianoflorentino Mar 2, 2024
7ad6f8e
Add initial SQL script to truncate customer table
fabianoflorentino Mar 2, 2024
aae3dc4
Update .gitignore to ignore all log files
fabianoflorentino Mar 2, 2024
3a3c1b4
Add frozen_string_literal to ApplicationRecord
fabianoflorentino Mar 2, 2024
2ad3d82
Add CustomersController with index and show actions
fabianoflorentino Mar 2, 2024
c159a38
Add resource route for customers and transactions
fabianoflorentino Mar 2, 2024
ef4d60b
Add migration files for creating transactions and adding reference to…
fabianoflorentino Mar 2, 2024
d15e99a
Add empty keep files to tmp directory
fabianoflorentino Mar 2, 2024
98be68e
Delete log/development.log
fabianoflorentino Mar 2, 2024
b88ad74
Merge branch 'development' of github.com:fabianoflorentino/blackpearl…
fabianoflorentino Mar 2, 2024
a57513b
Add index to amount column in transactions table
fabianoflorentino Mar 2, 2024
4157ab5
Add transactions table to schema.rb
fabianoflorentino Mar 2, 2024
8204a13
Add dependency on blackpearl-db in docker-compose.yml
fabianoflorentino Mar 2, 2024
4bb2eda
Add shoulda-matchers gem
fabianoflorentino Mar 2, 2024
829cf7d
Fix typo in transaction table column name
fabianoflorentino Mar 2, 2024
1ba7202
Add Shoulda Matchers configuration to rails_helper.rb
fabianoflorentino Mar 2, 2024
0b4a662
Add has_many association and update validations for Customer model
fabianoflorentino Mar 2, 2024
a666ea7
Add Transaction model with validations
fabianoflorentino Mar 2, 2024
896c966
Update customer factory to use Faker and SecureRandom
fabianoflorentino Mar 2, 2024
206ac0a
Add transaction factory to spec/factories/transactions.rb
fabianoflorentino Mar 2, 2024
ce5b66f
Add validation tests for Customer model
fabianoflorentino Mar 2, 2024
955ee03
Add Transaction model tests
fabianoflorentino Mar 2, 2024
9d411c8
Update config.ru to use single quotes and add frozen_string_literal d…
fabianoflorentino Mar 2, 2024
54d6817
Add RuboCop extensions and disable Metrics/BlockLength rule
fabianoflorentino Mar 2, 2024
8533911
Update Rakefile to use single quotes and add frozen_string_literal di…
fabianoflorentino Mar 2, 2024
fe11bda
Add frozen_string_literal: true to channel.rb
fabianoflorentino Mar 2, 2024
4b7947a
Add frozen_string_literal directive to connection.rb
fabianoflorentino Mar 2, 2024
b6baa9e
Add frozen_string_literal directive to ApplicationController
fabianoflorentino Mar 2, 2024
bda786a
Add frozen string literal comment to files
fabianoflorentino Mar 2, 2024
72600d8
Update filter_parameter_logging.rb to include additional sensitive pa…
fabianoflorentino Mar 2, 2024
7c3c2e4
Add frozen_string_literal: true to files
fabianoflorentino Mar 2, 2024
9f3a6ce
Refactor customer_spec.rb to use is_expected syntax
fabianoflorentino Mar 2, 2024
7de41d1
Refactor transaction_spec.rb to use is_expected.to syntax
fabianoflorentino Mar 2, 2024
a6c9eed
Add ApplicationMailer class
fabianoflorentino Mar 2, 2024
800ee8b
Update has_many association in Customer model
fabianoflorentino Mar 2, 2024
05ee9f2
Enable NewCops in .rubocop.yml
fabianoflorentino Mar 2, 2024
76f1745
Update schema.rb with new version and table definitions
fabianoflorentino Mar 2, 2024
b841393
Add default value for customer reference in transactions table
fabianoflorentino Mar 2, 2024
c6c48c8
Refactor routes_reloader paths in application.rb
fabianoflorentino Mar 2, 2024
16e6738
Update logger formatter in production environment
fabianoflorentino Mar 2, 2024
fdcc478
Refactor model specs
fabianoflorentino Mar 2, 2024
f3a8115
Fix validation for customer presence
fabianoflorentino Mar 2, 2024
4777f04
Add www.example.com to allowed hosts in development environment
fabianoflorentino Mar 3, 2024
1957b7f
Disable Metrics/BlockLength and RSpec/MultipleExpectations in .ruboco…
fabianoflorentino Mar 3, 2024
beb915f
Disable RSpec/ExampleLength cop in .rubocop.yml
fabianoflorentino Mar 3, 2024
d721e10
Add customer request specs
fabianoflorentino Mar 3, 2024
02ec2c7
Add unit test workflow configuration
fabianoflorentino Mar 3, 2024
72f8054
Update Ruby version to 3.2.3
fabianoflorentino Mar 3, 2024
6f10d05
Add POSTGRES_HOST environment variable to unit_tests.yml
fabianoflorentino Mar 3, 2024
f18917d
Add POSTGRES_HOST to unit tests workflow
fabianoflorentino Mar 3, 2024
20faf50
Update unit_tests.yml and database.yml
fabianoflorentino Mar 3, 2024
4732b33
Update database configuration to use localhost as the PostgreSQL host
fabianoflorentino Mar 3, 2024
b918df5
Update unit_tests.yml to use secrets for PostgreSQL credentials
fabianoflorentino Mar 3, 2024
f182440
Update secrets in unit_tests.yml
fabianoflorentino Mar 3, 2024
af44d26
Add Brakeman and RSpec workflows
fabianoflorentino Mar 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.

# Ignore git directory.
/.git/

# Ignore bundler config.
/.bundle

# Ignore all environment files (except templates).
/.env*
!/.env*.erb

# Ignore all default key files.
/config/master.key
/config/credentials/*.key

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/.keep

# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/.keep
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# See https://git-scm.com/docs/gitattributes for more about git attribute files.

# Mark the database schema as having been generated.
db/schema.rb linguist-generated

# Mark any vendored files as having been vendored.
vendor/* linguist-vendored
config/credentials/*.yml.enc diff=rails_credentials
config/credentials.yml.enc diff=rails_credentials
46 changes: 46 additions & 0 deletions .github/workflows/brakeman.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---

name: Brakeman

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

jobs:
brakeman:
name: Brakeman Security Scan
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Dependences
run: |
sudo apt-get update -y
sudo apt-get install -y libpq-dev postgresql-client build-essential libssl-dev

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.3

- name: Bundle Install
run: bundle install

- name: Brakeman Security Scan
run: brakeman -z -o brakeman-output.json

- name: Upload Brakeman Report
uses: actions/upload-artifact@v2
with:
name: brakeman-report
path: brakeman-output.json
67 changes: 67 additions & 0 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: RSpec

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

jobs:
rspec:
name: Unit Tests with RSepc
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
env:
RAILS_ENV: development
RAILS_MAX_THREADS: 2
WEB_CONCURRENCY: 2
POSTGRES_HOST: localhost
POSTGRES_PORT: '5432'
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
services:
postgres:
image: postgres:latest
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: '5432'
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
POSTGRES_MAX_CONNECTIONS: '30'
POSTGRES_RANDOM_PAGE_COST: '1.1'
POSTGRES_EFFECTIVE_IO_CONCURRENCY: '30'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 3
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Dependences
run: |
sudo apt-get update -y
sudo apt-get install -y libpq-dev postgresql-client build-essential libssl-dev

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.3

- name: Bundle Install
run: bundle install

- name: Database Setup
run: |
bundle exec rails db:migrate

- name: Run RSpec
run: bundle exec rspec
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ build-iPhoneSimulator/

# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*
.pgpass
.env

# Ignore master key for decrypting credentials and more.
/config/master.key
/log/*.log
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--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 @@
---

AllCops:
NewCops: enable

require:
- rubocop-rails
- rubocop-performance
- rubocop-rspec
- rubocop-factory_bot

Metrics/BlockLength:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false

RSpec/ExampleLength:
Enabled: false
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-3.2.3
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ruby:3.2.3-alpine3.19

LABEL maintainer="Fabiano Santos Florentino"
LABEL version="0.1"
LABEL description="Docker image for Ruby on Rails development"
LABEL appname="Black Pearl"

ENV PATH="/usr/local/bundle/bin:${PATH}"
ENV RUBY_YJIT_ENABLE=1

COPY . /app

WORKDIR /app

RUN apk update && apk upgrade --no-cache \
&& apk add --no-cache libpq-dev build-base git bash tzdata gcompat postgresql \
&& gem install rails railties bundler \
&& bundle install --jobs 2 --no-cache \
&& bundle exec bootsnap precompile

EXPOSE 3000

CMD ["bash", "-c", "bundle exec rails s -b 0.0.0.0 -p 3000"]
28 changes: 28 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

source 'https://rubygems.org'

ruby '3.2.3'

gem 'rails', '~> 7.1.3', '>= 7.1.3.2'

gem 'bootsnap', require: false
gem 'jsonapi-serializer', '~> 2.2.0'
gem 'pg', '~> 1.1'
gem 'puma', '>= 5.0'
gem 'tzinfo-data', '~> 1.2024', '>= 1.2024.1'

group :development, :test do
gem 'brakeman', '~> 6.0.1', require: false
gem 'debug'
gem 'factory_bot_rails', '~> 6.2.0'
gem 'faker', '~> 3.2.0'
gem 'rspec', '~> 3.13'
gem 'rspec-rails', '~> 6.1', '>= 6.1.1'
gem 'rubocop', '~> 1.61.0'
gem 'rubocop-performance', '~> 1.20.0'
gem 'rubocop-rails', '~> 2.23.1'
gem 'rubocop-rspec', '~> 2.27.0'
gem 'rubocop-shopify', '~> 2.15.1'
gem 'shoulda-matchers', '~> 5.3'
end
Loading
Loading