Skip to content

Commit 1f69b8f

Browse files
authored
Merge pull request #4 from rossme/DD-rspec-pr-autotest
DD-add rspec subcommand and PR CI
2 parents 8827d29 + 56df468 commit 1f69b8f

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

.github/workflows/rspec.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: RSpec
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
rspec:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: ruby/setup-ruby@v1
12+
with:
13+
bundler-cache: true
14+
- name: Run specs
15+
run: bundle exec rspec

lib/diffdash/cli/runner.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module CLI
55
# Thin CLI glue. Orchestrates engine + output adapters.
66
class Runner
77
VALID_OPTIONS = %w[--dry-run --verbose -v --help -h].freeze
8-
VALID_SUBCOMMANDS = %w[folders].freeze
8+
VALID_SUBCOMMANDS = %w[folders rspec].freeze
99

1010
def self.run(args)
1111
new(args).execute
@@ -42,6 +42,8 @@ def execute
4242
case @subcommand
4343
when "folders"
4444
return list_grafana_folders
45+
when "rspec"
46+
return run_rspec
4547
end
4648

4749
warn "[diffdash] v#{VERSION}"
@@ -105,6 +107,13 @@ def find_invalid_arguments
105107
end
106108
end
107109

110+
def rspec_args
111+
idx = @args.index("rspec")
112+
return [] unless idx
113+
114+
@args[(idx + 1)..] || []
115+
end
116+
108117
def build_outputs(change_set)
109118
title = Formatters::DashboardTitle.sanitize(change_set.branch_name)
110119

@@ -200,6 +209,13 @@ def list_grafana_folders
200209
1
201210
end
202211

212+
def run_rspec
213+
cmd = ["bundle", "exec", "rspec", *rspec_args]
214+
warn "[diffdash] Running: #{cmd.join(" ")}"
215+
system(*cmd)
216+
$?.success? ? 0 : 1
217+
end
218+
203219
def print_signal_summary(bundle, url: nil)
204220
log_count = bundle.logs.size
205221
counter_count = bundle.metrics.count { |s| s.metadata[:metric_type] == :counter }
@@ -275,6 +291,7 @@ def print_help
275291
276292
Commands:
277293
folders List available Grafana folders
294+
rspec [args] Run the RSpec suite (passes args through)
278295
(none) Run analysis and generate/upload dashboard
279296
280297
Options:

0 commit comments

Comments
 (0)