Skip to content

Commit b142e5b

Browse files
committed
test: Update build setup
1 parent 0ae4ce2 commit b142e5b

20 files changed

+149
-176
lines changed

.env

Lines changed: 0 additions & 2 deletions
This file was deleted.

.rubocop.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ inherit_from:
44

55
plugins:
66
- rubocop-capybara
7+
- rubocop-packaging
78
- rubocop-performance
89
- rubocop-rails
910
- rubocop-rspec
1011
- rubocop-rspec_rails
1112

12-
require:
13-
- rubocop-packaging
14-
1513
AllCops:
1614
Exclude:
1715
- bin/*

.tool-versions

Lines changed: 0 additions & 1 deletion
This file was deleted.

Gemfile

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,32 @@
33
source 'https://rubygems.org'
44

55
if ENV['DEVEL'] == '1'
6-
# for Docker dev
7-
rails_ver = ENV.fetch('RAILS_VERSION')
8-
gem 'rails', rails_ver
9-
10-
gem 'activeadmin', ENV.fetch('ACTIVEADMIN_VERSION')
116
gem 'activeadmin_quill_editor', path: './'
12-
gem 'appraisal', '~> 2.4'
13-
14-
if rails_ver.start_with?('7.0')
15-
gem 'concurrent-ruby', '1.3.4'
16-
gem 'sqlite3', '~> 1.4'
17-
else
18-
gem 'sqlite3'
19-
end
207
else
218
gemspec
22-
23-
gem 'sqlite3'
249
end
2510

11+
ruby_ver = ENV.fetch('RUBY_VERSION', '')
12+
rails_ver = ENV.fetch('RAILS_VERSION', '')
13+
activeadmin_ver = ENV.fetch('ACTIVEADMIN_VERSION', '')
14+
15+
rails = rails_ver.empty? ? ['rails'] : ['rails', "~> #{rails_ver}"]
16+
gem(*rails)
17+
18+
activeadmin = activeadmin_ver.empty? ? ['activeadmin'] : ['activeadmin', "~> #{activeadmin_ver}"]
19+
gem(*activeadmin)
20+
21+
ruby32 = Gem::Version.new(ruby_ver) >= Gem::Version.new('3.2')
22+
rails72 = Gem::Version.new(rails_ver) >= Gem::Version.new('7.2')
23+
sqlite3 = ruby32 || rails72 ? ['sqlite3'] : ['sqlite3', '~> 1.4']
24+
gem(*sqlite3)
25+
26+
# NOTE: to avoid error: uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger
27+
gem 'concurrent-ruby', '1.3.4'
28+
29+
# Misc
2630
gem 'bigdecimal'
31+
gem 'csv'
2732
gem 'mutex_m'
2833
gem 'puma'
2934
gem 'sassc'

Makefile

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1+
include extra/.env
2+
13
help:
2-
@echo "Main targets: up / down / console / shell"
4+
@echo "Main targets: build / specs / up / server / specs / shell"
35

46
# Docker commands
5-
down:
6-
docker compose down
77

8-
up:
9-
docker compose up
8+
build:
9+
@rm -f Gemfile.lock spec/dummy/db/*.sqlite3
10+
@docker compose -f extra/docker-compose.yml build
1011

11-
attach:
12-
docker compose attach app
12+
db_reset:
13+
@docker compose -f extra/docker-compose.yml run --rm app bin/rails db:reset db:test:prepare
1314

14-
up_attach:
15-
docker compose up -d && docker compose attach app
15+
up: build db_reset
16+
@docker compose -f extra/docker-compose.yml up
1617

1718
cleanup:
18-
docker container rm -f activeadmin_quill_editor_app && docker image rm -f activeadmin_quill_editor-app
19+
@docker compose -f extra/docker-compose.yml down --volumes --rmi local --remove-orphans
1920

20-
# Rails specific commands
21-
console:
22-
docker compose exec -e "PAGER=more" app bin/rails console
21+
# App commands
2322

24-
routes:
25-
docker compose exec app bin/rails routes
23+
server:
24+
@docker compose -f extra/docker-compose.yml exec app bin/rails server -b 0.0.0.0 -p ${SERVER_PORT}
25+
26+
console:
27+
@docker compose -f extra/docker-compose.yml exec app bin/rails console
2628

2729
specs:
28-
docker compose exec app bin/rspec --fail-fast
30+
@docker compose -f extra/docker-compose.yml exec app bin/rspec --fail-fast
2931

30-
# Other commands
31-
bundle:
32-
docker compose exec app bundle
32+
lint:
33+
@docker compose -f extra/docker-compose.yml exec app bin/rubocop
3334

3435
shell:
35-
docker compose exec -e "PAGER=more" app bash
36-
37-
lint:
38-
docker compose exec app bin/rubocop
36+
@docker compose -f extra/docker-compose.yml exec app bash

README.md

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -117,50 +117,7 @@ Some methods are provided for advanced use cases:
117117

118118
Project created by [Mattia Roccoberton](http://blocknot.es), thanks also to the good guys that opened issues and pull requests from time to time.
119119

120-
There 3 ways to interact with this project:
121-
122-
1) Using Docker:
123-
124-
```sh
125-
# Run rails server on the dummy app (=> http://localhost:3000 to access to ActiveAdmin):
126-
make up
127-
# Enter in a Rails console (with the dummy app started):
128-
make console
129-
# Enter in a shell (with the dummy app started):
130-
make shell
131-
# Run the linter on the project (with the dummy app started):
132-
make lint
133-
# Run the test suite (with the dummy app started):
134-
make specs
135-
# Remove container and image:
136-
make cleanup
137-
# To try different versions of Ruby/Rails/ActiveAdmin edit docker-compose.yml
138-
# For more commands please check the Makefile
139-
```
140-
141-
2) Using Appraisal:
142-
143-
```sh
144-
export RAILS_ENV=development
145-
# Install dependencies
146-
bin/appraisal
147-
# Run server (or any command)
148-
bin/appraisal rails s
149-
# Or with specific versions
150-
bin/appraisal rails71-activeadmin rails s
151-
```
152-
153-
3) With a local setup:
154-
155-
```sh
156-
# Dev setup (set the required envs)
157-
source extra/dev_setup.sh
158-
# Install dependencies
159-
bundle
160-
# Run server (or any command)
161-
bin/rails s
162-
# To try different versions of Rails/ActiveAdmin edit extra/dev_setup.sh
163-
```
120+
For development information please check [this document](extra/development.md).
164121

165122
## Do you like it? Star it!
166123

Rakefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# frozen_string_literal: true
22

3+
begin
4+
require 'bundler/setup'
5+
rescue LoadError
6+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7+
end
8+
9+
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
10+
load 'rails/tasks/engine.rake'
11+
12+
load 'rails/tasks/statistics.rake'
13+
314
require 'bundler/gem_tasks'
415

516
begin

bin/rails

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This command will automatically be run when you run "rails" with Rails gems
33
# installed from the root of your application.
44

5-
ENV['RAILS_ENV'] ||= 'test'
5+
ENV['RAILS_ENV'] ||= 'development'
66

77
ENGINE_ROOT = File.expand_path('..', __dir__)
88
ENGINE_PATH = File.expand_path('../lib/activeadmin/quill_editor/engine', __dir__)

docker-compose.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

extra/.bashrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
alias ls='ls --color'
2+
alias ll='ls -l'
3+
alias la='ls -la'

0 commit comments

Comments
 (0)