Skip to content

Commit

Permalink
Adds support for pushing sites that don't need build, and build bench…
Browse files Browse the repository at this point in the history
…mark site.

This should not affect CI for now.

--
PiperOrigin-RevId: 147346229
MOS_MIGRATED_REVID=147346229
  • Loading branch information
hermione521 authored and dslomov committed Feb 14, 2017
1 parent 59f8264 commit 01aa7d6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scripts/ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ function bazel_build() {
cp bazel-genfiles/bazel-distfile.zip $1/bazel-${release_label}-dist.zip
fi
cp bazel-genfiles/site/jekyll-tree.tar $1/www.bazel.build.tar
cp bazel-bin/src/tools/benchmark/webapp/site.tar $1/perf.bazel.build.tar.nobuild
cp bazel-genfiles/scripts/packages/README.md $1/README.md
fi
}
Expand Down Expand Up @@ -486,6 +487,7 @@ function bazel_release() {
# Use jekyll build to build the site and then gsutil to copy it to GCS
# Input: $1 tarball to the jekyll site
# $2 name of the bucket to deploy the site to
# $3 "nobuild" if only publish without build
# It requires to have gsutil installed. You can force the path to gsutil
# by setting the GSUTIL environment variable
function build_and_publish_site() {
Expand All @@ -494,17 +496,23 @@ function build_and_publish_site() {
local gs="$(get_gsutil)"
local site="$1"
local bucket="$2"
local nobuild="$3"

if [ ! -f "${site}" ] || [ -z "${bucket}" ]; then
echo "Usage: build_and_publish_site <site-tarball> <bucket>" >&2
return 1
fi
tar xf "${site}" --exclude=CNAME -C "${tmpdir}"
jekyll build -s "${tmpdir}" -d "${tmpdir}/production"
local prod_dir="${tmpdir}"
if [ "$nobuild" != "nobuild" ]; then
tar xf "${site}" --exclude=CNAME -C "${tmpdir}"
jekyll build -s "${tmpdir}" -d "${tmpdir}/production"
prod_dir="${tmpdir}/production"
fi

# Rsync:
# -r: recursive
# -c: compute checksum even though the input is from the filesystem
"${gs}" rsync -r -c "${tmpdir}/production" "gs://${bucket}"
"${gs}" rsync -r -c "${prod_dir}" "gs://${bucket}"
"${gs}" web set -m index.html -e 404.html "gs://${bucket}"
"${gs}" -m acl ch -R -u AllUsers:R "gs://${bucket}"
}
6 changes: 6 additions & 0 deletions src/tools/benchmark/webapp/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<p>404 - Page not found</p>
</body>
</html>
10 changes: 10 additions & 0 deletions src/tools/benchmark/webapp/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
package(default_visibility = ["//src/tools/benchmark:__pkg__"])

load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

filegroup(
name = "srcs",
srcs = glob(["**"]),
)

pkg_tar(
name = "site",
files = [
"draw_chart.js",
"line_chart.html",
],
)
File renamed without changes.

0 comments on commit 01aa7d6

Please sign in to comment.