Skip to content

Commit

Permalink
tests(ci): sample flow result check (#13728)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine authored Mar 17, 2022
1 parent 9847c11 commit 61a9ca8
Show file tree
Hide file tree
Showing 6 changed files with 769,568 additions and 801,438 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/.github/scripts/jest-retry.sh yarn test-treemap

- run: yarn diff:sample-json
- run: yarn diff:flow-sample-json
- run: yarn type-check
- run: yarn lint
- run: yarn test-lantern
Expand Down
40 changes: 40 additions & 0 deletions lighthouse-core/scripts/assert-baseline-flow-result-unchanged.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

##
# @license Copyright 2022 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 -e

PWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LH_ROOT="$PWD/../.."
BASELINE_RESULT_PATH="$LH_ROOT/lighthouse-core/test/fixtures/fraggle-rock/reports/sample-flow-result.json"
TMP_PATH="$LH_ROOT/.tmp"
FRESH_RESULT_PATH="$TMP_PATH/fresh_flow_result.json"

purple='\033[1;35m'
red='\033[1;31m'
green='\033[1;32m'
colorText() {
printf "\\n$2$1%b\\n" '\033[0m'
}

colorText "Generating fresh flow result" "$purple"
yarn update:flow-sample-json --output-path "$TMP_PATH/fresh_flow_result.json"

colorText "Diff'ing baseline flow result against the fresh flow result" "$purple"

set +e
git --no-pager diff --color=always --no-index "$BASELINE_RESULT_PATH" "$FRESH_RESULT_PATH"
retVal=$?
set -e

if [ $retVal -eq 0 ]; then
colorText "✅ PASS. No change in the flow result." "$green"
else
colorText "❌ FAIL. Flow result has changed." "$red"
echo "Run \`yarn update:flow-sample-json\` to rebaseline the flow result."
fi
exit $retVal
Loading

0 comments on commit 61a9ca8

Please sign in to comment.