Skip to content

Commit

Permalink
Merge branch 'master' into securitybumps
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Nov 20, 2020
2 parents 1576cec + b0cf8ae commit a33fa62
Show file tree
Hide file tree
Showing 14 changed files with 783 additions and 591 deletions.
76 changes: 76 additions & 0 deletions .github/scripts/git-get-shared-history.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash

##
# @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 -euxo pipefail

# Overview:
# - build-tracker (https://lh-build-tracker.herokuapp.com/) relies on a common commit that's shared between HEAD and master.
# - Lighthouse runs on pull_request, not push, so the checkout is not the branch with shared history, but the result of a merge.
# - checkout@v2 uses a merge remote (eg. remotes/pull/9605/merge) that often has just a single commit.
# - This script creates a new branch that matches the current checkout, but does have a shared history.

# See also
# - https://github.com/paularmstrong/build-tracker/issues/106
# - https://github.com/paularmstrong/build-tracker/issues/200

# We can always use some more history
git -c protocol.version=2 fetch --deepen=100
echo "History is deepened."

if git merge-base HEAD origin/master > /dev/null; then
echo "We have a common commit w/ origin/master. Skipping this script…";
exit 0
else
echo "We don't have a common commit w/ origin/master. We'll checkout the associated branch, merge master, and then we'll be good"
fi

# get the human readable remote name
checkout_name=$(git describe --all --exact-match HEAD)


# We only want to keep going if it's a 'remotes/pull/{*}/merge'
if [[ $checkout_name != remotes/pull/*/merge ]]; then
echo "Don't know how to handle this checkout ($checkout_name). 🤔 Bailing.";
exit 0;
fi

# Extract 9605 from 'remotes/pull/9605/merge'
pr_num=${checkout_name//[!0-9]/}

lsremote_hash=$(git ls-remote origin "refs/pull/$pr_num/head" | cut -f1)

if [ -z "$lsremote_hash" ]; then
echo "ls-remote failed to find this PR's branch. 🤔 Bailing.";
exit 0;
fi

# Checkout our PR branch
git checkout --progress --force "$lsremote_hash"

# Branch off, for safekeeping
mergebranch_name="_bt_mergebranch-$pr_num"
git checkout -b "$mergebranch_name"

# Merge 'n commit
git -c "user.name=LH GH Action bot" -c "user.email=ghbot@lighthouse.repo" merge --no-verify \
-m "Merge remote-tracking branch 'origin/master' into $mergebranch_name" origin/master

# If there's a diff aginst where we started.. we fucked up
if git --no-pager diff --color=always --exit-code "$checkout_name" > /dev/null; then
echo "No diff, good!"
else
echo "Unexpected difference between $mergebranch_name and $checkout_name. Bailing";
exit 0;
fi

# Lastly, now we should definitely have a merge-base.
if git merge-base HEAD origin/master > /dev/null; then
echo "Merge-base found. Perfect. 👌"
else
echo "No diff, but still no merge-base. Very unexpected. 🤔"
fi
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ jobs:
# Fail if any changes were written to any source files or generated untracked files (ex, from: build/build-cdt-lib.js).
- run: git add -A && git diff --cached --exit-code

# buildtracker runs `git merge-base HEAD origin/master` which needs more history than depth=1. https://github.com/paularmstrong/build-tracker/issues/106
- name: Deepen git fetch (for buildtracker)
run: git fetch --deepen=100
# buildtracker needs history and a common merge commit.
- name: Fixup git history (for buildtracker)
run: bash $GITHUB_WORKSPACE/.github/scripts/git-get-shared-history.sh
- name: Store in buildtracker
# TODO(paulirish): Don't allow this to fail the build. https://github.com/paularmstrong/build-tracker/issues/200
run: yarn bt-cli upload-build || true
Expand Down
7 changes: 4 additions & 3 deletions lighthouse-cli/test/fixtures/perf/delayed-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ setTimeout(() => {
sectionEl.append(imgEl, textEl);
shadowRoot.append(sectionEl);

// layout-shift-elements: ensure we can handle missing shift elements
if (window.location.href.includes('?missing')) {
// layout-shift-elements: ensure we can handle shift elements that the protocol can no longer identify
// see https://github.com/GoogleChrome/lighthouse/pull/10877
if (window.location.href.includes('?evicted')) {
stall(100); // force a long task to ensure we reach the rerendering stage
setTimeout(async () => {
await rerender(20); // rerender a large number of nodes to evict the early layout shift node
await rerender(30); // rerender a large number of nodes to evict the early layout shift node
document.body.textContent = 'Now it is all gone!';
}, 50);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ module.exports = [
},
{
lhr: {
requestedUrl: 'http://localhost:10200/perf/trace-elements.html?missing',
finalUrl: 'http://localhost:10200/perf/trace-elements.html?missing',
requestedUrl: 'http://localhost:10200/perf/trace-elements.html?evicted',
finalUrl: 'http://localhost:10200/perf/trace-elements.html?evicted',
audits: {
'largest-contentful-paint-element': {
score: null,
Expand Down

0 comments on commit a33fa62

Please sign in to comment.