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

Release v6.23.0 #697

Merged
merged 81 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
7bea4f0
Add Bugsnag::BreadcrumbType module
imjoehaines Aug 11, 2021
5eff8c0
Add Configuration#enabled_release_stages
imjoehaines Aug 11, 2021
afa4599
Add message & metadata to replace name & meta_data
imjoehaines Aug 11, 2021
63050e4
Add Configuration#enabled_breadcrumb_types
imjoehaines Aug 11, 2021
4ff542e
Add metadata to Report to replace meta_data
imjoehaines Aug 12, 2021
8fc8894
Add Event as an alias of the Report class
imjoehaines Aug 12, 2021
1154aaa
Add Configuration#auto_track_sessions
imjoehaines Aug 12, 2021
9cf9d76
Use the new property names in some MR tests
imjoehaines Aug 12, 2021
c987ca7
Update changelog
imjoehaines Aug 12, 2021
44c0494
Update CHANGELOG.md
imjoehaines Aug 12, 2021
5ca25e8
Merge pull request #676 from bugsnag/aliases
imjoehaines Aug 13, 2021
e31e408
Don't start a session in a disabled release stage
imjoehaines Aug 16, 2021
86a9aa6
Update changelog
imjoehaines Aug 16, 2021
e03bebd
Merge pull request #677 from bugsnag/dont-start-sessions-in-wrong-rel…
imjoehaines Aug 16, 2021
3ad02fd
Deliver sessions every 10 seconds
imjoehaines Aug 18, 2021
abe01c7
Update changelog
imjoehaines Aug 18, 2021
444c8d6
Merge pull request #680 from bugsnag/send-sessions-more-frequently
imjoehaines Aug 18, 2021
9bf9dd8
Refactor logging tests to use a real Logger
imjoehaines Aug 18, 2021
7b4b57c
Add Configuration#error to log error messages
imjoehaines Aug 18, 2021
52f67e7
Log delivery failures at error level
imjoehaines Aug 18, 2021
693a666
Update changelog
imjoehaines Aug 18, 2021
1bcfe6a
Merge pull request #681 from bugsnag/log-delivery-failures-as-errors
imjoehaines Aug 18, 2021
a1daac7
Add tests for a job that does not raise
imjoehaines Aug 19, 2021
f4602ff
Allow rails_integration fixture to be run manually
imjoehaines Aug 19, 2021
448fb37
Add routes & a controller to queue jobs
imjoehaines Aug 19, 2021
1084ebb
Add missing deprecation to changelog
imjoehaines Aug 19, 2021
616210e
Merge pull request #682 from bugsnag/tests-for-successful-job-execution
imjoehaines Aug 20, 2021
574b3dd
Merge pull request #684 from bugsnag/add-missing-deprecation-to-chang…
imjoehaines Aug 20, 2021
f4030f9
Add OnBreadcrumbCallbackList class
imjoehaines Aug 20, 2021
c4de39f
Handle errors raised in on_breadcrumb callbacks
imjoehaines Aug 20, 2021
21f459b
Move before_breadcrumb tests to a new describe
imjoehaines Aug 20, 2021
99d7729
Add add and remove on_breadcrumb methods
imjoehaines Aug 20, 2021
056d110
Call on_breadcrumb callbacks in leave_breadcrumb
imjoehaines Aug 20, 2021
21f20fc
Add script to run the integrations fixture
imjoehaines Aug 19, 2021
0fb28b2
Add run-rails-integrations to testing doc
imjoehaines Aug 23, 2021
7545b01
Update changelog
imjoehaines Aug 23, 2021
49f3465
Merge pull request #683 from bugsnag/allow-manually-testing-integrati…
imjoehaines Aug 23, 2021
36a1c7b
Merge pull request #686 from bugsnag/on-breadcrumb-callbacks
imjoehaines Aug 23, 2021
4fd0a9d
Allow setting context on Configuration
imjoehaines Aug 25, 2021
49699c8
Use the Configuration context for new events
imjoehaines Aug 25, 2021
7c64262
Update changelog
imjoehaines Aug 25, 2021
d145e26
Allow setting an 'automatic_context' on events
imjoehaines Aug 25, 2021
c1b43ee
Set automatic context in integrations & middleware
imjoehaines Aug 25, 2021
8f0f031
Add note for the configuration context precedence
imjoehaines Aug 25, 2021
1b3c6f4
Use the configuration context even if it's 'nil'
imjoehaines Aug 25, 2021
ba1e877
Update changelog
imjoehaines Aug 25, 2021
1bac40a
Merge pull request #687 from bugsnag/add-default-context
imjoehaines Aug 25, 2021
50759dd
Merge pull request #688 from bugsnag/configuration-context-precedence
imjoehaines Aug 25, 2021
36a0fa4
Add Bugsnag#breadcrumbs
imjoehaines Aug 25, 2021
394311a
Merge pull request #689 from bugsnag/breadcrumbs-getter
imjoehaines Aug 26, 2021
5968696
Add 'time' to device metadata
imjoehaines Aug 25, 2021
3964c37
Add some Maze Runner checks for device time
imjoehaines Aug 25, 2021
45736b6
Update changelog
imjoehaines Aug 26, 2021
65da7c9
Merge pull request #690 from bugsnag/add-device-time
imjoehaines Aug 26, 2021
8b64784
Add 'errors' to Report/Event class
imjoehaines Sep 3, 2021
6cb175e
Update changelog
imjoehaines Sep 6, 2021
d45a084
Add 'original_error' attribute
imjoehaines Sep 6, 2021
46c9a84
Update changelog
imjoehaines Sep 6, 2021
8bc5558
Refactor Rack spec to use a real Report instance
imjoehaines Sep 6, 2021
2467be3
Add Report#request to fetch HTTP request data
imjoehaines Sep 7, 2021
87b39ac
Update changelog
imjoehaines Sep 7, 2021
d10d22e
Add a MR test for all request data
imjoehaines Sep 7, 2021
452d0d8
Add MR test showing request data can be mutated
imjoehaines Sep 7, 2021
91eee12
Merge pull request #691 from bugsnag/add-report-errors
imjoehaines Sep 7, 2021
e1938de
Merge pull request #692 from bugsnag/add-original-error
imjoehaines Sep 8, 2021
6710a46
Merge pull request #693 from bugsnag/add-report-request
imjoehaines Sep 8, 2021
95abdd9
Add MetadataDelegate utility class
imjoehaines Sep 9, 2021
aa0f7dc
Move metadata delegate tests into shared examples
imjoehaines Sep 9, 2021
4f8d6f9
Add #add_metadata and #clear_metadata methods
imjoehaines Sep 9, 2021
cb0e926
Deprecated add_tab & remove_tab
imjoehaines Sep 9, 2021
17bdb42
Update changelog
imjoehaines Sep 9, 2021
d5ae38c
Merge pull request #694 from bugsnag/improve-metadata-api
imjoehaines Sep 9, 2021
1074a63
Add the stacktrace to each Error
imjoehaines Sep 10, 2021
9f3a75f
Refactor Error class to make stacktrace readonly
imjoehaines Sep 10, 2021
6e63b62
Add Report#set_user
imjoehaines Sep 10, 2021
91ff9c7
Update changelog
imjoehaines Sep 10, 2021
bc36cd1
Merge pull request #695 from bugsnag/add-stacktrace-to-errors
imjoehaines Sep 13, 2021
e8fe0d2
Merge pull request #696 from bugsnag/add-set-user-to-report
imjoehaines Sep 13, 2021
ca54356
Add stacktrace to Error object summary
imjoehaines Sep 14, 2021
2089377
Update changelog
imjoehaines Sep 17, 2021
00460bf
Bump version
imjoehaines Sep 17, 2021
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
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,57 @@
Changelog
=========

## v6.23.0 (21 September 2021)

### Enhancements

* Sessions will now be delivered every 10 seconds, instead of every 30 seconds
| [#680](https://github.com/bugsnag/bugsnag-ruby/pull/680)
* Log errors that prevent delivery at `ERROR` level
| [#681](https://github.com/bugsnag/bugsnag-ruby/pull/681)
* Add `on_breadcrumb` callbacks to replace `before_breadcrumb_callbacks`
| [#686](https://github.com/bugsnag/bugsnag-ruby/pull/686)
* Add `context` attribute to configuration, which will be used as the default context for events. Using this option will disable automatic context setting
| [#687](https://github.com/bugsnag/bugsnag-ruby/pull/687)
| [#688](https://github.com/bugsnag/bugsnag-ruby/pull/688)
* Add `Bugsnag#breadcrumbs` getter to fetch the current list of breadcrumbs
| [#689](https://github.com/bugsnag/bugsnag-ruby/pull/689)
* Add `time` (an ISO8601 string in UTC) to `device` metadata
| [#690](https://github.com/bugsnag/bugsnag-ruby/pull/690)
* Add `errors` to `Report`/`Event` containing an array of `Error` objects. The `Error` object contains `error_class`, `error_message`, `stacktrace` and `type` (always "ruby")
| [#691](https://github.com/bugsnag/bugsnag-ruby/pull/691)
* Add `original_error` to `Report`/`Event` containing the original Exception instance
| [#692](https://github.com/bugsnag/bugsnag-ruby/pull/692)
* Add `request` to `Report`/`Event` containing HTTP request metadata
| [#693](https://github.com/bugsnag/bugsnag-ruby/pull/693)
* Add `add_metadata` and `clear_metadata` to `Report`/`Event`
| [#694](https://github.com/bugsnag/bugsnag-ruby/pull/694)
* Add `set_user` to `Report`/`Event`
| [#695](https://github.com/bugsnag/bugsnag-ruby/pull/695)

### Fixes

* Avoid starting session delivery thread when the current release stage is not enabled
| [#677](https://github.com/bugsnag/bugsnag-ruby/pull/677)

### Deprecated

* `before_breadcrumb_callbacks` have been deprecated in favour of `on_breadcrumb` callbacks and will be removed in the next major release
* For consistency with Bugsnag notifiers for other languages, a number of methods have been deprecated in this release. The old options will be removed in the next major version | [#676](https://github.com/bugsnag/bugsnag-ruby/pull/676)
* The `notify_release_stages` configuration option has been deprecated in favour of `enabled_release_stages`
* The `auto_capture_sessions` and `track_sessions` configuration options have been deprecated in favour of `auto_track_sessions`
* The `enabled_automatic_breadcrumb_types` configuration option has been deprecated in favour of `enabled_breadcrumb_types`
* The `Report` class has been deprecated in favour of the `Event` class
* The `Report#meta_data` attribute has been deprecated in favour of `Event#metadata`
* The `Breadcrumb#meta_data` attribute has been deprecated in favour of `Breadcrumb#metadata`
* The `Breadcrumb#name` attribute has been deprecated in favour of `Breadcrumb#message`
* The breadcrumb type constants in the `Bugsnag::Breadcrumbs` module has been deprecated in favour of the constants available in the `Bugsnag::BreadcrumbType` module
For example, `Bugsnag::Breadcrumbs::ERROR_BREADCRUMB_TYPE` is now available as `Bugsnag::BreadcrumbType::ERROR`
* `Report#exceptions` has been deprecated in favour of the new `errors` property
* `Report#raw_exceptions` has been deprecated in favour of the new `original_error` property
* Accessing request data via `Report#metadata` has been deprecated in favour of using the new `request` property. Request data will be moved out of metadata in the next major version
* The `Report#add_tab` and `Report#remove_tab` methods have been deprecated in favour of the new `add_metadata` and `clear_metadata` methods

## v6.22.1 (11 August 2021)

### Fixes
Expand Down
21 changes: 21 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,24 @@ RUBY_TEST_VERSION=2.6 RAILS_VERSION=6 docker-compose run --use-aliases ruby-maze
```

In order to avoid running flakey or unfinished tests, the tag `"not @wip"` can be added to the tags option. This is recommended for all CI runs. If a tag is already specified, this should be added using the `and` keyword, e.g. `--tags "@rails6 and not @wip"`

## Manually testing queue libraries

To help manually test queue libraries and Active Job with various queue adapters, you can use [the `run-ruby-integrations` script](./features/fixtures/run-ruby-integrations). This takes care of installing your local copy of Bugsnag, booting Rails, setting up the database and booting the queue library

As with the end-to-end tests, only Bugsnag employees can run this script as it relies on the same private resources

The script will default to booting Sidekiq:

```
# run the rails_integrations fixture with sidekiq
$ ./features/fixtures/run-rails-integrations
```

The script can also run Resque, Que or Delayed Job:

```
$ ./features/fixtures/run-rails-integrations resque
$ ./features/fixtures/run-rails-integrations que
$ ./features/fixtures/run-rails-integrations delayed_job
```
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.22.1
6.23.0
6 changes: 6 additions & 0 deletions features/fixtures/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ services:
- SQL_ONLY_BREADCRUMBS
- ADD_ON_ERROR
- USE_DEFAULT_AUTO_CAPTURE_SESSIONS
- ADD_REQUEST_ON_ERROR
restart: "no"

rails4:
Expand Down Expand Up @@ -165,6 +166,7 @@ services:
- SQL_ONLY_BREADCRUMBS
- ADD_ON_ERROR
- USE_DEFAULT_AUTO_CAPTURE_SESSIONS
- ADD_REQUEST_ON_ERROR
restart: "no"

rails5:
Expand Down Expand Up @@ -201,6 +203,7 @@ services:
- SQL_ONLY_BREADCRUMBS
- ADD_ON_ERROR
- USE_DEFAULT_AUTO_CAPTURE_SESSIONS
- ADD_REQUEST_ON_ERROR
restart: "no"

rails6:
Expand Down Expand Up @@ -237,6 +240,7 @@ services:
- SQL_ONLY_BREADCRUMBS
- ADD_ON_ERROR
- USE_DEFAULT_AUTO_CAPTURE_SESSIONS
- ADD_REQUEST_ON_ERROR
restart: "no"
networks:
default:
Expand All @@ -261,6 +265,8 @@ services:
- RUN_AT_EXIT_HOOKS
- ACTIVE_JOB_QUEUE_ADAPTER
restart: "no"
ports:
- "3000:3000"

sidekiq:
build:
Expand Down
2 changes: 1 addition & 1 deletion features/fixtures/plain/app/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def configure_using_environment
conf.auto_notify = ENV["BUGSNAG_AUTO_NOTIFY"] != "false"
conf.ignore_classes << lambda { |ex| ex.class.to_s == ENV["BUGSNAG_IGNORE_CLASS"] } if ENV.include? "BUGSNAG_IGNORE_CLASS"
conf.meta_data_filters << ENV["BUGSNAG_META_DATA_FILTERS"] if ENV.include? "BUGSNAG_META_DATA_FILTERS"
conf.notify_release_stages = [ENV["BUGSNAG_NOTIFY_RELEASE_STAGE"]] if ENV.include? "BUGSNAG_NOTIFY_RELEASE_STAGE"
conf.enabled_release_stages = [ENV["BUGSNAG_NOTIFY_RELEASE_STAGE"]] if ENV.include? "BUGSNAG_NOTIFY_RELEASE_STAGE"
conf.project_root = ENV["BUGSNAG_PROJECT_ROOT"] if ENV.include? "BUGSNAG_PROJECT_ROOT"
conf.proxy_host = ENV["BUGSNAG_PROXY_HOST"] if ENV.include? "BUGSNAG_PROXY_HOST"
conf.proxy_password = ENV["BUGSNAG_PROXY_PASSWORD"] if ENV.include? "BUGSNAG_PROXY_PASSWORD"
Expand Down
7 changes: 7 additions & 0 deletions features/fixtures/rails3/app/config/initializers/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@
})
end)
end

if ENV["ADD_REQUEST_ON_ERROR"] == "true"
config.add_on_error(proc do |report|
report.request[:something] = "hello"
report.request[:params][:another_thing] = "hi"
end)
end
end
7 changes: 7 additions & 0 deletions features/fixtures/rails4/app/config/initializers/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@
})
end)
end

if ENV["ADD_REQUEST_ON_ERROR"] == "true"
config.add_on_error(proc do |report|
report.request[:something] = "hello"
report.request[:params][:another_thing] = "hi"
end)
end
end
11 changes: 9 additions & 2 deletions features/fixtures/rails5/app/config/initializers/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
config.auto_notify = ENV["BUGSNAG_AUTO_NOTIFY"] != "false"
config.project_root = ENV["BUGSNAG_PROJECT_ROOT"] if ENV.include? "BUGSNAG_PROJECT_ROOT"
config.ignore_classes << lambda { |ex| ex.class.to_s == ENV["BUGSNAG_IGNORE_CLASS"] } if ENV.include? "BUGSNAG_IGNORE_CLASS"
config.auto_capture_sessions = ENV["BUGSNAG_AUTO_CAPTURE_SESSIONS"] == "true" unless ENV["USE_DEFAULT_AUTO_CAPTURE_SESSIONS"] == "true"
config.auto_track_sessions = ENV["BUGSNAG_AUTO_CAPTURE_SESSIONS"] == "true" unless ENV["USE_DEFAULT_AUTO_CAPTURE_SESSIONS"] == "true"
config.send_code = ENV["BUGSNAG_SEND_CODE"] != "false"
config.send_environment = ENV["BUGSNAG_SEND_ENVIRONMENT"] == "true"
config.meta_data_filters << 'filtered_parameter'

if ENV["SQL_ONLY_BREADCRUMBS"] == "true"
config.before_breadcrumb_callbacks << Proc.new do |breadcrumb|
breadcrumb.ignore! unless breadcrumb.meta_data[:event_name] == "sql.active_record" && breadcrumb.meta_data[:name] == "User Load"
breadcrumb.ignore! unless breadcrumb.metadata[:event_name] == "sql.active_record" && breadcrumb.metadata[:name] == "User Load"
end
end

Expand All @@ -25,4 +25,11 @@
})
end)
end

if ENV["ADD_REQUEST_ON_ERROR"] == "true"
config.add_on_error(proc do |report|
report.request[:something] = "hello"
report.request[:params][:another_thing] = "hi"
end)
end
end
7 changes: 7 additions & 0 deletions features/fixtures/rails6/app/config/initializers/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@
})
end)
end

if ENV["ADD_REQUEST_ON_ERROR"] == "true"
config.add_on_error(proc do |report|
report.request[:something] = "hello"
report.request[:params][:another_thing] = "hi"
end)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class JobController < ApplicationController
def working
WorkingJob.perform_later

render json: { result: 'queued WorkingJob!' }
end

def unhandled
UnhandledJob.perform_later

render json: { result: 'queued UnhandledJob!' }
end
end
23 changes: 23 additions & 0 deletions features/fixtures/rails_integrations/app/app/jobs/working_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class WorkingJob < ApplicationJob
self.queue_adapter = ENV['ACTIVE_JOB_QUEUE_ADAPTER'].to_sym

def perform
do_stuff

more_stuff

success!
end

def do_stuff
'beep boop'
end

def more_stuff
'boop beep'
end

def success!
'yay'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Application < Rails::Application
# Only loads a smaller set of middleware suitable for API only apps.
# Middleware like session, flash, cookies can be added back manually.
# Skip views, helpers and assets when generating a new resource.
config.api_only = true
# config.api_only = true

config.autoload_paths << Rails.root.join('app/workers')
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

config.hosts = []
end
3 changes: 2 additions & 1 deletion features/fixtures/rails_integrations/app/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
get '/job/working', 'job#working'
get '/job/unhandled', 'job#unhandled'
end
120 changes: 120 additions & 0 deletions features/fixtures/run-ruby-integrations
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/env ruby

require "socket"
require "timeout"
require "pathname"

DOCKER_DIRECTORY = Pathname.new(__dir__)
ROOT_DIRECTORY = DOCKER_DIRECTORY + "../.."
FIXTURE_DIRECTORY = DOCKER_DIRECTORY + "rails_integrations"

raise "Fixture directory does not exist at: '#{FIXTURE_DIRECTORY}'" unless FIXTURE_DIRECTORY.exist?

QUEUE_LIBRARY_COMMANDS = {
sidekiq: 'sidekiq',
resque: 'rake resque:work',
que: 'que --log-level debug --queue-name "*" ./config/environment.rb',
delayed_job: 'rake jobs:work',
}

QUEUE_LIBRARY = ARGV.fetch(0, :sidekiq).to_sym

raise "Invalid queue libarary '#{QUEUE_LIBRARY}'" unless QUEUE_LIBRARY_COMMANDS.key?(QUEUE_LIBRARY)

def wait_for_port(port, max_attempts: 60, seconds_between_attempts: 1)
is_open = false
attempts = 0

until is_open || attempts > max_attempts
begin
attempts += 1

# add a timeout as sometimes TCPSocket will wait for ages before realising
# it can't connect - this is a local port so should be """instant"""
Timeout.timeout(2) do
TCPSocket.new("127.0.0.1", port).close

# success!
is_open = true
end
rescue Timeout::Error, Errno::ECONNREFUSED, Errno::EHOSTUNREACH
# ignore timeouts and errors from the port being closed

# wait between attempts to give the port some time to open
sleep(seconds_between_attempts)
end
end

raise "Port #{port} not open in time!" unless is_open
end

def run_in_shell(command, env: {}, background: false)
puts "running '#{command}' with env: #{env}, background: #{background}"

if background
spawn(env, command)
else
system(env, command, exception: true)
end
end

def run_docker_command(command, env: {}, **kwargs)
default_env = { "NETWORK_NAME" => "notwerk-norm", "ACTIVE_JOB_QUEUE_ADAPTER" => QUEUE_LIBRARY.to_s }

run_in_shell(command, env: default_env.merge(env), **kwargs)
end

# ensure we clean up after ourselves on exit
at_exit do
temp_bugsnag_lib = FIXTURE_DIRECTORY + "temp-bugsnag-lib"
temp_bugsnag_lib.rmtree if temp_bugsnag_lib.exist?

# stop the docker compose stack
Dir.chdir(FIXTURE_DIRECTORY) do
run_docker_command("docker-compose down")
end
end

# build the bugsnag gem and move it to the fixture directory
Dir.chdir(ROOT_DIRECTORY) do
run_in_shell("gem build bugsnag.gemspec -o bugsnag.gem")
run_in_shell("mv bugsnag.gem #{FIXTURE_DIRECTORY}")
end

Dir.chdir(FIXTURE_DIRECTORY) do
# unpack the gem into the directory the dockerfile expects
run_in_shell("gem unpack bugsnag.gem --target temp-bugsnag-lib")
run_in_shell("rm bugsnag.gem")

rails_pid = run_docker_command(
"docker-compose up --build rails_integrations",
env: { "RUBY_TEST_VERSION" => "2.7" },
background: true
)

# wait for the container to finish building & starting
wait_for_port(3000)

# setup and migrate the database
run_docker_command("docker-compose run rails_integrations bundle exec rake db:prepare")
run_docker_command("docker-compose run rails_integrations bundle exec rake db:migrate")

# run the queue library in the background (not using '--detach' so we can see the logs)
queue_library_pid = run_docker_command(
"docker-compose run rails_integrations bundle exec #{QUEUE_LIBRARY_COMMANDS[QUEUE_LIBRARY]}",
background: true
)

# give the queue library some time to start before we print stuff, otherwise
# we'll print before the library does
sleep(5)

puts "Everything is running!"

# this will wait forever as the queue libraries won't exit on their own - quit with Ctrl+C
Process.wait(queue_library_pid)

# the queue library has exited (because of Ctrl+C) so tell rails to stop too,
# otherwise you'll need to Ctrl+C twice and no one has time for that
Process.kill("TERM", rails_pid)
end
Loading