Skip to content

Commit

Permalink
[AF-10] Add development workflow (#11)
Browse files Browse the repository at this point in the history
* Add essential tools for development workflow

- Create main application with container structure;
- Update README with instructions to config application and setup database;
- Add tool-versions for use asdf version management;
- Add essential tools for testing and coverage;
- Add dotenv to work with environment variables (12factor);
- Add DATABASE_URL as required environment variable;
- Add core provider;
- Add Dependency auto-injection;
- Add postgres as main database
- Add money gem to handle financial values;
- Add fake data for development/test purposes;
- Configure sequel to handle database migrations;
- Add golang as development dependency to running local services;
- Add Procfile to start/stop related services;
- Create custom tasks to handle postgres database;
- Update CI config
  • Loading branch information
ricardopacheco authored Feb 16, 2024
1 parent a720a5d commit a628133
Show file tree
Hide file tree
Showing 26 changed files with 615 additions and 26 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
2 changes: 2 additions & 0 deletions .env.development.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
APP_ENV=development
DATABASE_URL=postgresql://postgres:@127.0.0.1/auction_fun_core_development?pool=10
2 changes: 2 additions & 0 deletions .env.test.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
APP_ENV=test
DATABASE_URL=postgresql://postgres:@127.0.0.1:5432/auction_fun_core_test?pool=10
29 changes: 25 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ on:
jobs:
build:
runs-on: ubuntu-22.04
env:
CI: true
APP_ENV: test
services:
postgres:
image: postgres:16.1
ports: ["5432:5432"]
env:
POSTGRES_HOST_AUTH_METHOD: trust
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
name: Ruby ${{ matrix.ruby }}
strategy:
matrix:
Expand All @@ -19,16 +29,27 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Install postgres client dependencies
run: sudo apt-get install libpq-dev
- name: Copy .env.test file
run: cp .env.test.template .env.test
- name: Load .env.test file
uses: xom9ikk/dotenv@v2
with:
path: ./
mode: test
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Install dependencies
run: bundle install
- name: Create database and running migrations
run: |
bundle exec rake auction_fun_core:db:create_database[postgres]
bundle exec rake auction_fun_core:db:migrate
env:
POSTGRES_HOST: localhost
- name: Run suite
run: bundle exec rspec spec/ --color --format progress
env:
CI: true
RACK_ENV: test
RAILS_ENV: test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@

# rspec failure tracking
.rspec_status

# Local variable enviroment
.env.development
.env.test
3 changes: 3 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ruby 3.3.0
postgres 16.1
golang 1.21.5
26 changes: 24 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,30 @@ source "https://rubygems.org"
# Specify your gem's dependencies in auction_fun_core.gemspec
gemspec

gem "activesupport", "7.1.3"
gem "dotenv", "3.0.2"
gem "dry-events", "1.0.1"
gem "dry-matcher", "1.0.0"
gem "dry-monads", "1.6.0"
gem "dry-system", "1.0.1"
gem "dry-validation", "1.10.0"
gem "money", "6.16.0"
gem "pg", "1.5.5"
gem "rake", "13.1.0"
gem "rom", "5.3.0"
gem "rom-sql", "3.6.2"
gem "yard", "0.9.34"
gem "zeitwerk", "2.6.13"

gem "rspec", "3.13.0"
group :development, :test do
gem "faker", "3.2.3"
gem "pry", "0.14.2"
gem "rspec", "3.13.0"
gem "standard", "1.33.0"
end

gem "standard", "1.33.0"
group :test do
gem "database_cleaner-sequel", "2.0.2"
gem "rom-factory", "0.12.0"
gem "simplecov", "0.22.0"
end
156 changes: 156 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,144 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.6)
coderay (1.1.3)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
database_cleaner-core (2.0.1)
database_cleaner-sequel (2.0.2)
database_cleaner-core (~> 2.0.0)
sequel
diff-lcs (1.5.1)
docile (1.4.0)
dotenv (3.0.2)
drb (2.2.0)
ruby2_keywords
dry-auto_inject (1.0.1)
dry-core (~> 1.0)
zeitwerk (~> 2.6)
dry-configurable (1.1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dry-core (1.0.1)
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
dry-events (1.0.1)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
dry-inflector (1.0.0)
dry-initializer (3.1.1)
dry-logic (1.5.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dry-matcher (1.0.0)
dry-core (~> 1.0, < 2)
dry-monads (1.6.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dry-schema (1.13.3)
concurrent-ruby (~> 1.0)
dry-configurable (~> 1.0, >= 1.0.1)
dry-core (~> 1.0, < 2)
dry-initializer (~> 3.0)
dry-logic (>= 1.4, < 2)
dry-types (>= 1.7, < 2)
zeitwerk (~> 2.6)
dry-struct (1.6.0)
dry-core (~> 1.0, < 2)
dry-types (>= 1.7, < 2)
ice_nine (~> 0.11)
zeitwerk (~> 2.6)
dry-system (1.0.1)
dry-auto_inject (~> 1.0, < 2)
dry-configurable (~> 1.0, < 2)
dry-core (~> 1.0, < 2)
dry-inflector (~> 1.0, < 2)
dry-types (1.7.2)
bigdecimal (~> 3.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0)
dry-inflector (~> 1.0)
dry-logic (~> 1.4)
zeitwerk (~> 2.6)
dry-validation (1.10.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
dry-initializer (~> 3.0)
dry-schema (>= 1.12, < 2)
zeitwerk (~> 2.6)
faker (3.2.3)
i18n (>= 1.8.11, < 2)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
json (2.7.1)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
method_source (1.0.0)
minitest (5.22.2)
money (6.16.0)
i18n (>= 0.6.4, <= 2)
mutex_m (0.2.0)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
pg (1.5.5)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
racc (1.7.3)
rainbow (3.1.1)
rake (13.1.0)
regexp_parser (2.9.0)
rexml (3.2.6)
rom (5.3.0)
rom-changeset (~> 5.3, >= 5.3.0)
rom-core (~> 5.3, >= 5.3.0)
rom-repository (~> 5.3, >= 5.3.0)
rom-changeset (5.3.0)
dry-core (~> 1.0)
rom-core (~> 5.3)
transproc (~> 1.0, >= 1.1.0)
rom-core (5.3.0)
concurrent-ruby (~> 1.1)
dry-configurable (~> 1.0)
dry-core (~> 1.0)
dry-inflector (~> 1.0)
dry-initializer (~> 3.0, >= 3.0.1)
dry-struct (~> 1.0)
dry-types (~> 1.6)
transproc (~> 1.0, >= 1.1.0)
rom-factory (0.12.0)
dry-configurable (~> 1.0)
dry-core (~> 1.0)
dry-struct (~> 1.6)
faker (>= 2.0, < 4)
rom-core (~> 5.3)
rom-repository (5.3.0)
dry-core (~> 1.0)
dry-initializer (~> 3.0, >= 3.0.1)
rom-core (~> 5.3, >= 5.3.0)
rom-sql (3.6.2)
dry-core (~> 1.0)
dry-types (~> 1.0)
rom (~> 5.2, >= 5.2.1)
sequel (>= 4.49)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand Down Expand Up @@ -50,6 +174,15 @@ GEM
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sequel (5.77.0)
bigdecimal
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
standard (1.33.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
Expand All @@ -62,17 +195,40 @@ GEM
standard-performance (1.3.1)
lint_roller (~> 1.1)
rubocop-performance (~> 1.20.2)
transproc (1.1.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
yard (0.9.34)
zeitwerk (2.6.13)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
activesupport (= 7.1.3)
auction_fun_core!
database_cleaner-sequel (= 2.0.2)
dotenv (= 3.0.2)
dry-events (= 1.0.1)
dry-matcher (= 1.0.0)
dry-monads (= 1.6.0)
dry-system (= 1.0.1)
dry-validation (= 1.10.0)
faker (= 3.2.3)
money (= 6.16.0)
pg (= 1.5.5)
pry (= 0.14.2)
rake (= 13.1.0)
rom (= 5.3.0)
rom-factory (= 0.12.0)
rom-sql (= 3.6.2)
rspec (= 3.13.0)
simplecov (= 0.22.0)
standard (= 1.33.0)
yard (= 0.9.34)
zeitwerk (= 2.6.13)

BUNDLED WITH
2.5.6
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
database: postgres
Loading

0 comments on commit a628133

Please sign in to comment.