Skip to content

Try circleci #228

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

Merged
merged 23 commits into from
May 9, 2018
Merged
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
62 changes: 62 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions .circleci/rtd-push.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion pip-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions scripts/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 = {}
Expand Down