Skip to content

Commit

Permalink
[MRG] Update config for CircleCI v2 (pydicom#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaramallion authored Jul 16, 2018
1 parent c96b9a2 commit 7b1e852
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 116 deletions.
22 changes: 22 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
jobs:
build:
docker:
- image: circleci/python:3.6
steps:
- checkout
- run:
name: Build documentation
command: ./build_docs/circle/build_doc.sh
timeout: "3600" # seconds
- store_artifacts:
path: docs/_build/html
- add_ssh_keys:
fingerprints:
- "a1:d2:31:ea:d3:72:b8:2e:c5:20:52:7f:94:7b:78:dc"
- deploy:
name: Deploy documentation
environment:
USERNAME: scaramallion
EMAIL: [email protected]
command: ./build_docs/circle/push_doc.sh
5 changes: 3 additions & 2 deletions build_docs/circle/build_doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes \
#conda install --yes --quiet pip setuptools numpy matplotlib sphinx \
# pillow sphinx_rtd_theme numpydoc
#conda install --yes --quiet -c conda-forge gdcm
pip install numpy matplotlib sphinx pillow sphinx_rtd_theme numpydoc
pip install sphinx-gallery sphinxcontrib-napoleon
python3 -m venv venv
. venv/bin/activate
pip install numpy matplotlib sphinx pillow sphinx_rtd_theme numpydoc sphinx-gallery sphinxcontrib-napoleon

# Add pydicom
pip install pydicom
Expand Down
31 changes: 0 additions & 31 deletions build_docs/circle/checkout_merge_commit.sh

This file was deleted.

105 changes: 76 additions & 29 deletions build_docs/circle/push_doc.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,82 @@
#!/bin/bash
# This script is meant to be called in the "deploy" step defined in
# circle.yml. See https://circleci.com/docs/ for more details.
# The behavior of the script is controlled by environment variable defined
# in the circle.yml in the top level folder of the project.

# This script is meant to be called in the "deploy" step defined
# in .circleci/config.yml. See https://circleci.com/docs/2.0 for more details.

# We have three possibily workflows:
# If the git branch is 'master' then we want to commit and merge the dev/
# docs on gh-pages
# If the git branch is [0-9].[0.9].X (i.e. 0.9.X, 1.0.X, 1.2.X, 41.21.X) then
# we want to commit and merge the major.minor/ docs on gh-pages
# If the git branch is anything else then we just want to test that committing
# the changes works so that any issues can be debugged

function doc_clone_commit {
# Clone the pynetdicom/$DOC_BRANCH branch, update the $DIR directory
# by deleting existing content and copying the most recent version from the
# $CIRCLE_BRANCH, then commit the changes with message $MSG
MSG="Updating the docs in $DIR/ for branch: $CIRCLE_BRANCH, commit $CIRCLE_SHA1"

# CircleCI version 2.0 builds the project in $HOME/project, i.e.:
# /home/circleci/project/pynetdicom3/dataset.py
# note the base directory for the repo is 'project' not 'pynetdicom3'

# Clone the $DOC_BRANCH branch
cd $HOME
git clone -b $DOC_BRANCH --single-branch $CIRCLE_REPOSITORY_URL
cd $CIRCLE_PROJECT_REPONAME
git reset --hard origin/$DOC_BRANCH
# Update the doc directory that will be committed
git rm -rf $DIR/ && rm -rf $DIR/
cp -R $HOME/project/docs/_build/html $DIR
# Set the git details of the committer
git config --global user.email $EMAIL
git config --global user.name $USERNAME
git config --global push.default matching
# Add back to git the doc directory that will be committed
git add -f $DIR/
git commit -m "$MSG" $DIR
}

# Test that the vars have been set
if [ -z ${CIRCLE_BRANCH+x} ]; then echo "CIRCLE_BRANCH is unset"; fi
if [ -z ${CIRCLE_SHA1+x} ]; then echo "CIRCLE_SHA1 is unset"; fi
if [ -z ${CIRCLE_REPOSITORY_URL+x} ]; then echo "CIRCLE_REPOSITORY_URL is unset"; fi
if [ -z ${CIRCLE_PROJECT_REPONAME+x} ]; then echo "CIRCLE_PROJECT_REPONAME is unset"; fi
if [ -z ${HOME+x} ]; then echo "HOME is unset"; fi
if [ -z ${EMAIL+x} ]; then echo "EMAIL is unset"; fi
if [ -z ${USERNAME+x} ]; then echo "USERNAME is unset"; fi

DOC_BRANCH=gh-pages

echo $GIT_AUTHOR_EMAIL
echo $GIT_AUTHOR_NAME

# Determine which of the three workflows to take
if [ "$CIRCLE_BRANCH" = "master" ]
then
dir=dev
# build of current master
echo "Performing commit and push to $CIRCLE_PROJECT_REPONAME/$DOC_BRANCH for $CIRCLE_BRANCH"
# Changes are made to dev/ directory
DIR=dev
doc_clone_commit
git push origin $DOC_BRANCH
echo "Push complete"
elif [[ "$CIRCLE_BRANCH" =~ ^[0-9]+\.[0-9]+\.X$ ]]
then
# build of release, matches branch name against 0.1.X, 91.235.X, etc
echo "Performing commit and push to $CIRCLE_PROJECT_REPONAME/$DOC_BRANCH for $CIRCLE_BRANCH"
# Strip off .X from branch name, so changes will go to 0.1/, 91.235/, etc
DIR="${CIRCLE_BRANCH::-2}"
doc_clone_commit
git push origin $DOC_BRANCH
echo "Push complete"
else
# Strip off .X
dir="${CIRCLE_BRANCH::-2}"
fi

MSG="Pushing the docs to $dir/ for branch: $CIRCLE_BRANCH, commit $CIRCLE_SHA1"

cd $HOME
if [ ! -d $DOC_REPO ];
then git clone --depth 1 --no-checkout "[email protected]:"$ORGANIZATION"/"$DOC_REPO".git";
# build pull release, should be regex ^pull\/[0-9]+$ but lets run against
# everything that doesn't match the other two workflows
echo "Testing commit only to $CIRCLE_PROJECT_REPONAME/$DOC_BRANCH for $CIRCLE_BRANCH"
# Changes are made to dev/ directory but not merged
DIR=dev
doc_clone_commit
echo "Test complete, changes NOT pushed"
fi
cd $DOC_REPO
git config core.sparseCheckout true
echo $dir > .git/info/sparse-checkout
git checkout gh-pages
git reset --hard origin/gh-pages
git rm -rf $dir/ && rm -rf $dir/
cp -R $HOME/pynetdicom3/docs/_build/html $dir
git config --global user.email $EMAIL
git config --global user.name $USERNAME
git config --global push.default matching
git add -f $dir/
git commit -m "$MSG" $dir
git push origin gh-pages

echo $MSG
54 changes: 0 additions & 54 deletions circle.yml

This file was deleted.

0 comments on commit 7b1e852

Please sign in to comment.