Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasleger authored Oct 24, 2024
0 parents commit db502a9
Show file tree
Hide file tree
Showing 101 changed files with 4,234 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
.git
.github
.dockerignore
Dockerfile
docker-compose.yml
tmp/**
log/**
.DS_STORE
storage/**
4 changes: 4 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DATABASE_URL='postgresql://postgres:dummy@db:5433'
RUBY_DEBUG_HOST=0.0.0.0
RUBY_DEBUG_NO_RELINE="true"
RUBY_DEBUG_PORT=12345
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 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
97 changes: 97 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: ci

on: push

env:
DATABASE_URL: postgres://postgres:dummy@localhost:5432/test

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
tags: rails-template:latest
outputs: type=docker,dest=/tmp/rails-template.tar
cache-from: type=gha
cache-to: type=gha,mode=max
-
name: Cache image
id: rails-template-docker
uses: actions/cache@v4
with:
path: /tmp/rails-template.tar
key: ${{ github.sha }}-rails-template
lint:
name: "Linting: Rubocop"
runs-on: ubuntu-latest
needs: build
steps:
- uses: docker/setup-buildx-action@v3
- uses: actions/cache@v4
with:
path: /tmp/rails-template.tar
key: ${{ github.sha }}-rails-template
- run: docker load --input /tmp/rails-template.tar
- run: docker run --rm rails-template:latest bundle exec rubocop
unit-tests:
name: "Unit tests: RSpec"
runs-on: ubuntu-latest
needs: build
services:
postgres:
image: postgres
ports: ["5432:5432"]
env:
POSTGRES_DB: test
POSTGRES_PASSWORD: dummy
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: docker/setup-buildx-action@v3
- uses: actions/cache@v4
with:
path: /tmp/rails-template.tar
key: ${{ github.sha }}-rails-template
- run: docker load --input /tmp/rails-template.tar
- run: |
docker run \
--network="host" \
-e DATABASE_URL="${{ env.DATABASE_URL }}" \
-v /var/run/docker.sock:/var/run/docker.sock \
--rm rails-template bundle exec rspec
integration-tests:
name: "Integration tests: Cucumber"
runs-on: ubuntu-latest
needs: build
services:
postgres:
image: postgres
ports: ["5432:5432"]
env:
POSTGRES_DB: test
POSTGRES_PASSWORD: dummy
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: docker/setup-buildx-action@v3
- uses: actions/cache@v4
with:
path: /tmp/rails-template.tar
key: ${{ github.sha }}-rails-template
- run: docker load --input /tmp/rails-template.tar
- run: |
docker run \
--network="host" \
-e DATABASE_URL="${{ env.DATABASE_URL }}" \
-v /var/run/docker.sock:/var/run/docker.sock \
--rm rails-template bundle exec cucumber
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-*

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

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

# Ignore uploaded files in development.
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/
!/tmp/storage/.keep

/public/assets

# Ignore master key for decrypting credentials and more.
/config/master.key

node_modules
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
16 changes: 16 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
inherit_from: .rubocop_todo.yml

require:
- rubocop-rspec
- rubocop-rails
- rubocop-capybara
- rubocop-factory_bot
- rubocop-rspec_rails


AllCops:
NewCops: enable

Style/StringLiterals:
Enabled: true
EnforcedStyle: "double_quotes"
38 changes: 38 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-05-01 07:54:40 UTC using RuboCop version 1.63.4.
# 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
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'lib/tasks/cucumber.rake'

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 28

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: slashes, arguments
Rails/FilePath:
Exclude:
- 'lib/tasks/cucumber.rake'
- 'spec/rails_helper.rb'

# Offense count: 5
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'app/controllers/home_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/mailers/application_mailer.rb'
- 'app/models/application_record.rb'
- 'config/application.rb'
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.5
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ruby:3.3.5-slim

EXPOSE 3000

RUN apt-get update && apt-get upgrade -y && apt-get install --no-install-recommends -y build-essential libpq-dev nodejs npm

# do the bundle install in another directory with the strict essential
# (Gemfile and Gemfile.lock) to allow further steps to be cached
# (namely the NPM steps)
WORKDIR /bundle
COPY Gemfile Gemfile.lock ./
RUN bundle install

# Move to the main folder
WORKDIR /app

# We can't do the WORKDIR trick here because npm modules need to be
# installed in the root folder (since they're installed locally in
# node_modules)
COPY package.json package-lock.json ./

RUN npm i

COPY . .

ENTRYPOINT ["./entrypoint.sh"]

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

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

ruby "3.3.5"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails"

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

# Use PostgreSQL as the database for Active Record
gem "pg"

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

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

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"

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

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

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# 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]

# Reduces boot times through caching; required in config/boot.rb
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 "dsfr-view-components"

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 "factory_bot_rails"
gem "rspec-rails"
end

group :test do
gem "capybara"
gem "cucumber-rails", require: false
gem "faker", require: false
gem "guard"
gem "guard-cucumber"
gem "guard-rspec"
gem "rspec"
gem "rubocop"
gem "rubocop-capybara"
gem "rubocop-factory_bot"
gem "rubocop-rails"
gem "rubocop-rspec"
gem "rubocop-rspec_rails"
end

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

# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
# gem "rack-mini-profiler"

# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
end
Loading

0 comments on commit db502a9

Please sign in to comment.