diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..b118c7d32 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,62 @@ +# Python CircleCI 2.0 configuration file +# Check https://circleci.com/docs/2.0/language-python/ for more details +version: 2 + +apt-run: &apt-install + name: Install apt packages + command: | + sudo apt-get update + sudo apt-get install build-essential pandoc + +pip-run: &pip-install + name: Install Python dependencies + command: | + python3 -m venv venv + . venv/bin/activate + pip install -q -r pip-requirements.txt + pip install astropy_helpers sphinx + +jobs: + + build: + docker: + - image: circleci/python:3.6 + + steps: + - checkout + - add_ssh_keys: # add GitHub SSH keys + fingerprints: + - 32:53:df:4a:53:71:25:8b:73:42:71:c8:57:8a:3f:f7 + - run: *apt-install # run the apt install defined above + - run: *pip-install # run the pip install defined above + + # - restore_cache: # Need cache for all tutorial data! + # keys: sample-data-v1 + + - run: + name: Build documentation + command: | + . venv/bin/activate + make html + + - store_artifacts: + path: build/html + + - run: + name: Built documentation is available at + command: | + DOCS_URL="${CIRCLE_BUILD_URL}/artifacts/${CIRCLE_NODE_INDEX}/${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}/build/html/index.html"; echo $DOCS_URL + + - run: + name: Push to RTD branch + command: | + bash .circleci/rtd-push.sh + + # - save_cache: # Specify what paths to cache + # key: sample-data-v1 + # paths: + # - ~/sunpy/data/sample_data + +notify: + webhooks: + - url: https://giles.cadair.com/circleci diff --git a/.circleci/rtd-push.sh b/.circleci/rtd-push.sh new file mode 100644 index 000000000..087360171 --- /dev/null +++ b/.circleci/rtd-push.sh @@ -0,0 +1,23 @@ +#!/bin/bash -eux + +# if [ -z "${GIT_USER_NAME}" ]; then +# echo "Please set an env var GIT_USER_NAME" +# exit 1 +# fi +# +# if [ -z "${GIT_USER_EMAIL}" ]; then +# echo "Please set an env var GIT_USER_EMAIL" +# exit 1 +# fi + +if [[ -z $CIRCLE_PULL_REQUEST ]] ; then + git checkout --orphan rst + git add -f tutorials/rst-tutorials/* + git -c user.name='circle' -c user.email='circle' commit -m "now with RST" + git remote add origin git@github.com:astropy/astropy-tutorials.git + git push -q -f origin rst + echo "Not a pull request: pushing RST files to rst branch." +else + echo $CIRCLE_PULL_REQUEST + echo "This is a pull request: not pushing RST files." +fi diff --git a/pip-requirements.txt b/pip-requirements.txt index 4f0059537..d9dd00b30 100644 --- a/pip-requirements.txt +++ b/pip-requirements.txt @@ -4,4 +4,9 @@ astroquery==0.3.7 matplotlib==2.0.2 numpy==1.13.1 jupyter==1.0 -scipy=0.19 +scipy==0.19 +notebook==5.0 +aplpy +spectral-cube +reproject +git+https://github.com/jupyter/nbconvert diff --git a/scripts/convert.py b/scripts/convert.py index fb25153ca..e71062e84 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -41,6 +41,10 @@ def __init__(self, nb_path, output_path=None, template_file=None, logger.info('Processing notebook {0} (in {1})'.format(fn, self.path_only)) + # the RST file + self._rst_path = path.join(self.output_path, + '{0}.rst'.format(self.nb_name)) + if kernel_name is None: self.kernel_name = ExecutePreprocessor.kernel_name.default_value else: @@ -107,6 +111,12 @@ def convert(self, remove_executed=False): raise IOError("Executed notebook file doesn't exist! Expected: {0}" .format(self._executed_nb_path)) + if path.exists(self._rst_path) and not self.overwrite: + logger.debug("RST version of notebook already exists at {0}. Use " + "overwrite=True or --overwrite (at cmd line) to re-run" + .format(self._rst_path)) + return self._rst_path + # Initialize the resources dict - see: # https://github.com/jupyter/nbconvert/blob/master/nbconvert/nbconvertapp.py#L327 resources = {}