percy / cli

The Percy CLI is used to interact with, and upload snapshots to, percy.io via the command line.
https://docs.percy.io/docs/cli-overview
70 stars 43 forks source link

Can't change the port via CLI #786

Closed nskazki closed 2 years ago

nskazki commented 2 years ago

The problem

Can't change the port. The -P and --port arguments are ignored. The PERCY_SERVER_PORT environment variable is ignored.

Environment

Details

The documentation says the port can be changed via the command line arguments: https://docs.percy.io/docs/cli-exec#percy-exec.

This piece of code defines those arguments as well as offers an additional way of changing the port, via the environment variable, and yet I can't change it: https://github.com/percy/cli/blob/a0c0c9a3e1cfdde44639fa17385c5764feb9415e/packages/cli-exec/src/common.js

However, percy-capybara doesn't have problems with overriding the server's address, which results in the failed connection as you will see below. The overriding is happening here https://github.com/percy/percy-capybara/blob/1bdb8b8f334965cc9d753d89d54237eb224d43ae/lib/percy/capybara.rb#L11.

Debug logs

$ PERCY_TOKEN=xxx PERCY_SERVER_ADDRESS=http://localhost:9000 percy exec --port 9000 --debug -- rspec spec/features/create_campaign_spec.rb:33
[percy:config] Found config file: .percy.yml (0ms)
[percy:config] Using config:
{
  version: 2,
  snapshot: {
    widths: [
      375,
      980,
      1280
    ]
  },
  discovery: {
    disableCache: true,
    networkIdleTimeout: 350
  }
} (9ms)
[percy:core:browser] Launching browser (8ms)
[percy:core:browser] Browser connected [69080]: HeadlessChrome/92.0.4515.0 (181ms)
[percy:core] Percy has started! (1ms)
[percy:cli:exec] Running "rspec spec/features/create_campaign_spec.rb:33" (0ms)
Run options: include {:locations=>{"./spec/features/create_campaign_spec.rb"=>[33]}}

Randomized with seed 33240
Capybara starting Puma...
* Version 5.6.2 , codename: Birdie's Version
* Min threads: 0, max threads: 4
* Listening on http://127.0.0.1:59505
[percy:capybara] Percy is not running, disabling snapshots
[percy:capybara] Failed to open TCP connection to localhost:9000 (Connection refused - connect(2) for "localhost" port 9000)
.

Top 1 slowest examples (11.73 seconds, 99.7% of total time):
  create campaign creates competition
    11.73 seconds ./spec/features/create_campaign_spec.rb:33

Finished in 11.77 seconds (files took 2.43 seconds to load)
1 example, 0 failures

Randomized with seed 33240

[percy:core:browser] Closing browser (14581ms)
[percy:core:browser] Browser closed (7ms)
[percy:core] Build not created (0ms)
wwilsman commented 2 years ago

Thanks for the bug report @nskazki! Will have a fix for this shipped shortly 👍