Skip to content

Commit

Permalink
🚀 deploy toil_example on every new commit (#10)
Browse files Browse the repository at this point in the history
* 🚀 add logic to deploy toil example
* 🐛 fix git command
* 📝 add credits to generated README
* 🔧 skip example deployment if GH_TOKEN is unset
* 🔧 make sure toil_example starts from scratch
* 🔧 symlink .gitmessage
* 🔧 no need for -f with cookiecutter
* 🐛 force branch and push in example deployment
  • Loading branch information
jsmedmar authored and juanesarango committed Feb 19, 2018
1 parent fddd774 commit a25a37a
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 70 deletions.
25 changes: 0 additions & 25 deletions .gitmessage

This file was deleted.

1 change: 1 addition & 0 deletions .gitmessage
18 changes: 13 additions & 5 deletions .travis.yml
Expand Up @@ -2,28 +2,36 @@ language: python

cache:
pip: true
directories: $TRAVIS_BUILD_DIR/.tox
directories: "$TRAVIS_BUILD_DIR/.tox"

install:
- cd $TRAVIS_BUILD_DIR && pip install -U -r requirements.txt
- pip install -U tox-travis

matrix:
include:
- python: 2.7
- python: 3.6
env: SKIP_TOIL_TEST=true
- python: 2.7
env: DEPLOY_TOIL_EXAMPLE=true
- python: 3.6
env: SKIP_TOIL_TEST=true

script:
- pytest -s tests

after_success:
- bash $TRAVIS_BUILD_DIR/.travis/deploy_toil_example.sh

deploy:
provider: pypi
distributions: sdist bdist_wheel
user: leukgen
password:
secure: fnnV7uAyom7OIqsL3kDKHGi3ONO/Pxp4RRtn8ypkGZegYKskroMNC1nbMoSVlR3c6MAlMbUX2HHVKtXaKaVM7uiL/CmSG0BS7Cdb3cuaMQOuaXqwvuqkqaiDHYidrcQ5AFMmD/QZVLwgLRejPMQZ91UU2DYg+SEfNfqk7OmdLiC74MWKJth0fY+5ZtwtE5ecKNc0l6grJun9YvrZ+EVl98HcuMdA7DLQ9rR7EUefGU50bVCrAJfb4SZoU0kaiOfx9cTH5z2txqOCj9kxsn+yVvukN59TXhOu7xip8ALIUlIaARydsOly4/sAJgdfkEuCSUjtmOD46QetMaSngaNVwhxZz9AwbeO06GfwOthB+NjPvHN15Pj8lTEBLoowjVPRH+81OJkhk6x+yyqIHt+kJbrj1UjJAl7yFAiTynZ//5bwjM921x8POfL0Kunsm0plccg5DFNUru58VUTyHJqXcx+RF2j3I3KU1D0+bTtQFR2Le+xcbaqpYfhA5M82GlUvFHa2co2IrELiS3HJyphQNCr2vrRNOcw+c16XOhShBpy2cd1SbHgx4HvtIHDFgly9uUHHEf9g1QDletg/ODWEisk6b7APwjqtOsH+RvFmVln7QakE1v0K4ZwkjrRa2JdP/p/X4rU0IL56Gprnkb+wjIEg1VcT5e7VpAdbcVmR5Fk=
secure: i3NT2YPez9Htah8k54jrVjCEL+bgFpGG9lRfGbIKoE2WBYeW28k11S9mu7BzAjGO8egFIIciksbat6KxiD1yITxBwkm9ptj41TICWzITM1lsIZttIeVMPd3olNGWfudALXsRqZ2nKoZuj+DpOIPaUkiIGN8nWSR6Byuw9BW8Y3rVVfii1gvVCUnLDfrGc2PNbt+Gg/HgMahg8odkihcPMvxiLx2+Uk6O0w/cfbmuZNdWEZrbFAr8cMLoqLXmZt9hJqONgaHrKlirH69C3MlNdppADVpJM6CTLgdsT4YDuRox+o2EMBziC9fqM4ohv+9qz8rK8Kir2P/Qj8QkkubqK/wHLSgmTXHHueE7K0dlMlj51p777dJjSEzxWi8Wnl+qVGi971LnvG8ygzwWb1+4x6SdsSSCdbLEVnefp1N2Pvl2gruPX+zytCsbaqXJD0V/2xV/b+fPVaD1td8dBGsAfLh00lttOpR3MwTAF5WFsiQCKq3D6RVbn0Aeeu+CYOBCarEqx0To/ydqPe36FKPLyyzAfnCfEMjQNvMzsFKy9Y0YHIV+dKMoW0oFYqRY9RGp4K0vp65PDOWNQZkGKDN592LIBwTR8cxoQpuax6FfqcxDGEUSsFdN6T+SJskZFO/bK3xpJyhWHlg1xrfdwH+iwXDswEAzUtat3auDcv0Htko=
on:
tags: true
repo: leukgen/cookiecutter-toil
branch: master

env:
global:
secure: uzWd7bdnaSw5q8r7s5iS/OWPJXHGNgM7FuISux+/SlpLU0E7g+boJo9/IlwrnjDirczw9hOHP6ndGussJEjxLTNfSZ5yqO6JmQW3P4yE3N6tByg32WPsLaEvmRx71tDPBWV3kylQC1Wnw8Lc0MIsPnKU1fTWI/LpD+SGzBNGxpEI2telboILmayVOez1v/E/8Uxx2+CjKT30XKKZvKlyflOrP1K8+QrHbu8G075M+/mwLHk4NFfRB0b2GJR6dZyre0+RSHRaK2ibGwXQlYKyx23qjeP++1w2Q3Sbatau8d1KA4jrlPw6Jyv7OEyfInAIMBOW2G59BfJW8jvqtUFrLs9224aeAWSMGub243l3BRMdZEXx8OLltcclDBPgO+W6SeU4Wm4gIS4lInwdNDnkaLpolsd09JUHqX1StEh28FqAt3QmIcW+sq8YWBS9i87VeUrnpzIWVLYby5dhFN15twhuV1oFcPHWVbmiBbPwhIzASadTnU0UPE6j6Y1De78Qe55pvGv9FGVR4T8wytWxIoxSQY/1HBGB6+b1fmKHnY9e+MH+BrFaxpF45k1im1BlzEEG9dDvNk4bQjIWrM6sYkFDrsqLvC1kMyRG83Hz/dJLVXpo/ese8KDZ/4Gmo+kreRqWMC1Kw2nwAXr+U27gg0y6+2i1ys2cxv3lu+M0MxY=
35 changes: 35 additions & 0 deletions .travis/deploy_toil_example.sh
@@ -0,0 +1,35 @@
if [ -z "$GH_TOKEN" ]; then
echo "No GH token available, skipping toil_example deployment..."
exit 0
fi

DEPLOY_REPO_URL=https://${GH_TOKEN}@github.com/leukgen/toil_example.git
DEPLOY_BASE_DIR=/tmp/toil_example_deploy
DEPLOY_TEMP_DIR=/tmp/toil_example_deploy/_toil_example
DEPLOY_REPO_DIR=/tmp/toil_example_deploy/toil_example
DEPLOY_REPO_BRA=${TRAVIS_PULL_REQUEST_BRANCH:="$TRAVIS_BRANCH"}

git config --global user.email "travis@travis-ci.org"
git config --global user.name "Travis CI"

if [ "$DEPLOY_TOIL_EXAMPLE" = "true" ]; then
mkdir $DEPLOY_BASE_DIR && cd $DEPLOY_BASE_DIR
git clone $DEPLOY_REPO_URL $DEPLOY_REPO_DIR

echo "checking out to current branch: $DEPLOY_REPO_BRA"
cd $DEPLOY_REPO_DIR && git checkout -B $DEPLOY_REPO_BRA

echo "force creating cookiecutter..."
cd $DEPLOY_BASE_DIR && mv $DEPLOY_REPO_DIR $DEPLOY_TEMP_DIR
cookiecutter $TRAVIS_BUILD_DIR --no-input -o $DEPLOY_BASE_DIR

echo "moving back .git directory to repo..."
mv $DEPLOY_TEMP_DIR/.git $DEPLOY_REPO_DIR
cd $DEPLOY_REPO_DIR && git add .

echo "pushing changes: 🤖 travis build $TRAVIS_BUILD_NUMBER..."
git commit --message "🤖 travis build $TRAVIS_BUILD_NUMBER"
git push -u --force origin $DEPLOY_REPO_BRA
else
echo "DEPLOY_TOIL_EXAMPLE not set to true, skipping..."
fi
16 changes: 15 additions & 1 deletion README.md
Expand Up @@ -9,6 +9,12 @@ A [cookiecutter] for the creation of [toil] and [click] Command Line Interfaces
pip install cookiecutter-toil
cookiecutter cookiecutter-toil

# Live Example

[![travis badge][example_travis_badge]][example_travis_base]
[![codecov badge][example_codecov_badge]][example_codecov_base]

Check out [toil_example], this project is updated automatically with every new commit on cookiecutter-toil.

# Features

Expand Down Expand Up @@ -69,8 +75,9 @@ A [cookiecutter] for the creation of [toil] and [click] Command Line Interfaces

* 🌀   **Continuous Integration**

[Travis CI] configuration with automatic deployment to `PyPi` with tags on `master`. To encrypt your `PyPi` password replace the field `deploy.password` in the `.travis.yml` configuration file and run:
[Travis CI] configuration with automatic deployment to `PyPi` with tags on `master`. To encrypt your `PyPi` password simply run:

# you need travis (e.g. brew install travis)
travis encrypt --add deploy.password

Check out this [tutorial][travis_deploy] if you want to learn more about deployment.
Expand All @@ -84,6 +91,7 @@ A [cookiecutter] for the creation of [toil] and [click] Command Line Interfaces
Please see the [CONTRIBUTING.md](CONTRIBUTING.md) in this repository!

<!-- References -->
[toil_example]: https://github.com/leukgen/toil_example
[`VERSION`]: https://packaging.python.org/guides/single-sourcing-package-version/
[click]: http://click.pocoo.org/6/
[covenant]: http://contributor-covenant.org/version/1/4/
Expand All @@ -107,3 +115,9 @@ Please see the [CONTRIBUTING.md](CONTRIBUTING.md) in this repository!
[pyup_base]: https://pyup.io/repos/github/leukgen/cookiecutter-toil/
[travis_badge]: https://img.shields.io/travis/leukgen/cookiecutter-toil.svg
[travis_base]: https://travis-ci.org/leukgen/cookiecutter-toil

<!-- toil example badges -->
[example_codecov_badge]: https://codecov.io/gh/leukgen/toil_example/branch/master/graph/badge.svg
[example_codecov_base]: https://codecov.io/gh/leukgen/toil_example
[example_travis_badge]: https://img.shields.io/travis/leukgen/toil_example.svg
[example_travis_base]: https://travis-ci.org/leukgen/toil_example
8 changes: 4 additions & 4 deletions cookiecutter.json
@@ -1,9 +1,9 @@
{
"full_name": "John Smith",
"email": "smithj@mskcc.org",
"full_name": "Juan S. Medina, Juan E. Arango",
"email": "medinaj@mskcc.org",
"github_account": "leukgen",
"cli_type": ["toil", "click"],
"project_name": "test_project",
"project_name": "toil_example",
"project_slug": "{{ cookiecutter.project_name.lower()|replace(' ', '_')|replace('-', '_') }}",
"project_description": "An awesome python package."
"project_description": "A Command Line Interface created with [cookiecutter-toil](https://github.com/leukgen/cookiecutter-toil)."
}
3 changes: 2 additions & 1 deletion setup.json
Expand Up @@ -26,5 +26,6 @@
],
"license": "BSD",
"name": "cookiecutter-toil",
"url": "github.com/leukgen/cookiecutter-toil"
"long_description": "📘 learn more on `GitHub <https://github.com/leukgen/cookiecutter-toil>`_!",
"url": "https://github.com/leukgen/cookiecutter-toil"
}
9 changes: 0 additions & 9 deletions setup.py
Expand Up @@ -3,28 +3,19 @@
from os.path import join
from os.path import abspath
from os.path import dirname
import io
import json

from setuptools import find_packages
from setuptools import setup


def read(path, **kwargs):
"""Return content of a file."""
return io.open(path, encoding=kwargs.get("encoding", "utf8")).read()


ROOT = abspath(dirname(__file__))

# please put setup keywords in the setup.json to keep this file clean
with open(join(ROOT, "setup.json"), "r") as f:
SETUP = json.load(f)

setup(
# load description from README
long_description=read(join(ROOT, "README.md")),

# the version is only defined in one place
version="0.1.0",

Expand Down
20 changes: 12 additions & 8 deletions {{cookiecutter.project_slug}}/README.md
Expand Up @@ -4,23 +4,19 @@
[![travis badge][travis_badge]][travis_base]
[![codecov badge][codecov_badge]][codecov_base]

An awesome pipeline called {{cookiecutter.project_slug}}.
{{cookiecutter.project_description}}

# Features

* 📦 &nbsp; **Installation**
* 📦 &nbsp; **Easy Installation**

# local
pip install --editable .

# pypi (if available)
pip install {{cookiecutter.project_slug}}

* 🍉 &nbsp; **Usage**
* 🍉 &nbsp; **Usage Documentation**

{{cookiecutter.project_slug}} --help

* 🐳 &nbsp; **Container Usage**
* 🐳 &nbsp; **Containers Support**

Check our docker hub for {{cookiecutter.project_slug}} images. Alternatively clone this repo and build the image yourself.

Expand All @@ -44,9 +40,17 @@ An awesome pipeline called {{cookiecutter.project_slug}}.

Contributions are welcome, and they are greatly appreciated, check our [contributing guidelines](CONTROBUTING.md)!

# Credits

This package was created using [Cookiecutter] and the
[leukgen/cookiecutter-toil] project template.


<!-- References -->
[singularity]: http://singularity.lbl.gov/
[docker2singularity]: https://github.com/singularityware/docker2singularity
[cookiecutter]: https://github.com/audreyr/cookiecutter
[leukgen/cookiecutter-toil]: https://github.com/leukgen/cookiecutter-toil

<!-- Badges -->
[codecov_badge]: https://codecov.io/gh/{{cookiecutter.github_account}}/{{cookiecutter.project_slug}}/branch/master/graph/badge.svg
Expand Down
3 changes: 2 additions & 1 deletion {{cookiecutter.project_slug}}/setup.json
Expand Up @@ -33,10 +33,11 @@
]
},
"author": "{{cookiecutter.full_name}}",
"description": "{{cookiecutter.project_description}}",
"keywords": [],
"license": "BSD",
"name": "{{cookiecutter.project_slug}}",
"test_suite": "tests",
"long_description": "📘 learn more on `GitHub <https://github.com/{{cookiecutter.github_account}}/{{cookiecutter.project_slug}}>`_!",
"description": "{{cookiecutter.project_description}}",
"url": "https://github.com/{{cookiecutter.github_account}}/{{cookiecutter.project_slug}}"
}
22 changes: 8 additions & 14 deletions {{cookiecutter.project_slug}}/setup.py
Expand Up @@ -3,34 +3,28 @@
from os.path import join
from os.path import abspath
from os.path import dirname
import io
import json

from setuptools import find_packages
from setuptools import setup


def read(path, **kwargs):
"""Return content of a file."""
return io.open(path, encoding=kwargs.get("encoding", "utf8")).read()


ROOT = abspath(dirname(__file__))

# please put setup keywords in the setup.json to keep this file clean
with open(join(ROOT, "setup.json"), "r") as f:
SETUP = json.load(f)

setup(
# load description from README
long_description=read(join(ROOT, "README.md")),
# see 4 > https://packaging.python.org/guides/single-sourcing-package-version/
with open(join(ROOT, "{{cookiecutter.project_slug}}", "VERSION"), "r") as f:
VERSION = f.read().strip()

# the version is only defined in one place
version=read(join(ROOT, "{{cookiecutter.project_slug}}", "VERSION")).strip(),
setup(
# single source package version
version=VERSION,

# in combination with recursive-includes in MANIFEST.in, non-python files
# included inside the {{cookiecutter.project_slug}} will be copied to the
# site-packages installation directory
# within the {{cookiecutter.project_slug}} will be copied into the
# site-packages and wheels installation directories
include_package_data=True,

# return a list all Python packages found within the ROOT directory
Expand Down
Expand Up @@ -48,8 +48,8 @@ def run(self, fileStore):

def run_toil(options):
"""Toil implementation for {{cookiecutter.project_slug}}."""
head = Hello(cores=4, memory="12G", options=options)
child = HelloMessage(cores=4, memory="12G", options=options)
head = Hello(cores=1, memory="1G", options=options)
child = HelloMessage(cores=1, memory="1G", options=options)
head.addChild(child)
ContainerCallJob.Runner.startToil(head, options)

Expand Down

0 comments on commit a25a37a

Please sign in to comment.