-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deploy documentation from the Travis-CI integration
- Loading branch information
1 parent
6cbac80
commit d3c2d0e
Showing
4 changed files
with
203 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
#!/usr/bin/env bash | ||
#------------------------------------------------------------------------------- | ||
# (C) British Crown Copyright 2012-8 Met Office. | ||
# | ||
# This file is part of Rose, a framework for meteorological suites. | ||
# | ||
# Rose is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Rose is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Rose. If not, see <http://www.gnu.org/licenses/>. | ||
#------------------------------------------------------------------------------- | ||
set -eu | ||
set -o xtrace # for ease of debugging travis builds | ||
shopt -s extglob | ||
|
||
|
||
export PATH="${PWD}/bin:${HOME}/fcm-master/bin:${HOME}/cylc-master/bin:$PATH" | ||
|
||
TMP_DOCS_DIR="${TMPDIR:-/var/tmp}/temp-docs-dir" | ||
DOCUMENTATION_FILES=!(doc|404*|CHANGES.md|_config.yml) | ||
GITHUB_REPO="https://github.com/${TRAVIS_REPO_SLUG}" | ||
|
||
|
||
install() { | ||
args=("$@") | ||
|
||
# package managers | ||
sudo apt-get -q update | ||
sudo apt-get install -qy python-pip | ||
|
||
# Cylc | ||
if grep 'cylc' <<< "${args[@]}"; then | ||
# install Cylc | ||
wget 'https://github.com/cylc/cylc/archive/master.tar.gz' -O \ | ||
'/tmp/cylc-master.tar.gz' | ||
tar -xvf '/tmp/cylc-master.tar.gz' -C "${HOME}" | ||
make -C "${HOME}/cylc-master" 'version' | ||
|
||
# install Cylc dependencies | ||
sudo apt-get -qy install at python-jinja2 heirloom-mailx | ||
pip install -q pyopenssl cherrypy requests Jinja2 EmPy | ||
|
||
# configure SSH | ||
ssh-keygen -t 'rsa' -f "${HOME}/.ssh/id_rsa" -N '' -q | ||
cat "${HOME}/.ssh/id_rsa.pub" >>"${HOME}/.ssh/authorized_keys" | ||
ssh-keyscan -t 'rsa' 'localhost' >>"${HOME}/.ssh/known_hosts" | ||
fi | ||
|
||
# FCM | ||
if grep 'fcm' <<< "${args[@]}"; then | ||
# install Subversion | ||
sudo sh -c 'echo "deb http://opensource.wandisco.com/ubuntu \ | ||
`lsb_release -cs` \ | ||
svn19" >> /etc/apt/sources.list.d/subversion19.list' | ||
sudo wget -q http://opensource.wandisco.com/wandisco-debian.gpg -O- | \ | ||
sudo apt-key add - | ||
sudo apt-get -qy install subversion | ||
|
||
# install FCM | ||
wget 'https://github.com/metomi/fcm/archive/master.tar.gz' -O \ | ||
'/tmp/fcm-master.tar.gz' | ||
tar -xvf '/tmp/fcm-master.tar.gz' -C "${HOME}" | ||
|
||
# install FCM dependencies | ||
sudo apt-get -qy install build-essential gfortran libxml-parser-perl \ | ||
libconfig-inifiles-perl libdbi-perl libdbd-sqlite3-perl | ||
fi | ||
|
||
# Rose - full installation + testing dependencies | ||
if grep 'rose' <<< "${args[@]}"; then | ||
sudo apt-get -qy install python-jinja2 python-sqlalchemy | ||
pip install -q cherrypy requests sqlalchemy pycodestyle Jinja2 EmPy | ||
fi | ||
|
||
# Graphviz | ||
if grep -E '(rose|cylc|docs)' <<< "${args[@]}"; then | ||
sudo apt-get install -qy python-dev graphviz libgraphviz-dev | ||
pip install -q pygraphviz \ | ||
--install-option="--include-path=/usr/include/graphviz" \ | ||
--install-option="--library-path=/usr/lib/graphviz/" | ||
fi | ||
|
||
# LaTeX | ||
if grep 'docs' <<< "${args[@]}"; then | ||
# NOTE: Rose installs its own Python dependencies in a virtualenv via | ||
# the `rose make-docs` command. | ||
|
||
# non-Python dependencies for building PDF documentation | ||
sudo apt-get -qy install latexmk texlive texlive-generic-extra \ | ||
texlive-latex-extra texlive-fonts-recommended | ||
fi | ||
} | ||
|
||
test-battery () { | ||
# run the standard rose test battery | ||
rose test-battery --state=save -j 5 || ( | ||
echo -e "\n\nRerunning Failed Tests...\n\n" | ||
rose test-battery -v --state=save,failed -j 5 | ||
) | ||
} | ||
|
||
test-docs () { | ||
# run rose documentation tests | ||
rose make-docs --venv --dev --strict clean linkcheck doctest \ | ||
--default-version none | ||
git clean -xf . | ||
} | ||
|
||
prepare-docs-branch () { | ||
# prepare to build documentation on top of the upstream/gh-pages branch | ||
|
||
# symlink doc/ to a temporary directory to build the docs in | ||
mkdir "$TMP_DOCS_DIR" | ||
rm -rf 'doc' || true | ||
ln -s "$TMP_DOCS_DIR" 'doc' | ||
|
||
# archive the upstream/gh-pages branch to the temporary directory | ||
git remote add upstream "${GITHUB_REPO}.git" | ||
git fetch upstream gh-pages | ||
git archive 'upstream/gh-pages' | (cd "${TMP_DOCS_DIR}"; tar -xf '-') | ||
} | ||
|
||
build-docs () { | ||
# build the rose documentation in the standard output formats | ||
|
||
# if we are not building the most recent tag then leave the default | ||
# docs version (symlinked from the web root) unchanged | ||
LATEST_TAG="$(git ls-remote --tags --refs 'http://github.com/metomi/rose' \ | ||
| sed 's/.*refs\/tags\/\(.*\)/\1/' | sort | tail -n 1)" | ||
if [[ "${LATEST_TAG}" != "${TRAVIS_TAG}" ]]; then | ||
DEFAULT_VERSION="--default-version none" | ||
fi | ||
|
||
# build the documentation | ||
if ! rose make-docs --venv --dev --strict clean html slides pdf \ | ||
${DEFAULT_VERSION:-} >out 2>&1; then | ||
# output is a bit long, only output it if the docs fail to build | ||
cat out >2 | ||
exit 1 | ||
fi | ||
|
||
# remove left-overs including any doctrees created by Sphinx | ||
rm -rf 'doc/'*'/doctrees' | ||
git clean -xf $DOCUMENTATION_FILES | ||
} | ||
|
||
deploy-docs () { | ||
# produce a gh-pages branch ready for docs deployment | ||
git checkout -B 'gh-pages' 'upstream/gh-pages' | ||
rsync -aqv "${TMP_DOCS_DIR}/" . | ||
git add -f ./* | ||
git commit -q -m "${TRAVIS_TAG}" | ||
|
||
# push gh-pages branch to GitHub where it will be auto-deployed to ghpages | ||
set +o xtrace # prevent leakage of the GH_TOKEN env var | ||
git push "https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" \ | ||
'gh-pages' 2>&1 | sed "s/$GH_TOKEN/\$GH_TOKEN/g" | ||
} | ||
|
||
|
||
"$@" |