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

[gh394] Remove the Figaro gem dependency #400

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# DO NOT STORE SECRETS HERE.
# Use .env.development for local secrets.

REDIS_URL=redis://localhost:6379

# CI/CD
TEST_RETRY=0
CI=false

# Mail
MAILER_DEFAULT_HOST=localhost
MAILER_DEFAULT_PORT=3000
MAILER_SENDER=Test <[email protected]>

# Locales
AVAILABLE_LOCALES=en
DEFAULT_LOCALE=en
FALLBACK_LOCALES=en

SECRET_KEY_BASE=replace_with_lengthy_secure_hex
5 changes: 5 additions & 0 deletions .env.development.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# DO NOT COMMIT THIS FILE (`.env.development`)
# Rename it to `.env.development` and use it for local secrets only.

# Used to verify the integrity of signed cookies. so ensure a secure value is set
SECRET_KEY_BASE=replace_with_lengthy_secure_hex
3 changes: 3 additions & 0 deletions .gitignore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@

# Ignore the test coverage results from SimpleCov
/coverage

# Ignore environment variables files
.env.development
IGNORE
end
6 changes: 0 additions & 6 deletions .template/addons/docker/.env.tt

This file was deleted.

5 changes: 4 additions & 1 deletion .template/addons/docker/Dockerfile.tt
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ COPY . ./
RUN rm -rf tmp/docker

<%- if WEB_VARIANT -%>

# Compile assets
RUN bin/docker-assets-precompile
RUN bundle exec rails i18n:js:export
RUN bundle exec rails assets:precompile --trace
RUN yarn postcss

<%- end -%>
EXPOSE $PORT
Expand Down
13 changes: 12 additions & 1 deletion .template/addons/docker/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,16 @@
template 'docker-compose.dev.yml.tt'
template 'docker-compose.test.yml.tt'
template 'docker-compose.yml.tt'
template '.env.tt'
template '.dockerignore.tt'

append_to_file '.env' do
<<~ENVEXAMPLE

# Docker
APP_NAME=#{APP_NAME}
DOCKER_REGISTRY_HOST=#{DOCKER_REGISTRY_HOST}
DOCKER_IMAGE=#{DOCKER_IMAGE}
BRANCH_TAG=latest
PORT=80
ENVEXAMPLE
end
4 changes: 0 additions & 4 deletions .template/spec/addons/base/docker/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
expect(file('Dockerfile')).to exist
end

it 'creates the docker env file' do
expect(file('.env')).to exist
end

it 'creates the docker ignore file' do
expect(file('.dockerignore')).to exist
end
Expand Down
5 changes: 0 additions & 5 deletions .template/spec/base/bin/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,4 @@
expect(file('bin/docker-prepare')).to exist
expect(file('bin/docker-prepare')).to be_executable
end

it 'creates the docker asset precompile script' do
expect(file('bin/docker-assets-precompile')).to exist
expect(file('bin/docker-assets-precompile')).to be_executable
end
end
4 changes: 2 additions & 2 deletions .template/spec/base/config/template_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

describe '/config template' do
it 'creates the Figaro configuration for application variables' do
expect(file('config/application.yml')).to exist
it 'does NOT create the application.yml config' do
expect(file('config/application.yml')).not_to exist
end

it 'creates the database configuration' do
Expand Down
8 changes: 8 additions & 0 deletions .template/spec/base/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@
it 'creates Reek configuration files' do
expect(file('.reek.yml')).to exist
end

it 'creates .env file' do
expect(file('.env')).to exist
end

it 'creates .env.development.example file' do
expect(file('.env.development.example')).to exist
end
end
3 changes: 2 additions & 1 deletion .template/variants/web/package.json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
run 'yarn add postcss postcss-cli autoprefixer'

run 'yarn add --dev @nimblehq/[email protected]'
run 'yarn add --dev stylelint'
run 'yarn add --dev stylelint@14'
run 'yarn add --dev @nimblehq/stylelint-config-nimble'

# Setup scripts
run 'npm set-script eslint "eslint . --color"'
run 'npm set-script eslint:fix "eslint . --color --fix"'
Expand Down
7 changes: 3 additions & 4 deletions .template/variants/web/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ def apply_web_variant!

after_bundle do
use_source_path __dir__

# Generate translation file
run 'bin/rake i18n:js:export'

# Fix the default Rails template that does not put trailing commas
run 'yarn run codebase:fix'

apply 'spec/template.rb'

# Generate translation file
run 'bundle exec rake i18n:js:export'
end
end

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.tt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ gem 'puma' # Use Puma as the app server
gem 'mini_magick' # A ruby wrapper for ImageMagick or GraphicsMagick command line
gem 'pagy' # A pagination gem that is very light and fast
gem 'discard' # Soft deletes for ActiveRecord
gem 'dotenv-rails' # Shim to load environment variables from .env into ENV in development
gem 'sidekiq' # background processing for Ruby
gem 'sassc' # bootsnap dependency
gem 'bootsnap', require: false # Reduces boot times through caching; required in config/boot.rb
Expand Down Expand Up @@ -41,7 +42,6 @@ group :development, :test do
# gem 'debug', platforms: %i[ mri mingw x64_mingw ] # Official debug

# Utilities
gem 'figaro' # Simple Rails app configuration
gem 'listen' # Listens to file modifications
gem 'letter_opener' # Preview mail in the browser instead of sending
gem 'ffaker' # A library for generating fake data such as names, addresses, and phone numbers
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test_template:
if [ $(VARIANT) = web ]; then \
bundle exec rspec --pattern="${base_spec}, ${web_spec}, ${base_addon_spec}, ${web_addon_spec}" --format progress; \
elif [ $(VARIANT) = api ]; then \
bundle exec rspec --pattern="${base_spec}, ${api_spec}, ${base_addon_spec}, ${api_addon_spec}" --format progress; \
bundle exec rspec --pattern="${base_spec}, ${api_spec}, ${base_addon_spec}, ${api_addon_spec}"; \
fi;

cleanup:
Expand Down
24 changes: 0 additions & 24 deletions bin/docker-assets-precompile

This file was deleted.

3 changes: 3 additions & 0 deletions bin/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ if [ -f tmp/pids/server.pid ]; then
rm -f tmp/pids/server.pid
fi

bundle install
bundle update

# Run pending migrations (if any) and start rails
bundle exec rails db:migrate
bundle exec rails s -p $PORT -b 0.0.0.0
1 change: 0 additions & 1 deletion bin/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
copy_file 'bin/worker.sh', mode: :preserve
copy_file 'bin/dev', mode: :preserve
copy_file 'bin/docker-prepare', mode: :preserve
copy_file 'bin/docker-assets-precompile', mode: :preserve
25 changes: 0 additions & 25 deletions config/application.yml.tt

This file was deleted.

23 changes: 0 additions & 23 deletions config/database.yml

This file was deleted.

23 changes: 23 additions & 0 deletions config/database.yml.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
default: &default
adapter: postgresql
encoding: unicode
pool: 5

development:
<<: *default
host: <%= ENV.fetch('DB_HOST') { 'localhost' } %>
port: <%= ENV.fetch('DB_PORT') { 5432 } %>
username: <%= ENV.fetch('DB_USERNAME') { 'postgres' } %>
password: <%= ENV.fetch('DB_PASSWORD') { 'postgres' } %>
database: <%= ENV.fetch('DB_NAME') { APP_NAME } %>_development

test:
<<: *default
host: <%= ENV.fetch('DB_HOST') { 'localhost' } %>
port: <%= ENV.fetch('DB_PORT') { 5432 } %>
username: <%= ENV.fetch('DB_USERNAME') { 'postgres' } %>
password: <%= ENV.fetch('DB_PASSWORD') { 'postgres' } %>
database: <%= ENV.fetch('DB_NAME') { APP_NAME } %>_test

production:
url: <%= ENV.fetch('DATABASE_URL') { '' } %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will only work for heroku afaik

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

Andy found a part of the solution in #411 — but the implementation still require some improvements 💭

3 changes: 1 addition & 2 deletions config/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

apply 'config/application.rb'

template 'config/application.yml.tt'
copy_file 'config/database.yml', force: true
template 'config/database.yml.tt', force: true
copy_file 'config/sidekiq.yml'

apply 'config/environments/development.rb'
Expand Down
2 changes: 2 additions & 0 deletions template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def apply_template!(template_root)

copy_file '.flayignore'
copy_file 'Dangerfile'
copy_file '.env'
copy_file '.env.development.example'
copy_file '.rubocop.yml'
copy_file '.reek.yml'

Expand Down