-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
misc: add lhci dogfood script to travis #9677
Changes from 8 commits
ee4a2e6
1ec0c5d
8039529
07cc490
1c667a1
27f69e2
0aa48d2
0c5839c
35479ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
set -euox pipefail | ||
|
||
# This script requires LHCI_CANARY_SERVER_URL and LHCI_CANARY_SERVER_TOKEN variables to be set. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
does this mean only PRs from core contributors will get this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could've sworn I replied to this already... anyhoo, yes it's only available to core contributors at the moment, but that's not a hard requirement, we could loosen this and hardcode them if we wanted later they're not really that secret since you could find them out yourself given the URL of our server. |
||
|
||
if [[ "$TRAVIS_NODE_VERSION" != "10" ]]; then | ||
echo "Not running dogfood script on node versions other than 10"; | ||
exit 0; | ||
fi | ||
|
||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
LH_ROOT_DIR="$SCRIPT_DIR/../.." | ||
|
||
# Testing lhci takes time and the server ain't massive, we'll only run the tests if we touched files that affect the report. | ||
CHANGED_FILES="" | ||
if [[ "$CI" ]]; then | ||
CHANGED_FILES=$(git --no-pager diff --name-only "$TRAVIS_COMMIT_RANGE") | ||
else | ||
CHANGED_FILES=$(git --no-pager diff --name-only master) | ||
fi | ||
|
||
printf "Determined the following files have been touched:\n\n$CHANGED_FILES\n\n" | ||
|
||
if ! echo "$CHANGED_FILES" | grep -E 'report|lhci' > /dev/null; then | ||
echo "No report files affected, skipping lhci checks." | ||
exit 0 | ||
fi | ||
|
||
# Generate an HTML report | ||
patrickhulce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
yarn now-build | ||
cp ./dist/now/english/index.html ./lighthouse-cli/test/fixtures/lhci.report.html | ||
|
||
# Start up a test server. | ||
yarn static-server & | ||
# Wait for the server to start before hitting it with data. | ||
sleep 10 | ||
# Install LHCI | ||
npm install -g @lhci/cli@next | ||
patrickhulce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Collect our LHCI results. | ||
lhci collect --url=http://localhost:10200/lhci.report.html | ||
# Upload the results to our canary server. | ||
lhci upload --serverBaseUrl="$LHCI_CANARY_SERVER_URL" --token="$LHCI_CANARY_SERVER_TOKEN" | ||
|
||
# Kill the static server from earlier. | ||
kill $! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
but they don't. so it doesnt really matter. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the benefit of doing this here instead of in the /bin/bash shebang? all my personal scripts look like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no benefit I'm aware of, just personal habit I suppose.
is there a benefit to doing it in the shebang? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like one liners i guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh after some googling I remembered I started this habit back at a company that used
#!/usr/bin/env bash
in all our scripts where the one-liner wasn't an option, so I guess that's one benefit of thisset
method is that it can be consistent across those two methods :)