From 13c9bfdfbc7bd4fa66b752d698dc4871dd38e76f Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Wed, 2 Oct 2019 14:46:11 -0500 Subject: [PATCH] tests: add multiple urls to our dogfood --- scripts/ci-dogfood-get-urls.js | 35 ++++++++++++++++++++++++++++++++++ scripts/ci-dogfood.sh | 6 +++++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 scripts/ci-dogfood-get-urls.js diff --git a/scripts/ci-dogfood-get-urls.js b/scripts/ci-dogfood-get-urls.js new file mode 100644 index 000000000..95b7f8230 --- /dev/null +++ b/scripts/ci-dogfood-get-urls.js @@ -0,0 +1,35 @@ +/** + * @license Copyright 2019 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ +'use strict'; + +const ApiClient = require('@lhci/utils/src/api-client.js'); + +async function main() { + const rootURL = process.env.LHCI_ROOT_URL; + if (!rootURL) throw new Error(`Missing LHCI_ROOT_URL environment variable`); + + const client = new ApiClient({rootURL}); + + const projects = await client.getProjects(); + const project = projects.find(project => project.name.includes('Viewer')) || projects[0]; + const builds = await client.getBuilds(project.id); + const build = builds.find(build => build.branch.includes('test_1')) || builds[0]; + + process.stdout.write( + [ + new URL(`/app`, rootURL), + new URL(`/app/projects/${project.id}`, rootURL), + new URL(`/app/projects/${project.id}/builds/${build.id}`, rootURL), + ].join('\n') + ); + + process.exit(0); +} + +main().catch(err => { + process.stderr.write(err.stack); + process.exit(1); +}); diff --git a/scripts/ci-dogfood.sh b/scripts/ci-dogfood.sh index 6e9e31445..32d5623e5 100755 --- a/scripts/ci-dogfood.sh +++ b/scripts/ci-dogfood.sh @@ -17,7 +17,11 @@ sleep 10 # Seed the database with some data for us to audit. yarn start:seed-database # Collect our LHCI results. -yarn start collect --url=http://localhost:9009/app +rm -rf .lighthouseci/ +for url in $(LHCI_ROOT_URL=http://localhost:9009 node ./scripts/ci-dogfood-get-urls.js); do + yarn start collect "--url=$url" --additive +done + # Upload the results to our canary server. yarn start upload --serverBaseUrl="$LHCI_CANARY_SERVER_URL" --token="$LHCI_CANARY_SERVER_TOKEN"