Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
189 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
language: node_js | ||
node_js: '7' | ||
dist: trusty | ||
sudo: false | ||
git: | ||
depth: 1 | ||
env: | ||
global: | ||
- CLOUDSDK_CORE_DISABLE_PROMPTS=1 | ||
- CLOUDSDK_PYTHON_SITEPACKAGES=1 | ||
- GAE_APP_ID=cr-status | ||
cache: | ||
directories: | ||
- node_modules | ||
- travis/node_modules | ||
install: | ||
- npm install -g bower gulp | ||
- npm install | ||
- npm run install-travis | ||
script: | ||
- npm run lint | ||
- npm run build | ||
after_success: | ||
- "./travis/deploy_pr_gae.sh" | ||
- export LH_MIN_PASS_SCORE=96 | ||
- export LH_TEST_URL=https://lighthouse-ci-staging-dot-cr-status.appspot.com/features | ||
- node travis/runLighthouse.js $LH_TEST_URL $LH_MIN_PASS_SCORE |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Auto-Deploy Pull Request | ||
|
||
# If this isn't a pull request, abort. | ||
if [ "${TRAVIS_EVENT_TYPE}" != "pull_request" ]; then | ||
echo "This only runs on pull_request events. Event was $TRAVIS_EVENT_TYPE." | ||
exit | ||
fi | ||
|
||
# If there were build failures, abort | ||
if [ "${TRAVIS_TEST_RESULT}" = "1" ]; then | ||
echo "Deploy aborted, there were build/test failures." | ||
exit | ||
fi | ||
|
||
./travis/install_google_cloud_sdk.sh | ||
|
||
# Set the AppEngine version for staging | ||
# VERSION=pr-$TRAVIS_PULL_REQUEST | ||
VERSION=lighthouse-ci-staging | ||
|
||
# Determine staging URL based on PR. | ||
export LH_TEST_URL=https://$VERSION-dot-$GAE_APP_ID.appspot.com/features | ||
echo "Pull Request: $TRAVIS_PULL_REQUEST will be staged at $LH_TEST_URL" | ||
|
||
# Deploy to AppEngine | ||
$HOME/google-cloud-sdk/bin/gcloud app deploy app.yaml -q --no-promote --version $VERSION | ||
|
||
# Make sure an AppEngine instance has started. | ||
curl $LH_TEST_URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Installs the Google Cloud SDK | ||
|
||
# Decrypt the Service Account Key | ||
openssl aes-256-cbc -K $encrypted_aee7e38c959c_key -iv $encrypted_aee7e38c959c_iv \ | ||
-in gcloud-client-secret.json.enc -out gcloud-client-secret.json -d | ||
|
||
# Download & install the Google Cloud SDK | ||
curl https://sdk.cloud.google.com | bash | ||
|
||
# Update any necessary components | ||
$HOME/google-cloud-sdk/bin/gcloud components update -q | ||
|
||
# Set the AppEngine App ID to $GAE_APP_ID | ||
$HOME/google-cloud-sdk/bin/gcloud config set project $GAE_APP_ID | ||
|
||
# Authenticate to AppEngine using the service account | ||
$HOME/google-cloud-sdk/bin/gcloud auth activate-service-account \ | ||
--key-file gcloud-client-secret.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "chrome-status-ci", | ||
"version": "0.0.1", | ||
"main": "index.js", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"chalk": "^1.1.3", | ||
"github": "^9.2.0", | ||
"node-fetch": "^1.6.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* Copyright 2017 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 chalk = require('chalk'); | ||
const fetch = require('node-fetch'); // polyfill | ||
|
||
const args = process.argv.slice(2); | ||
const LH_TEST_URL = args[0]; | ||
const LH_MIN_PASS_SCORE = args[1]; | ||
const PR_NUM = process.env.TRAVIS_PULL_REQUEST; | ||
const PR_SHA = process.env.TRAVIS_PULL_REQUEST_SHA; | ||
const REPO_SLUG = process.env.TRAVIS_PULL_REQUEST_SLUG; | ||
|
||
const CI_HOST = 'https://lighthouse-ci.appspot.com'; | ||
const API_KEY = process.env.API_KEY; | ||
const RUNNERS = {chrome: 'chrome', wpt: 'wpt'}; | ||
|
||
/** | ||
* @param {!string} runner Where to run Lighthouse. | ||
*/ | ||
function run(runner) { | ||
const data = { | ||
testUrl: LH_TEST_URL, | ||
minPassScore: Number(LH_MIN_PASS_SCORE), | ||
repo: { | ||
owner: REPO_SLUG.split('/')[0], | ||
name: REPO_SLUG.split('/')[1] | ||
}, | ||
pr: { | ||
number: parseInt(PR_NUM, 10), | ||
sha: PR_SHA | ||
} | ||
}; | ||
|
||
let endpoint; | ||
let body = JSON.stringify(data); | ||
|
||
switch (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({format: 'json'}, data)); | ||
} | ||
|
||
fetch(endpoint, { | ||
method: 'POST', | ||
body, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-API-KEY': API_KEY // Keep usage tight for now. | ||
} | ||
}) | ||
.then(resp => resp.json()) | ||
.then(json => { | ||
if (runner === RUNNERS.wpt) { | ||
console.log(chalk.green( | ||
`Started Lighthouse run on WebPageTest: ${json.data.target_url}`)); | ||
return; | ||
} | ||
|
||
let colorize = chalk.green; | ||
if (json.score < LH_MIN_PASS_SCORE) { | ||
colorize = chalk.red; | ||
} | ||
console.log(colorize('Lighthouse CI score:'), json.score); | ||
}) | ||
.catch(err => { | ||
console.log(chalk.red('Lighthouse CI failed'), err); | ||
process.exit(1); | ||
}); | ||
} | ||
|
||
// Run LH if this is a PR. | ||
if (process.env.TRAVIS_EVENT_TYPE === 'pull_request') { | ||
run(RUNNERS.wpt); | ||
} else { | ||
console.log('Lighthouse not run for non-PR commits'); | ||
} |