Skip to content
Draft
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
13 changes: 6 additions & 7 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,14 @@ jobs:
image: postgres:17
env:
POSTGRES_USER: alchemy_user
POSTGRES_PASSWORD: password
POSTGRES_DB: alchemy_cms_dummy_test
POSTGRES_HOST_AUTH_METHOD: trust
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mariadb:
image: mariadb:latest
ports: ["3307:3306"]
env:
MARIADB_USER: alchemy_user
MARIADB_PASSWORD: password
MARIADB_DATABASE: alchemy_cms_dummy_test
MARIADB_ROOT_PASSWORD: password
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 1
options: --health-cmd="mariadb-admin ping" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- uses: actions/checkout@v6
Expand Down Expand Up @@ -200,9 +196,12 @@ jobs:
- name: Prepare database
run: |
bundle exec rake alchemy:spec:prepare
cd spec/dummy
bin/rails parallel:setup
cd -
- name: Run tests
run: |
bundle exec rspec
bin/parallel_rspec
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
if: matrix.rails == '8.0' && matrix.ruby == '3.4'
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ end

group :development, :test do
gem "execjs", "~> 2.10.0"
gem "parallel_tests", "~> 5.5"
gem "rubocop", require: false
gem "standard", "~> 1.25", require: false

Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,34 @@ $ bundle exec rake

*) This default task executes the database preparations and runs all defined test cases.

### Run specs in parallel

Using https://github.com/grosser/parallel_tests

#### Once before running

```
bundle exec rake alchemy:spec:prepare
cd spec/dummy
bin/rails parallel:setup
cd -
```

#### Start a parallel test run

```
bin/parallel_rspec
```

#### After adding a new migration

```
cd spec/dummy
bin/rails alchemy:install:migrations
bin/rails parallel:migrate
cd -
```

### Start the dummy app

You can even start the dummy app and use it to manually test your changes with:
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/color_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Alchemy
module Ingredients
class ColorView < BaseView
def call
value
value.html_safe
end

def render?
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/select_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Ingredients
class SelectView < BaseView
def call
if ingredient.multiple? && value.is_a?(Array)
value.to_sentence
value.to_sentence.html_safe
else
super
end
Expand Down
3 changes: 3 additions & 0 deletions bin/parallel_rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
require "bundler/setup"
load Gem.bin_path("parallel_tests", "parallel_rspec")
11 changes: 5 additions & 6 deletions spec/dummy/config/database.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
sqlite: &sqlite
adapter: sqlite3
database: db/<%= Rails.env %>.sqlite3
database: db/<%= Rails.env %><%= ENV['TEST_ENV_NUMBER'] %>.sqlite3

mysql: &mysql
adapter: mysql2
encoding: utf8mb4
username: <%= ENV['DB_USER'] %>
password: <%= ENV['DB_PASSWORD'] %>
database: alchemy_cms_dummy_<%= Rails.env %>
database: alchemy_cms_dummy_<%= Rails.env %><%= ENV['TEST_ENV_NUMBER'] %>

mariadb: &mariadb
adapter: mysql2
encoding: utf8mb4
port: 3307
username: <%= ENV['DB_USER'] %>
password: <%= ENV['DB_PASSWORD'] %>
database: alchemy_cms_dummy_<%= Rails.env %>
username: root
database: alchemy_cms_dummy_<%= Rails.env %><%= ENV['TEST_ENV_NUMBER'] %>

postgresql: &postgresql
adapter: postgresql
<% if ENV['DB_USER'] %>
username: <%= ENV['DB_USER'] %>
password: <%= ENV['DB_PASSWORD'] %>
<% end %>
database: alchemy_cms_dummy_<%= Rails.env %>
database: alchemy_cms_dummy_<%= Rails.env %><%= ENV['TEST_ENV_NUMBER'] %>
min_messages: ERROR

defaults: &defaults
Expand Down
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@
add_filter "/lib/generators"
end

if ENV["TEST_ENV_NUMBER"] # parallel specs
SimpleCov.at_exit do
result = SimpleCov.result
result.format! if ParallelTests.number_of_running_processes <= 1
end
end

require "rspec/core"

RSpec.configure do |config|
config.raise_errors_for_deprecations!
config.run_all_when_everything_filtered = true
config.pattern = "**/*_spec.rb"
config.filter_run :focus
config.silence_filter_announcements = true if ENV["TEST_ENV_NUMBER"]
end
Loading