diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml new file mode 100644 index 0000000..e1c32bd --- /dev/null +++ b/.github/workflows/rspec.yml @@ -0,0 +1,15 @@ +name: RSpec + +on: + pull_request: + +jobs: + rspec: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - name: Run specs + run: bundle exec rspec diff --git a/lib/diffdash/cli/runner.rb b/lib/diffdash/cli/runner.rb index 7f490b0..4b90f79 100644 --- a/lib/diffdash/cli/runner.rb +++ b/lib/diffdash/cli/runner.rb @@ -5,7 +5,7 @@ module CLI # Thin CLI glue. Orchestrates engine + output adapters. class Runner VALID_OPTIONS = %w[--dry-run --verbose -v --help -h].freeze - VALID_SUBCOMMANDS = %w[folders].freeze + VALID_SUBCOMMANDS = %w[folders rspec].freeze def self.run(args) new(args).execute @@ -42,6 +42,8 @@ def execute case @subcommand when "folders" return list_grafana_folders + when "rspec" + return run_rspec end warn "[diffdash] v#{VERSION}" @@ -105,6 +107,13 @@ def find_invalid_arguments end end + def rspec_args + idx = @args.index("rspec") + return [] unless idx + + @args[(idx + 1)..] || [] + end + def build_outputs(change_set) title = Formatters::DashboardTitle.sanitize(change_set.branch_name) @@ -200,6 +209,13 @@ def list_grafana_folders 1 end + def run_rspec + cmd = ["bundle", "exec", "rspec", *rspec_args] + warn "[diffdash] Running: #{cmd.join(" ")}" + system(*cmd) + $?.success? ? 0 : 1 + end + def print_signal_summary(bundle, url: nil) log_count = bundle.logs.size counter_count = bundle.metrics.count { |s| s.metadata[:metric_type] == :counter } @@ -275,6 +291,7 @@ def print_help Commands: folders List available Grafana folders + rspec [args] Run the RSpec suite (passes args through) (none) Run analysis and generate/upload dashboard Options: