diff --git a/.gitignore b/.gitignore index 80411db..fde1160 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# Os/editor stuff +*.swp +*.orig + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -90,4 +94,3 @@ ENV/ /.travis_ci_gh_pages_deploy_key /.travis_ci_gh_pages_deploy_key.pub -/gh-pages diff --git a/.travis.yml b/.travis.yml index 8559434..f3b1e28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,30 +3,37 @@ # notice and this notice are preserved. This file is offered as-is, # without any warranty. language: python + +env: + global: + - DEPLOY_DOC_TO_DIRECTORY=/ + - DEPLOY_DOC_FROM_DIRECTORY=docs/build/html + - SAGE_SERVER=http://mirrors.xmission.com/sage/ + matrix: include: - - env: CACHE_NAME=8.0 DEPLOY_DOC_FROM_BRANCH=master DEPLOY_DOC_TO_DIRECTORY=/ SAGE_SERVER=http://mirrors.xmission.com/sage/ SAGE_IMAGE=linux/64bit/sage-8.0-Ubuntu_14.04-x86_64.tar.bz2 + - env: CACHE_NAME=8.0 SAGE_IMAGE=linux/64bit/sage-8.0-Ubuntu_14.04-x86_64.tar.bz2 DEPLOY_DOC=true dist: trusty - - env: CACHE_NAME=7.6 SAGE_SERVER=http://mirrors.xmission.com/sage/ SAGE_IMAGE=linux/64bit/sage-7.6-Ubuntu_12.04-x86_64.tar.bz2 + - env: CACHE_NAME=7.6 SAGE_IMAGE=linux/64bit/sage-7.6-Ubuntu_12.04-x86_64.tar.bz2 dist: precise - - env: CACHE_NAME=7.5.1 SAGE_SERVER=http://mirrors.xmission.com/sage/ SAGE_IMAGE=linux/64bit/sage-7.5.1-Ubuntu_12.04-x86_64.tar.bz2 + - env: CACHE_NAME=7.5.1 SAGE_IMAGE=linux/64bit/sage-7.5.1-Ubuntu_12.04-x86_64.tar.bz2 dist: precise -install: -- ./.travis-install.sh -script: -- ./.travis-test.sh +# the following environment is usefull if you just want to test travis +# without needing to wait very long for sage to install +# it causes the travis_scripts install.sh and test.sh to not execute. + - env: CACHE_NAME=NO_SAGE TEST_TRAVIS=true + cache: directories: - $HOME/SageMath - $HOME/.cache/matplotlib timeout: 1000 + before_cache: - rm -Rf $HOME/SageMath/logs $HOME/SageMath/.BUILDSTART -after_success: -- ./.travis-deploy-doc.sh -before_script: -- openssl aes-256-cbc -K $encrypted_f96cc3b3888c_key -iv $encrypted_f96cc3b3888c_iv - -in .travis_ci_gh_pages_deploy_key.enc -out .travis_ci_gh_pages_deploy_key -d || true + +install: +- travis_scripts/install-sage.sh addons: apt: @@ -35,3 +42,29 @@ addons: # Otherwise, numpy cannot be imported. # Also, optional package installs in .travis-install.sh will trigger build of sage gcc. - gfortran + + +#here is where actually all the testing happens +script: +- travis_scripts/test.sh +#add lines of the following type if you want to run aditional tests +#- some_command some_arguments + + +before_deploy: +- travis_scripts/get-key.sh +- openssl aes-256-cbc -K $encrypted_f96cc3b3888c_key -iv $encrypted_f96cc3b3888c_iv -in .travis_ci_gh_pages_deploy_key.enc -out .travis_ci_gh_pages_deploy_key -d + +deploy: +#If travis start supporting ssh/deploy keys this could be changed to be handled by their +#pages provider documented at https://docs.travis-ci.com/user/deployment/pages/ . +#However currently that needs an authentication token giving write acces to all your +#repositories, which is really insecure and a bad idea! + provider: script + skip_cleanup: true + on: + branch: master + condition: $DEPLOY_DOC = true + script: travis_scripts/deploy-doc.sh + + diff --git a/.travis_ci_gh_pages_deploy_key.enc b/.travis_ci_gh_pages_deploy_key.enc deleted file mode 100644 index 33a7eaa..0000000 Binary files a/.travis_ci_gh_pages_deploy_key.enc and /dev/null differ diff --git a/README.rst b/README.rst index 038129f..e44f0ab 100644 --- a/README.rst +++ b/README.rst @@ -128,67 +128,81 @@ Automatically deploying documentation to GitHub pages using Travis CI of your GitHub-hosted project. * If you don't already have GitHub pages for your project: Create and - checkout a branch ``gh-pages`` in your repository and put an empty - file ``.nojekyll`` in it (see - https://help.github.com/articles/files-that-start-with-an-underscore-are-missing/). - Then commit it and push it to GitHub:: - - $ git clone --single-branch --depth 1 https://github.com/USER/PROJECT.git gh-pages - $ cd gh-pages - $ git checkout --orphan gh-pages - $ git rm -rf . - $ touch .nojekyll - $ git add .nojekyll - $ git commit -m "Initial commit" - $ git push -u origin gh-pages - $ cd .. + checkout a branch empty branch ``gh-pages`` in your repository. + Then commit it and push it to GitHub. This is done in a new clone + because we will delete it after we pushed everything to github. + + git clone --single-branch --depth 1 https://github.com/USER/PROJECT.git tmp_dir + cd tmp_dir + git checkout --orphan gh-pages + git rm -rf . + git commit -m --allow-empty "Initial commit" + git push -u origin gh-pages + cd .. + * (Back in your working copy:) Generate a new ssh key pair with an empty passphrase:: - $ ssh-keygen -t dsa -f .travis_ci_gh_pages_deploy_key + ssh-keygen -t dsa -f .travis_ci_gh_pages_deploy_key * Add the public ssh key (contents of the file ``.travis_ci_gh_pages_deploy_key.pub``) to your GitHub repository - as a deploy key (Settings/Deploy keys/Add deploy key). + as a deploy key on http://github.com (Settings/Deploy keys/Add deploy key). Title: Key for deploying documentation to GitHub pages. Check Allow write access. * Install the Travis CI command-line client from https://github.com/travis-ci/travis.rb:: - $ gem install travis + gem install travis + + One might need to add the ``--user-install`` option to gem if one doesn't have + write acces to the system wide gem repository. If one does this be sure to also + add the place where travis is installed to your path. This should be something + like ``$HOME/.gem/ruby/2.0.0/bin`` + * Log in to Travis CI using your GitHub credentials:: - $ travis login + travis login * Encrypt the private ssh key, add the decryption keys as secure environment variables to Travis CI, and add code to ``.travis.yml`` to decrypt it:: - $ travis encrypt-file .travis_ci_gh_pages_deploy_key --add before_script + travis encrypt-file .travis_ci_gh_pages_deploy_key --add before_deploy + +* inspect the ``.travis.yml`` file. The ``before_deploy`` section should look + something like this:: + + before_deploy: + - travis_scripts/get-key.sh + - openssl aes-256-cbc -K $encrypted_0fe3b59c4233_key -iv $encrypted_0fe3b59c4233_iv -in .travis_ci_gh_pages_deploy_key.enc -out .travis_ci_gh_pages_deploy_key -d + + if there are more then one openssl command, remove all but the last one. -* Add the encrypted private ssh key to the repository:: +* Add the encrypted ssh key to the ``tmp_dir`` repository in a new branch called ``deploy_key``:: - $ git add .travis_ci_gh_pages_deploy_key.enc + cd tmp_dir + git checkout --orphan deploy_key + git add .travis_ci_gh_pages_deploy_key.enc + git commit -m "Added Travis GitHub pages deploy key" + git push origin deploy_key -* Have git ignore the other keys (and the gh-pages directory):: +* we can now savely remove the repository in tmp_dir:: - $ echo >> .gitignore - $ echo "/.travis_ci_gh_pages_deploy_key" >> .gitignore - $ echo "/.travis_ci_gh_pages_deploy_key.pub" >> .gitignore - $ echo "/gh-pages" >> .gitignore - $ git add .gitignore + cd .. + rm -rf tmp_dir * Optionally, edit ``.travis.yml`` to adjust variables ``DEPLOY_DOC_...`` * Commit all changes to GitHub. The Travis CI build should then run automatically and deploy it:: - $ git add .travis.yml - $ git commit -m "Deploy built documentation to GitHub" - $ git push + git add .travis.yml + git commit -m "Deploy built documentation to GitHub" + git push * The deployed documentation will be available at: https://USER.github.io/PROJECT/ diff --git a/.travis-deploy-doc.sh b/travis_scripts/deploy-doc.sh similarity index 63% rename from .travis-deploy-doc.sh rename to travis_scripts/deploy-doc.sh index 44710c7..f01071b 100755 --- a/.travis-deploy-doc.sh +++ b/travis_scripts/deploy-doc.sh @@ -4,24 +4,30 @@ # notice and this notice are preserved. This file is offered as-is, # without any warranty. set -e -if [[ "${TRAVIS_PULL_REQUEST}" == "false" && "${TRAVIS_BRANCH}" == "${DEPLOY_DOC_FROM_BRANCH}" && -r .travis_ci_gh_pages_deploy_key ]]; then +if [[ -r .travis_ci_gh_pages_deploy_key ]]; then if [[ -z "${DEPLOY_DOC_TO_REPOSITORY}" ]]; then DEPLOY_DOC_TO_REPOSITORY="${TRAVIS_REPO_SLUG}" fi chmod 600 .travis_ci_gh_pages_deploy_key eval `ssh-agent -s` ssh-add .travis_ci_gh_pages_deploy_key < /dev/null - rm -Rf gh-pages - git clone --depth 1 git@github.com:${DEPLOY_DOC_TO_REPOSITORY}.git --depth 1 --branch=gh-pages gh-pages - BUILT_DOCS_DIR=`cd docs/build/html && pwd` - cd gh-pages + rm -f .travis_ci_gh_pages_deploy_key + rm -Rf $HOME/gh-pages + git clone --depth 1 git@github.com:${DEPLOY_DOC_TO_REPOSITORY}.git --branch=gh-pages $HOME/gh-pages + BUILT_DOCS_DIR=$TRAVIS_BUILD_DIR/$DEPLOY_DOC_FROM_DIRECTORY + cd $HOME/gh-pages + touch .nojekyll rm -Rf ./${DEPLOY_DOC_TO_DIRECTORY}/* mkdir -p ./${DEPLOY_DOC_TO_DIRECTORY} cp -R $BUILT_DOCS_DIR/* ./${DEPLOY_DOC_TO_DIRECTORY}/ git add --all . - git config user.name "Travis CI" - git config user.email "nobody@example.org" + git config user.name "Travis Deployment Script" + git config user.email "deploy@travis-ci.org" if git commit -m "Automatic upload of documentation built from ${TRAVIS_COMMIT}"; then git push origin gh-pages fi + rm -Rf $HOME/gh-pages + exit fi +echo "Error in docmumentation deployment: .travis_ci_gh_pages_deploy_key not found" +exit 1 diff --git a/travis_scripts/get-key.sh b/travis_scripts/get-key.sh new file mode 100755 index 0000000..f9ed707 --- /dev/null +++ b/travis_scripts/get-key.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +rm -rf $HOME/deploy_key +git clone --depth 1 https://github.com/${TRAVIS_REPO_SLUG}.git --branch=deploy_key $HOME/deploy_key +cp $HOME/deploy_key/.travis_ci_gh_pages_deploy_key.enc . +rm -rf $HOME/deploy_key diff --git a/.travis-install.sh b/travis_scripts/install-sage.sh similarity index 90% rename from .travis-install.sh rename to travis_scripts/install-sage.sh index 6ca551f..bf92001 100755 --- a/.travis-install.sh +++ b/travis_scripts/install-sage.sh @@ -1,8 +1,11 @@ -#! /bin/sh +#!/bin/bash # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright # notice and this notice are preserved. This file is offered as-is, # without any warranty. +if [ "$TEST_TRAVIS" = "true" ] ; then + exit; +fi set -e cd $HOME if [ ! -x SageMath/sage ] ; then diff --git a/.travis-test.sh b/travis_scripts/test.sh similarity index 89% rename from .travis-test.sh rename to travis_scripts/test.sh index 910faf4..7ef5c9c 100755 --- a/.travis-test.sh +++ b/travis_scripts/test.sh @@ -3,6 +3,9 @@ # are permitted in any medium without royalty provided the copyright # notice and this notice are preserved. This file is offered as-is, # without any warranty. +if [ "$TEST_TRAVIS" = "true" ] ; then + exit; +fi set -e $HOME/SageMath/sage -pip install --upgrade --no-index -v . $HOME/SageMath/sage setup.py test