Skip to content
Merged
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
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/Makefile
/LICENSE.txt
/Gemfile.lock
/extra/init.sh

/app
/bin
/coverage
/gemfiles
/spec/dummy/db/*.sqlite3
/spec/dummy/log
/spec/dummy/tmp
/spec/dummy/**/*_spec.rb

/**/*.md
2 changes: 0 additions & 2 deletions .env

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/specs_rails70.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Database setup
run: bin/rails db:reset db:test:prepare

- name: Run tests
run: bundle exec rspec --profile

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/specs_rails71.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Database setup
run: bin/rails db:reset db:test:prepare

- name: Run tests
run: bundle exec rspec --profile

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/specs_rails72.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Database setup
run: bin/rails db:reset db:test:prepare

- name: Run tests
run: bundle exec rspec --profile

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/specs_rails80.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Database setup
run: bin/rails db:reset db:test:prepare

- name: Run tests
run: bundle exec rspec --profile

Expand Down
17 changes: 14 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@
source 'https://rubygems.org'

if ENV['DEVEL'] == '1'
rails_ver = ENV.fetch('RAILS_VERSION')
gem 'rails', rails_ver
rails_ver = ENV.fetch('RAILS_VERSION', '')
activeadmin_ver = ENV.fetch('ACTIVEADMIN_VERSION', '')

if rails_ver.empty?
gem 'rails'
else
gem 'rails', "~> #{rails_ver}"
end

if activeadmin_ver.empty?
gem 'activeadmin'
else
gem 'activeadmin', "~> #{activeadmin_ver}"
end

gem 'activeadmin', ENV.fetch('ACTIVEADMIN_VERSION')
gem 'activeadmin_dynamic_fields', path: './'
gem 'appraisal', '~> 2.4'

Expand Down
43 changes: 19 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
include extra/.env

help:
@echo "Main targets: up / down / console / shell"
@echo "Main targets: build / specs / up / server / specs / shell"

# Docker commands
down:
docker compose down

up:
docker compose up

attach:
docker compose attach app
build:
@rm -f Gemfile.lock
@docker compose -f extra/docker-compose.yml build

up_attach:
docker compose up -d && docker compose attach app
up: build
@docker compose -f extra/docker-compose.yml up

cleanup:
docker container rm -f activeadmin_dynamic_fields_app && docker image rm -f activeadmin_dynamic_fields-app
@docker compose -f extra/docker-compose.yml down --volumes --rmi local --remove-orphans

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

routes:
docker compose exec app bin/rails routes
server:
@docker compose -f extra/docker-compose.yml exec app bin/rails s -b 0.0.0.0 -p ${SERVER_PORT}

specs:
docker compose exec app bin/rspec --fail-fast
@docker compose -f extra/docker-compose.yml exec app bin/rspec --fail-fast

lint:
@docker compose -f extra/docker-compose.yml exec app bin/rubocop

# Other commands
bundle:
docker compose exec app bundle
appraisal_update:
@docker compose -f extra/docker-compose.yml exec app bin/appraisal update

shell:
docker compose exec -e "PAGER=more" app bash

lint:
docker compose exec app bin/rubocop
@docker compose -f extra/docker-compose.yml exec app bash
45 changes: 1 addition & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,50 +239,7 @@ The link url is loaded via AJAX before opening the dialog.

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

There 3 ways to interact with this project:

1) Using Docker:

```sh
# Run rails server on the dummy app (=> http://localhost:3000 to access to ActiveAdmin):
make up
# Enter in a Rails console (with the dummy app started):
make console
# Enter in a shell (with the dummy app started):
make shell
# Run the linter on the project (with the dummy app started):
make lint
# Run the test suite (with the dummy app started):
make specs
# Remove container and image:
make cleanup
# To try different versions of Ruby/Rails/ActiveAdmin edit docker-compose.yml
# For more commands please check the Makefile
```

2) Using Appraisal:

```sh
export RAILS_ENV=development
# Install dependencies:
bin/appraisal
# Run server (or any command):
bin/appraisal rails s
# Or with a specific configuration:
bin/appraisal rails80-activeadmin rails s
```

3) With a local setup:

```sh
# Dev setup (set the required envs):
source extra/dev_setup.sh
# Install dependencies:
bundle update
# Run server (or any command):
bin/rails s
# To try different versions of Rails/ActiveAdmin edit extra/dev_setup.sh
```
For development information please check [this document](extra/development.md).

## Do you like it? Star it!

Expand Down
11 changes: 11 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# frozen_string_literal: true

begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end

APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
load 'rails/tasks/engine.rake'

load 'rails/tasks/statistics.rake'

require 'bundler/gem_tasks'

begin
Expand Down
3 changes: 1 addition & 2 deletions activeadmin_dynamic_fields.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
$:.push File.expand_path('lib', __dir__)
require 'activeadmin/dynamic_fields/version'

Gem::Specification.new do |spec|
Expand Down
2 changes: 1 addition & 1 deletion bin/rails
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

# ENV['RAILS_ENV'] ||= 'test'
ENV['RAILS_ENV'] ||= 'development'

ENGINE_ROOT = File.expand_path('..', __dir__)
ENGINE_PATH = File.expand_path('../lib/activeadmin/dynamic_fields/engine', __dir__)
Expand Down
25 changes: 0 additions & 25 deletions docker-compose.yml

This file was deleted.

3 changes: 3 additions & 0 deletions extra/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alias ls='ls --color'
alias ll='ls -l'
alias la='ls -la'
7 changes: 7 additions & 0 deletions extra/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
COMPOSE_PROJECT_NAME=activeadmin_dynamic_fields

BUNDLER_VERSION=2.5.23
SERVER_PORT=4000

UID=1000
GID=1000
26 changes: 18 additions & 8 deletions extra/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
ARG RUBY_IMAGE=ruby:3
FROM ${RUBY_IMAGE}

ARG UID

ENV DEBIAN_FRONTEND=noninteractive
ENV DEVEL=1
ENV LANG=C.UTF-8
ENV RAILS_ENV=development

RUN apt-get update -qq
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yqq --no-install-recommends build-essential chromium libyaml-dev nano
RUN apt-get install -yqq --no-install-recommends build-essential chromium libyaml-dev nano netcat-traditional pkg-config

RUN gem install bundler
ARG BUNDLER_VERSION
RUN gem install bundler -v ${BUNDLER_VERSION}
RUN echo 'gem: --no-document' > /etc/gemrc

RUN useradd -u ${UID} --shell /bin/bash app
ARG UID
RUN useradd -u $UID --shell /bin/bash app

RUN mkdir -p /home/app && chown -R app:app /home/app
RUN chown -R app /usr/local/bundle

USER ${UID}
ARG RAILS_VERSION
ENV RAILS_VERSION=$RAILS_VERSION

ARG ACTIVEADMIN_VERSION
ENV ACTIVEADMIN_VERSION=$ACTIVEADMIN_VERSION

WORKDIR /app
COPY . /app
RUN bundle install
RUN chown -R app:app /app/spec/dummy/db /usr/local/bundle

RUN ln -s /app/extra/.bashrc /home/app/.bashrc
18 changes: 0 additions & 18 deletions extra/Dockerfile_alpine

This file was deleted.

47 changes: 47 additions & 0 deletions extra/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## Development

There 3 ways to interact with this project:

1) Using Docker:

```sh
# Run rails server on the dummy app (=> http://localhost:3000 to access to ActiveAdmin):
make up
# Enter in a Rails console (with the dummy app started):
make console
# Enter in a shell (with the dummy app started):
make shell
# Run the linter on the project (with the dummy app started):
make lint
# Run the test suite (with the dummy app started):
make specs
# Remove container and image:
make cleanup
# To try different versions of Ruby/Rails/ActiveAdmin:
RUBY=3.2 RAILS=7.1.0 ACTIVEADMIN=3.2.0 make up
# For more commands please check the Makefile
```

2) Using Appraisal:

```sh
export RAILS_ENV=development
# Install dependencies:
bin/appraisal
# Run server (or any command):
bin/appraisal rails s
# Or with a specific configuration:
bin/appraisal rails80-activeadmin rails s
```

3) With a local setup:

```sh
# Dev setup (set the required envs):
source extra/dev_setup.sh
# Install dependencies:
bundle update
# Run server (or any command):
bin/rails s
# To try different versions of Rails/ActiveAdmin edit extra/dev_setup.sh
```
20 changes: 20 additions & 0 deletions extra/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:
app:
build:
context: ..
dockerfile: extra/Dockerfile
args:
ACTIVEADMIN_VERSION: ${ACTIVEADMIN:-}
BUNDLER_VERSION: ${BUNDLER_VERSION}
RAILS_VERSION: ${RAILS:-}
RUBY_IMAGE: ruby:${RUBY:-3.4}-slim
UID: ${UID}
user: ${UID}:${GID}
ports:
- ${SERVER_PORT}:${SERVER_PORT}
working_dir: /app
volumes:
- ..:/app
stdin_open: true
tty: true
command: ${COMMAND:-extra/init.sh}
Loading