From c26d81d455b8e8cf8d2a5716bfa8c92e15d6c5b8 Mon Sep 17 00:00:00 2001 From: Maarten Derickx Date: Wed, 6 Sep 2017 08:21:13 +0200 Subject: [PATCH 1/5] rewrote github pages deployment scripts --- .gitignore | 4 +- .travis.yml | 61 ++++++++++++++---- .travis_ci_gh_pages_deploy_key.enc | Bin 672 -> 0 bytes .../deploy-doc.sh | 22 +++++-- travis_scripts/get-key.sh | 6 ++ .../install-sage.sh | 5 +- .travis-test.sh => travis_scripts/test.sh | 3 + 7 files changed, 81 insertions(+), 20 deletions(-) delete mode 100644 .travis_ci_gh_pages_deploy_key.enc rename .travis-deploy-doc.sh => travis_scripts/deploy-doc.sh (60%) create mode 100755 travis_scripts/get-key.sh rename .travis-install.sh => travis_scripts/install-sage.sh (92%) rename .travis-test.sh => travis_scripts/test.sh (92%) diff --git a/.gitignore b/.gitignore index 80411db..c49c1f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Os/editor stuff +*.swp + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -90,4 +93,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 c725191..361f3de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,23 +3,62 @@ # 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=7.6 DEPLOY_DOC_FROM_BRANCH=master DEPLOY_DOC_TO_DIRECTORY=/ 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.5.1 SAGE_SERVER=http://mirrors.xmission.com/sage/ SAGE_IMAGE=linux/64bit/sage-7.5.1-Ubuntu_12.04-x86_64.tar.bz2 -install: -- ./.travis-install.sh -script: -- ./.travis-test.sh + - 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_IMAGE=linux/64bit/sage-7.6-Ubuntu_12.04-x86_64.tar.bz2 + dist: precise + - env: CACHE_NAME=7.5.1 SAGE_IMAGE=linux/64bit/sage-7.5.1-Ubuntu_12.04-x86_64.tar.bz2 + dist: precise +# 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: + packages: + # On 8.0 with trusty, Fortran compiler is needed. + # Otherwise, numpy cannot be imported. + # Also, optional package installs in .travis-install.sh will trigger build of sage gcc. + - gfortran + +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_0fe3b59c4233_key -iv $encrypted_0fe3b59c4233_iv -in .travis_ci_gh_pages_deploy_key.enc -out .travis_ci_gh_pages_deploy_key -d + +deploy: + provider: script + skip_cleanup: true + on: + branch: travis_check + 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 33a7eaa89fad3317a6c4c1f8d4f0d3cfdb0f822d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 672 zcmV;R0$=@{k~}Y) zj~faaE*&%oZ2YU8(Nq@;3~C6E4o~v zhA-@#jz+N!qp_RzC7eUWjs2gyY(2`kyDDb4=i^ZlT3J=Qk|R}cCwO3CyQQ>u0p%g4 z2DLH~ab4V7wyL6NRShM?Fc0PqN2FB>RsEKSzV!{*OB${-mzxQ}b#vq@w9;O0&VJ7o zs`exFl8L;%i^B};)CqM()Gb)r0pTvY4&zFpdpxf{FO3!OJVPDvzUDmioald<_6|z- z0!|bVKZ*q$nrft4F6;)2VFOjf0||((;a#i zG4hS~VQwb!o#^7(?9_LjKU#kPR@NMRmh;*z?>p*c&nOdAHX@L`A&6ix>VG=!;x;>O zLQunHgBfAc_$Aj?`z()ZJxgSG=6b;w#*eAMD-^YNPFcP(n~Semls?hV0|a849&RSa z^*0CT)hVpDZof1Cua$p^ahQ`2btW`|v|h4UC2s8GBwz@cRdsZ&$yea?f06+H37+V- zMl>(XLJXn|n5rCH1j$s8ZCnRf<4wd@j#?qCEwgP5JGkukp8%ggjZSOdG!(Sysp4j5 zgYM2CwhQDM$bl3bk5pI46+i?KMXowy7b~vVl@0V`6ZBRFm-Wq;ZcZcni6<0(WhTR& GmZWvQ6hF`a diff --git a/.travis-deploy-doc.sh b/travis_scripts/deploy-doc.sh similarity index 60% rename from .travis-deploy-doc.sh rename to travis_scripts/deploy-doc.sh index 44710c7..7c3a4b8 100755 --- a/.travis-deploy-doc.sh +++ b/travis_scripts/deploy-doc.sh @@ -4,24 +4,32 @@ # 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 + echo "DEPLOY_DOC_FROM_DIRECTORY" + echo $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 92% rename from .travis-install.sh rename to travis_scripts/install-sage.sh index eef217c..3433a73 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 ; 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 92% rename from .travis-test.sh rename to travis_scripts/test.sh index 910faf4..66822ed 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 ; then + exit; +fi set -e $HOME/SageMath/sage -pip install --upgrade --no-index -v . $HOME/SageMath/sage setup.py test From c6444f1a0b3dab7c6d27cad8a5504972866870e2 Mon Sep 17 00:00:00 2001 From: Maarten Derickx Date: Wed, 6 Sep 2017 08:46:02 +0200 Subject: [PATCH 2/5] Fixed improper bash boolean true checking --- travis_scripts/install-sage.sh | 2 +- travis_scripts/test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/travis_scripts/install-sage.sh b/travis_scripts/install-sage.sh index 3433a73..debd98f 100755 --- a/travis_scripts/install-sage.sh +++ b/travis_scripts/install-sage.sh @@ -3,7 +3,7 @@ # 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 ; then +if [ "$TEST_TRAVIS" = "true" ] ; then exit; fi set -e diff --git a/travis_scripts/test.sh b/travis_scripts/test.sh index 66822ed..7ef5c9c 100755 --- a/travis_scripts/test.sh +++ b/travis_scripts/test.sh @@ -3,7 +3,7 @@ # 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 ; then +if [ "$TEST_TRAVIS" = "true" ] ; then exit; fi set -e From a5e2cffaf816118192a3ffce5f70671dc36321c6 Mon Sep 17 00:00:00 2001 From: Maarten Derickx Date: Wed, 6 Sep 2017 14:57:22 +0200 Subject: [PATCH 3/5] Adapted the documentation to the new github pages deployment --- .gitignore | 1 + .travis.yml | 8 +++- README.rst | 74 +++++++++++++++++++++--------------- travis_scripts/deploy-doc.sh | 2 - 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index c49c1f9..fde1160 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Os/editor stuff *.swp +*.orig # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/.travis.yml b/.travis.yml index 361f3de..39ebf25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,8 @@ addons: # 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 @@ -54,10 +56,14 @@ before_deploy: - 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 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: travis_check + branch: master condition: $DEPLOY_DOC = true script: travis_scripts/deploy-doc.sh diff --git a/README.rst b/README.rst index 038129f..34877e9 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 --alow-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_scripts/deploy-doc.sh b/travis_scripts/deploy-doc.sh index 7c3a4b8..f01071b 100755 --- a/travis_scripts/deploy-doc.sh +++ b/travis_scripts/deploy-doc.sh @@ -15,8 +15,6 @@ if [[ -r .travis_ci_gh_pages_deploy_key ]]; then 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 - echo "DEPLOY_DOC_FROM_DIRECTORY" - echo $DEPLOY_DOC_FROM_DIRECTORY cd $HOME/gh-pages touch .nojekyll rm -Rf ./${DEPLOY_DOC_TO_DIRECTORY}/* From bd5c925bc21fa67e51fd414032ae5ba30949c4b8 Mon Sep 17 00:00:00 2001 From: Maarten Derickx Date: Wed, 6 Sep 2017 15:45:16 +0200 Subject: [PATCH 4/5] Still use the sagemath key decription --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39ebf25..f3b1e28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,7 @@ script: 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 +- 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 From 917bfc7d97e67a82200f52b8db2995f71abcf07a Mon Sep 17 00:00:00 2001 From: Maarten Derickx Date: Wed, 6 Sep 2017 16:10:26 +0200 Subject: [PATCH 5/5] fix whitespace --- README.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index 34877e9..e44f0ab 100644 --- a/README.rst +++ b/README.rst @@ -128,18 +128,18 @@ 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 empty branch ``gh-pages`` in your repository. + 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 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 --alow-empty "Initial commit" + 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:: @@ -155,13 +155,13 @@ Automatically deploying documentation to GitHub pages using Travis CI * 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 + 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:: @@ -179,7 +179,7 @@ Automatically deploying documentation to GitHub pages using Travis CI 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 ssh key to the ``tmp_dir`` repository in a new branch called ``deploy_key``::