You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2017/08/04 19:01:58 UTC

[2/3] mesos git commit: Added scripts to automate website publishing.

Added scripts to automate website publishing.

These scripts are expected to be run by ASF CI on any commit to
the mesos repo. The directory layout is similar to tidybot CI job.

Review: https://reviews.apache.org/r/60439


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/23541eff
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/23541eff
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/23541eff

Branch: refs/heads/master
Commit: 23541effba3d24bf5b0eeb457601fe6148002134
Parents: c1fdaea
Author: Vinod Kone <vi...@gmail.com>
Authored: Thu Jun 22 10:43:33 2017 +0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Aug 4 12:01:35 2017 -0700

----------------------------------------------------------------------
 support/jenkins/websitebot.sh       | 51 ++++++++++++++++++++++++++++++++
 support/mesos-website.sh            | 48 ++++++++++++++++++++++++++++++
 support/mesos-website/Dockerfile    | 26 ++++++++++++++++
 support/mesos-website/build.sh      | 44 +++++++++++++++++++++++++++
 support/mesos-website/entrypoint.sh | 33 +++++++++++++++++++++
 5 files changed, 202 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/23541eff/support/jenkins/websitebot.sh
----------------------------------------------------------------------
diff --git a/support/jenkins/websitebot.sh b/support/jenkins/websitebot.sh
new file mode 100755
index 0000000..dccbbc3
--- /dev/null
+++ b/support/jenkins/websitebot.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+# This script is executed by ASF CI to automatically publish the website
+# whenever there is a new commit in the mesos repo.
+set -e
+set -o pipefail
+
+: "${WORKSPACE:?"Environment variable 'WORKSPACE' must be set"}"
+
+export MESOS_DIR="$WORKSPACE/mesos"
+export MESOS_SITE_DIR="$WORKSPACE/mesos-site"
+
+pushd "$MESOS_DIR"
+
+if [ "$(git status --porcelain | wc -l)" -ne 0 ]; then
+  echo "This script is not intended to run on a live checkout, but the source
+        tree contains untracked files or uncommitted changes."
+
+  exit 1
+fi
+
+MESOS_HEAD_SHA=$(git rev-parse --verify --short HEAD)
+
+./support/mesos-website.sh
+
+popd # $MESOS_DIR
+
+# Commit the updated changes to the site repo for website update.
+pushd "$MESOS_SITE_DIR"
+
+git add .
+git commit -m "Updated the website built from mesos SHA: $MESOS_HEAD_SHA."
+git push origin HEAD:refs/heads/asf-site
+
+popd # $MESOS_SITE_DIR

http://git-wip-us.apache.org/repos/asf/mesos/blob/23541eff/support/mesos-website.sh
----------------------------------------------------------------------
diff --git a/support/mesos-website.sh b/support/mesos-website.sh
new file mode 100755
index 0000000..ce416df
--- /dev/null
+++ b/support/mesos-website.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+# This is a wrapper for building Mesos website locally.
+set -e
+set -o pipefail
+
+MESOS_DIR=$(git rev-parse --show-toplevel)
+
+: "${MESOS_SITE_DIR:?"Environment variable 'MESOS_SITE_DIR' must be set"}"
+
+pushd "$MESOS_DIR"
+
+TAG=mesos/website-`date +%s`-$RANDOM
+
+docker build -t $TAG support/mesos-website
+
+trap 'docker rmi $TAG' EXIT
+
+# NOTE: We set `LOCAL_USER_ID` environment variable to enable running the
+# container process with the same UID as the user running this script. This
+# ensures that any writes to the mounted volumes will have the same permissions
+# as the user running the script, making it easy to do cleanups; otherwise
+# any writes will have permissions of UID 0 by default on Linux.
+
+docker run \
+  --rm \
+  -e LOCAL_USER_ID="$(id -u "$USER")" \
+  -v "$MESOS_DIR":/mesos:Z \
+  -v "$MESOS_SITE_DIR/content":/mesos/site/publish:Z \
+  $TAG
+
+popd # $MESOS_DIR

http://git-wip-us.apache.org/repos/asf/mesos/blob/23541eff/support/mesos-website/Dockerfile
----------------------------------------------------------------------
diff --git a/support/mesos-website/Dockerfile b/support/mesos-website/Dockerfile
new file mode 100644
index 0000000..4156eb4
--- /dev/null
+++ b/support/mesos-website/Dockerfile
@@ -0,0 +1,26 @@
+FROM centos:7
+MAINTAINER "dev@mesos.apache.org"
+
+LABEL Description="This image is used for generating Mesos web site."
+
+# Install Mesos build dependencies.
+RUN yum install -y which
+RUN yum groupinstall -y 'Development Tools'
+RUN yum install -y epel-release
+RUN yum install -y clang git maven cmake
+RUN yum install -y java-1.8.0-openjdk-devel python-devel zlib-devel libcurl-devel openssl-devel cyrus-sasl-devel cyrus-sasl-md5 apr-devel subversion-devel apr-utils-devel libevent-devel libev-devel
+
+# Install website dependencies.
+RUN yum install -y ruby ruby-devel doxygen
+RUN gem install bundler
+
+
+# Setup environment to build Mesos and website.
+ENV CC gcc
+ENV CXX g++
+ENV LANG en_US.UTF-8
+ENV LC_ALL en_US.UTF-8
+
+
+WORKDIR /mesos
+CMD bash support/mesos-website/entrypoint.sh

http://git-wip-us.apache.org/repos/asf/mesos/blob/23541eff/support/mesos-website/build.sh
----------------------------------------------------------------------
diff --git a/support/mesos-website/build.sh b/support/mesos-website/build.sh
new file mode 100755
index 0000000..afbec48
--- /dev/null
+++ b/support/mesos-website/build.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+# This is a script for building Mesos website.
+set -e
+set -o pipefail
+
+function exit_hook {
+  # Remove generated documents when exit.
+  cd /mesos/site && bundle exec rake clean_docs
+}
+
+trap exit_hook EXIT
+
+# Build mesos to get the latest master and agent binaries.
+./bootstrap
+mkdir -p build
+pushd build
+../configure --disable-python
+make -j6
+popd # build
+
+# Generate the endpoint docs from the latest mesos and agent binaries.
+./support/generate-endpoint-help.py
+
+# Build the website.
+pushd site
+bundle exec rake
+popd # site

http://git-wip-us.apache.org/repos/asf/mesos/blob/23541eff/support/mesos-website/entrypoint.sh
----------------------------------------------------------------------
diff --git a/support/mesos-website/entrypoint.sh b/support/mesos-website/entrypoint.sh
new file mode 100755
index 0000000..72fd723
--- /dev/null
+++ b/support/mesos-website/entrypoint.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+# This is a wrapper script for building Mesos website as a non-root user.
+set -e
+set -o pipefail
+
+# This needs to be run under `root` user for `bundle exec rake` to
+# work properly. See MESOS-7859.
+pushd site
+bundle install
+popd # site
+
+# Create a local user account.
+useradd -u $LOCAL_USER_ID -s /bin/bash -m tempuser
+
+# Build mesos and the website as the new user.
+su -c support/mesos-website/build.sh tempuser