Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Upload to different surge domains based on PR
Browse files Browse the repository at this point in the history
  • Loading branch information
fofr committed Sep 13, 2017
1 parent 14ee206 commit 4fb92c6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 1 addition & 3 deletions app.rb
Expand Up @@ -13,8 +13,6 @@
end

environment = payload['deployment']['environment']
review_domain = "https://#{environment}.herokuapp.com"

paths = GovukVisualRegression::VisualDiff::DocumentTypes.new.type_paths('statistics')
GovukVisualRegression::VisualDiff::Runner.new(paths: paths, review_domain: review_domain).run
GovukVisualRegression::VisualDiff::HerokuRunner.new(paths: paths, environment: environment).run
end
3 changes: 2 additions & 1 deletion lib/govuk_visual_regression/visual_diff/heroku_runner.rb
Expand Up @@ -6,7 +6,8 @@ def install_surge
end

def upload_to_surge
@kernel.system "surge --project results/visual/ --domain govuk-vr.surge.sh"
surge_domain = @environment ? @environment : "govuk-vr"
@kernel.system "surge --project results/visual/ --domain #{surge_domain}.surge.sh"
end

def run
Expand Down
8 changes: 4 additions & 4 deletions lib/govuk_visual_regression/visual_diff/runner.rb
@@ -1,15 +1,15 @@
module GovukVisualRegression
module VisualDiff
class Runner
def initialize(paths:, review_domain: nil, live_domain: nil, kernel: Kernel)
def initialize(paths:, environment: nil, kernel: Kernel)
@paths = paths
@kernel = kernel
@live_domain = live_domain
@review_domain = review_domain
@environment = environment
end

def run
wraith_config = WraithConfig.new(paths: @paths, review_domain: @review_domain, live_domain: @live_domain)
review_domain = @environment ? "https://#{@environment}.herokuapp.com" : nil
wraith_config = WraithConfig.new(paths: @paths, review_domain: review_domain)
wraith_config.write

cmd = "wraith capture #{wraith_config.location}"
Expand Down
4 changes: 2 additions & 2 deletions spec/govuk_visual_regression/visual_diff/runner_spec.rb
Expand Up @@ -12,12 +12,12 @@
end

it "executes wraith with the appropriate config" do
expect(config_handler_klass).to receive(:new).with(paths: ["/government/stats/foo", "/government/stats/bar"], review_domain: 'review', live_domain: nil)
expect(config_handler_klass).to receive(:new).with(paths: ["/government/stats/foo", "/government/stats/bar"], review_domain: nil)
expect(config_handler).to receive(:write)
expect(kernel).to receive(:system).with("wraith capture #{config_handler.location}")
expect(config_handler).to receive(:delete)

expect { described_class.new(paths: input_paths, review_domain: 'review', kernel: kernel).run }.to output(
expect { described_class.new(paths: input_paths, kernel: kernel).run }.to output(
"---> Creating Visual Diffs\n" +
"running: wraith capture #{config_handler.location}\n"
).to_stdout
Expand Down

0 comments on commit 4fb92c6

Please sign in to comment.