Skip to content

Commit

Permalink
tests: add multiple urls to our dogfood
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Oct 3, 2019
1 parent ccb528b commit 13c9bfd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
35 changes: 35 additions & 0 deletions 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);
});
6 changes: 5 additions & 1 deletion scripts/ci-dogfood.sh
Expand Up @@ -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"

Expand Down

0 comments on commit 13c9bfd

Please sign in to comment.