function run(config) {
  let endpoint;
  let body = JSON.stringify(config);

  switch (config.runner) {
    case RUNNERS.wpt:
      endpoint = `${CI_HOST}/run_on_wpt`;
      break;
    case RUNNERS.chrome: // same as default
    default:
      endpoint = `${CI_HOST}/run_on_chrome`;
      body = JSON.stringify(Object.assign({output: 'json'}, config));
  }

  fetch(endpoint, {method: 'POST', body, headers: {
    'Content-Type': 'application/json',
    'X-API-KEY': API_KEY
  }})
    .then(resp => resp.json())
    .then(json => {
      if (config.runner === RUNNERS.wpt) {
        console.log(
          `Started Lighthouse run on WebPageTest: ${json.data.target_url}`);
        return;
      }
      console.log('New Lighthouse scores:');
      console.log(JSON.stringify(json));
    })
    .catch(err => {
      console.log('Lighthouse CI failed', err);
      process.exit(1);
    });
}
@param {!Object} config Settings to run the Lighthouse CI.