Skip to content

Commit

Permalink
feat: Expanded .percy.yml configuration support (#257)
Browse files Browse the repository at this point in the history
* add page pool size to constants

* add page pool size to asset discovery options

* add agent configuration to .percy.yml test file

* refactored how we handle constants. Moved them to be in with the services they are for. Started to add asset discovery options from the configuration file

* assert that asset discovery configuration values make it through

* refactor agent configuration

* cleanup

* further refactoring configuration handling

* refactor away default configuration values from the ConfigurationService

* expand test coverage for ConfigurationService

* default min height should be 1024

* actually set the default file value

* set page pool size to ideal values learned through some performance testing

* remove console.log

* shift type packages to devDependencies
  • Loading branch information
djones authored Jul 2, 2019
1 parent 0feb8cd commit 9538202
Show file tree
Hide file tree
Showing 34 changed files with 406 additions and 271 deletions.
66 changes: 49 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
"@oclif/config": "^1",
"@oclif/plugin-help": "^2",
"@oclif/plugin-not-found": "^1.2",
"@types/express": "^4.16.0",
"@types/js-yaml": "^3.11.2",
"@types/puppeteer": "^1.6.0",
"axios": "^0.18.1",
"body-parser": "^1.18.3",
"colors": "^1.3.2",
"cors": "^2.8.4",
"cross-spawn": "^6.0.5",
"deepmerge": "^3.2.1",
"express": "^4.16.3",
"generic-pool": "^3.7.1",
"globby": "^9.2.0",
Expand All @@ -54,13 +52,18 @@
"@types/chai": "^4.1.4",
"@types/chai-http": "^3.0.5",
"@types/cheerio": "^0.22.11",
"@types/colors": "^1.2.1",
"@types/cors": "^2.8.4",
"@types/deepmerge": "^2.2.0",
"@types/express": "^4.16.0",
"@types/cross-spawn": "^6.0.0",
"@types/generic-pool": "^3.1.9",
"@types/http-server": "^0.10.0",
"@types/js-yaml": "^3.11.2",
"@types/mocha": "^5.2.5",
"@types/nock": "^10.0.2",
"@types/node": "^12.0.0",
"@types/puppeteer": "^1.6.0",
"@types/sinon": "^7.0.12",
"@types/sinon-chai": "^3.2.0",
"babel-loader": "^8.0.6",
Expand Down
12 changes: 6 additions & 6 deletions src/commands/exec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {flags} from '@oclif/command'
import * as spawn from 'cross-spawn'
import Constants from '../services/constants'
import { DEFAULT_CONFIGURATION } from '../configuration/configuration'
import ConfigurationService from '../services/configuration-service'
import PercyCommand from './percy-command'

export default class Exec extends PercyCommand {
Expand All @@ -16,12 +17,12 @@ export default class Exec extends PercyCommand {
static flags = {
'network-idle-timeout': flags.integer({
char: 't',
default: Constants.NETWORK_IDLE_TIMEOUT,
default: DEFAULT_CONFIGURATION.agent['asset-discovery']['network-idle-timeout'],
description: 'asset discovery network idle timeout (in milliseconds)',
}),
'port': flags.integer({
char: 'p',
default: Constants.PORT,
default: DEFAULT_CONFIGURATION.agent.port,
description: 'port',
}),
}
Expand All @@ -32,8 +33,6 @@ export default class Exec extends PercyCommand {
const {argv} = this.parse(Exec)
const {flags} = this.parse(Exec)

const port = flags.port as number
const networkIdleTimeout = flags['network-idle-timeout'] as number
const command = argv.shift()

if (!command) {
Expand All @@ -44,7 +43,8 @@ export default class Exec extends PercyCommand {
}

if (this.percyWillRun()) {
await this.agentService.start({port, networkIdleTimeout})
const configuration = new ConfigurationService().applyFlags(flags)
await this.agentService.start(configuration)
this.logStart()
}

Expand Down
5 changes: 2 additions & 3 deletions src/commands/health-check.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Command, flags} from '@oclif/command'
import * as colors from 'colors'
import Constants from '../services/constants'
import {DEFAULT_CONFIGURATION} from '../configuration/configuration'
import healthCheck from '../utils/health-checker'

export default class HealthCheck extends Command {
Expand All @@ -10,7 +9,7 @@ export default class HealthCheck extends Command {
static flags = {
port: flags.integer({
char: 'p',
default: Constants.PORT,
default: DEFAULT_CONFIGURATION.agent.port,
description: 'port',
}),
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/percy-command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Command} from '@oclif/command'
import * as winston from 'winston'
import AgentService from '../services/agent-service'
import {AgentService} from '../services/agent-service'
import ProcessService from '../services/process-service'
import logger from '../utils/logger'

Expand Down
Loading

0 comments on commit 9538202

Please sign in to comment.