Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis check #25

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Os/editor stuff
*.swp
*.orig

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -90,4 +94,3 @@ ENV/

/.travis_ci_gh_pages_deploy_key
/.travis_ci_gh_pages_deploy_key.pub
/gh-pages
57 changes: 45 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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


Binary file removed .travis_ci_gh_pages_deploy_key.enc
Binary file not shown.
74 changes: 44 additions & 30 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
20 changes: 13 additions & 7 deletions .travis-deploy-doc.sh → travis_scripts/deploy-doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]:${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 [email protected]:${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
6 changes: 6 additions & 0 deletions travis_scripts/get-key.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion .travis-install.sh → travis_scripts/install-sage.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions .travis-test.sh → travis_scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down