Skip to content

Commit

Permalink
Merge pull request #2 from fabianoflorentino/development
Browse files Browse the repository at this point in the history
Development to Main
  • Loading branch information
fabianoflorentino authored Mar 3, 2024
2 parents 381ded1 + af44d26 commit e209e7a
Show file tree
Hide file tree
Showing 81 changed files with 1,913 additions and 0 deletions.
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

0 comments on commit e209e7a

Please sign in to comment.