Commit 033b5754 authored by Wei-Yin Chen (陳威尹)'s avatar Wei-Yin Chen (陳威尹) Committed by Commit Bot

Use code review in DOM distiller dist repo

Before this CL, this script builds DOM distiller, pushes the compiled
artifacts to the dom-distiller/dist repo, and generates a local commit
for rolling. The local commit needs to be uploaded as a CL.

In order to avoid pushing without reviewing, we want to generate a CL
in the dom-distiller/dist repo instead of directly pushing to it.

When reviewing the CL in the dom-distiller/dist repo, the reviewer
needs to run update_domdistiller_js.sh in validation mode to make sure
the artifacts in the CL are identical to local output.

Bug: None
Change-Id: Ia29c1686106c3516f341e4d826aca69842ac5668
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2304338Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789575}
parent 8adc9665
......@@ -5,10 +5,13 @@
# found in the LICENSE file.
#
# Clones the dom-distiller repo, compiles and extracts its javascript Then
# copies that js into the Chromium tree.
# Clones the dom-distiller repo, compiles and extracts its JavaScript. The
# artifact would be uploaded as a CL in dom-distiller/dist repo, and then
# generates a rolling commit to be uploaded.
# This script requires that ant is installed. It takes an optional parameter
# for which SHA1 to roll to. If left unspecified the script rolls to HEAD.
# for which SHA1 in dom-distiller repo to roll to. If left unspecified the
# script rolls to HEAD. The second optional parameter is the Gerrit URL of
# the CL in dom-distiller/dist repo to be validated.
(
set -e
......@@ -27,11 +30,17 @@
mkdir $tmpdir
pushd $tmpdir
function finish {
rm -rf $tmpdir
}
trap finish EXIT
git clone $repo_host/dom-distiller
pushd dom-distiller
# The new git SHA1 is HEAD or the first command line parameter.
[[ -z "$1" ]] && gitsha_target="HEAD" || gitsha_target="$1"
gerrit_url="$2"
new_gitsha=$(git rev-parse --short=10 ${gitsha_target})
git reset --hard ${new_gitsha}
git log --oneline ${curr_gitsha}..${new_gitsha} > $changes
......@@ -57,8 +66,13 @@
popd # dom-distiller
git clone $repo_host/dom-distiller/dist $tmpdir/dom-distiller-dist
rm -rf $tmpdir/dom-distiller-dist/*
pushd dom-distiller-dist
if [[ -n "$gerrit_url" ]]; then
echo "Validating $gerrit_url"
git cl patch --force $gerrit_url
fi
rm -rf $tmpdir/dom-distiller-dist/*
cp -r $tmpdir/dom-distiller/out/package/* .
# Stop rolling python/plugin_pb2.py for protobuf backward compatibility.
......@@ -67,10 +81,35 @@
git add .
if [[ $(git status --short | wc -l) -ne 0 ]]; then
git commit -a -m "Package for ${new_gitsha}"
git push origin master
if [[ -n "$gerrit_url" ]]; then
echo "FAIL. The output is different from $gerrit_url."
exit 1
fi
# For Change-Id footer.
curl -Lo $(git rev-parse --git-dir)/hooks/commit-msg https://gerrit-review.googlesource.com/tools/hooks/commit-msg
chmod +x $(git rev-parse --git-dir)/hooks/commit-msg
gen_message () {
echo "Package for ${new_gitsha}"
echo
echo "This is generated from:"
echo "${repo_host}/dom-distiller/+/${new_gitsha}."
echo
echo "To validate, run the following command in chromium/src:"
echo "third_party/dom_distiller_js/update_domdistiller_js.sh ${new_gitsha} <Gerrit-URL>"
}
message=$tmpdir/message
gen_message > $message
git commit -a -F $message
git push origin master:refs/for/master
else
# No changes to external repo, but need to check if DEPS refers to same SHA1.
if [[ -n "$gerrit_url" ]]; then
echo "PASS. The output is the same as $gerrit_url."
exit 0
fi
echo "WARNING: There were no changes to the distribution package."
fi
new_dist_gitsha=$(git rev-parse HEAD)
......@@ -80,7 +119,6 @@
curr_dist_gitsha=$(grep -e "/chromium\/dom-distiller\/dist.git" $src_path/DEPS | sed -e "s/.*'\([A-Za-z0-9]\{40\}\)'.*/\1/g")
if [[ "${new_dist_gitsha}" == "${curr_dist_gitsha}" ]]; then
echo "The roll does not include any changes to the dist package. Exiting."
rm -rf $tmpdir
exit 1
fi
......@@ -101,7 +139,6 @@
cat $bugs
}
message=$tmpdir/message
gen_message > $message
# Run checklicenses.py on the pulled files, but only print the output on
......@@ -109,6 +146,4 @@
$src_path/tools/checklicenses/checklicenses.py third_party/dom_distiller_js > $tmpdir/checklicenses.out || cat $tmpdir/checklicenses.out
git commit -a -F $message
rm -rf $tmpdir
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment