Skip to content

Commit

Permalink
Merge pull request #120 from appsignal/ruby-setup
Browse files Browse the repository at this point in the history
Fix runner for Ruby setup on GitHub Actions
  • Loading branch information
tombruijn authored Jul 2, 2024
2 parents 353efcf + 05ba1f6 commit e03053c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ Style/SymbolArray:
Metrics/AbcSize:
Enabled: false

Metrics/ClassLength:
Enabled: false

Metrics/BlockLength:
Exclude:
- Rakefile
Expand Down
4 changes: 2 additions & 2 deletions ruby/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
PATH
remote: ../../../..
specs:
appsignal (3.0.15)
appsignal (3.9.2)
rack

GEM
remote: https://rubygems.org/
specs:
rack (2.2.3)
rack (3.1.5)

PLATFORMS
ruby
Expand Down
4 changes: 2 additions & 2 deletions spec/diagnose_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
/ activejob_report_errors: "all"/,
%r{ ca_file_path: ".+/appsignal[-/]ruby/resources/cacert.pem"},
/ debug: false/,
/ dns_servers: \[\]/,
" dns_servers: []",
/ enable_allocation_tracking: true/,
/ enable_gvl_global_timer: true/,
/ enable_gvl_waiting_threads: true/,
Expand Down Expand Up @@ -472,7 +472,7 @@
/ system: true/,
/ ca_file_path: #{quoted ".+/_build/dev/rel/elixir_diagnose/lib/appsignal-\\d+\\.\\d+\\.\\d+(-\\w+\\.\\d+)?/priv/cacert.pem"}/, # rubocop:disable Layout/LineLength
/ debug: false/,
/ dns_servers: \[\]/,
" dns_servers: []",
/ enable_error_backend: true/,
/ enable_host_metrics: true/,
/ enable_minutely_probes: false/,
Expand Down
44 changes: 31 additions & 13 deletions spec/support/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,31 +91,41 @@ def install_report?
end

def run_env
{ "APPSIGNAL_PUSH_API_KEY" => @push_api_key }
{
"APPSIGNAL_PUSH_API_KEY" => @push_api_key,
"APPSIGNAL_PUSH_API_ENDPOINT" => ENV["APPSIGNAL_PUSH_API_ENDPOINT"],
"APPSIGNAL_DIAGNOSE_ENDPOINT" => ENV["APPSIGNAL_DIAGNOSE_ENDPOINT"]
}
end

def run_command(_arguments)
raise NotImplementedError, "`Runner` subclasses must implement `run_command`"
end

def run # rubocop:disable Metrics/MethodLength
Dir.chdir directory do
before_setup
setup_commands.each do |command|
run_setup command
Bundler.with_unbundled_env do
Dir.chdir directory do
before_setup
setup_commands.each do |command|
run_setup command
end
after_setup
end
after_setup
end

# Run the command
prompt = @prompt ? %(echo "#{@prompt}" | ) : ""
command = run_command(@arguments.dup)
read, write = IO.pipe
pid = spawn(
run_env,
"#{prompt} #{command}",
{ [:out, :err] => write, :chdir => directory }
)
env = run_env
pid =
Bundler.with_unbundled_env do
spawn(
env,
"#{prompt} #{command}",
{ [:out, :err] => write, :chdir => directory }
)
end
_pid, status = Process.wait2 pid # Wait until command exits
write.close

Expand Down Expand Up @@ -191,6 +201,13 @@ def directory
File.join(project_path, "ruby")
end

def setup_commands
[
"bundle config set --local gemfile #{directory}/Gemfile",
"bundle install"
]
end

def run_env
super.merge({
"BUNDLE_GEMFILE" => File.join(directory, "Gemfile")
Expand All @@ -205,7 +222,8 @@ def run_command(arguments)

def ignored_lines
[
/appsignal: Unable to log to /
/appsignal: Unable to log to /,
/Calling `DidYouMean::SPELL_CHECKERS/
]
end

Expand Down Expand Up @@ -270,7 +288,7 @@ def install_report
end
end

class Elixir < Runner # rubocop:disable Metrics/ClassLength
class Elixir < Runner
def directory
File.join(project_path, "elixir")
end
Expand Down

0 comments on commit e03053c

Please sign in to comment.