Skip to content
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 save latest run script #11516

Merged
merged 4 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions lighthouse-core/scripts/save-latest-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
patrickhulce marked this conversation as resolved.
Show resolved Hide resolved

##
# @license Copyright 2020 The Lighthouse Authors. 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.
##

set -euo pipefail

# Saves the necessary contents of the `latest-run/` folder to a subfolder for easier A/B comparison.
# Restoring the contents to `latest-run/` is just `cp latest-run/latest-run-bak/* latest-run/`.

DIRNAME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LH_ROOT="$DIRNAME/../.."
TARGET_DIR=${1:-latest-run-bak}

cd "$LH_ROOT/latest-run"
mkdir -p "$TARGET_DIR"

for file in *.json ; do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for file in *.json ; do
for file in *.* ; do

i mean we dont have non-json now but figure it can be flexible for all non-directories..

Copy link
Collaborator Author

@patrickhulce patrickhulce Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't that pickup the default of .bak?

selfishly that also means it starts to pick up all the various *.zips when I need to upload these to issues 😬

can we only do this when we have a need for something other than json?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't that pickup the default of .bak?

lol right.. suggestion above for that.

can we only do this when we have a need for something other than json?

sure

echo "Copying $file to $TARGET_DIR..."
cp "$file" "$TARGET_DIR/$file"
done
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"diff:sample-json": "yarn i18n:checks && bash lighthouse-core/scripts/assert-golden-lhr-unchanged.sh",
"computeBenchmarkIndex": "./lighthouse-core/scripts/benchmark.js",
"minify-latest-run": "./lighthouse-core/scripts/lantern/minify-trace.js ./latest-run/defaultPass.trace.json ./latest-run/defaultPass.trace.min.json && ./lighthouse-core/scripts/lantern/minify-devtoolslog.js ./latest-run/defaultPass.devtoolslog.json ./latest-run/defaultPass.devtoolslog.min.json",
"save-latest-run": "./lighthouse-core/scripts/save-latest-run.sh",
"compile-proto": "protoc --python_out=./ ./proto/lighthouse-result.proto && mv ./proto/*_pb2.py ./proto/scripts || (echo \"❌ Install protobuf ≥ 3.7.1 to compile the proto file.\" && false)",
"build-proto-roundtrip": "mkdir -p .tmp && cross-env PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2 python proto/scripts/json_roundtrip_via_proto.py",
"static-server": "node lighthouse-cli/test/fixtures/static-server.js"
Expand Down