diff --git a/.github/workflows/ruby_tests.yml b/.github/workflows/ruby_tests.yml index 9b86813e7..4b5c08deb 100644 --- a/.github/workflows/ruby_tests.yml +++ b/.github/workflows/ruby_tests.yml @@ -2,6 +2,10 @@ name: Ruby Tests on: pull_request jobs: + rubocop: + uses: theforeman/actions/.github/workflows/rubocop.yml@v0 + with: + command: bundle exec rubocop --parallel --format github Test_ruby: runs-on: ubuntu-latest strategy: diff --git a/lib/foreman_maintain/utils/command_runner.rb b/lib/foreman_maintain/utils/command_runner.rb index 27a8ae19b..cb02e08c0 100644 --- a/lib/foreman_maintain/utils/command_runner.rb +++ b/lib/foreman_maintain/utils/command_runner.rb @@ -8,13 +8,15 @@ class CommandRunner attr_reader :logger, :command def initialize(logger, command, options) - options.validate_options!(:stdin, :hidden_patterns, :interactive, :valid_exit_statuses) + options.validate_options!(:stdin, :hidden_patterns, :interactive, :valid_exit_statuses, + :discard_stderr) options[:valid_exit_statuses] ||= [0] @logger = logger @command = command @stdin = options[:stdin] @hidden_patterns = Array(options[:hidden_patterns]).compact @interactive = options[:interactive] + @discard_stderr = options[:discard_stderr] || false @options = options @valid_exit_statuses = options[:valid_exit_statuses] raise ArgumentError, 'Can not pass stdin for interactive command' if @interactive && @stdin @@ -92,7 +94,11 @@ def run_non_interactively end def full_command - "#{@command} 2>&1" + if @discard_stderr + @command.to_s + else + "#{@command} 2>&1" + end end def hide_strings(string)