Skip to content

Commit

Permalink
Merge pull request #162 from Autodesk/deploy
Browse files Browse the repository at this point in the history
Continuous deployment
  • Loading branch information
avirshup authored Jun 13, 2017
2 parents 16a8570 + ce9d6ae commit f03040a
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 46 deletions.
13 changes: 11 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,18 @@ are considered "stable".

### Releases

1. Decide on the new version number (using [semantic versioning](http://semver.org/)). For our purposes here, we'll pretend it's `0.9.3`.
1. Decide on the new version number (see below). For our purposes here, we'll pretend it's `0.9.3`.
1. Tag the relevant commit (the build must be passing) with a release candidate version number, e.g., `0.9.3rc1`.
1. Codeship will automatically deploy the updated release to PyPI and DockerHub (still WIP 5/17)
1. Codeship will automatically deploy the updated release to PyPI and DockerHub
1. Manually test the example notebooks against this pre-release version.
1. If succesful, tag the relevant commit with the official release version `0.9.3`

### Versioning
For now, we're using a subset [PEP 440](https://www.python.org/dev/peps/pep-0440/):
1. Every release should be of the form MAJOR.MINOR.PATCH, e.g. `0.1.2`
2. Pre-releases should be numbered consecutively, and may be alpha, beta, or "release candidate", e.g. `1.0.1rc3` or `0.5.3a1`
3. Our deployment infrastructure uses this regular expression to accept version strings:
`^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)((a|rc|b)(0|[1-9]\d*))?$`

### Maintainers: updating the documentation

Expand Down
3 changes: 2 additions & 1 deletion DockerMakefiles/Moldesign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ moldesign_minimal_requirements:
&& apt-get install -y gcc \
&& pip install -r /tmp/mdtreqs.txt
COPY . /opt/molecular-design-toolkit
RUN pip install -e /opt/molecular-design-toolkit
WORKDIR /opt/molecular-design-toolkit
RUN python setup.py sdist && pip install `ls -t dist/*.tar.gz | head -n1`
moldesign_minimal:
requires:
Expand Down
2 changes: 1 addition & 1 deletion DockerMakefiles/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DockerMake >= 0.5.3
DockerMake >= 0.5.6
5 changes: 2 additions & 3 deletions codeship-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ docker_make:

publisher:
encrypted_env_file: deployment/tokens.crypt
encryped_dockercfg: deployment/docker.crypt
build:
context: .
dockerfile: ./deployment/build-env.dockerfile
context: ./deployment
dockerfile: ./moldesign-complete-cache.dockerfile
add_docker: true
working_dir: /opt/molecular-design-toolkit
volumes:
Expand Down
20 changes: 4 additions & 16 deletions codeship-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,9 @@
service: test_moldesign_minimal_py2
name: minimal_test_py2

# TODO: test the merged versions of PRs; test additional environments sometimes

#- name: code_coverage
# service: test_moldesign_complete
# command: cd /opt/molecular-design-toolkit/ && coveralls

- name: publish
service: publisher
# matches tags that are valid semantic versions
tag: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$'
type: serial
steps:
- command: ./deployment/check_pkg_version.sh
name: verify_version
- command: cd DockerMakefiles && docker-make --all --tag $CI_BRANCH --repo docker.io/autodesk/moldesign
tag: docker_push
- command: python setup.py check sdist && twine upload -u ${PYPI_USER} -p ${PYPI_PASSWORD} dist/*
name: pypi_push
# matches tags that are valid PEP440 versions
tag: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)((a|rc|b)(0|[1-9]\d*))?$'
command: ./deployment/publish.sh

14 changes: 0 additions & 14 deletions deployment/check_pkg_version.sh

This file was deleted.

9 changes: 5 additions & 4 deletions deployment/codeship_runtests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env bash

# this script expects to run from the moldesign/_tests directory

# fail immediately if any command fails:
set -e

VERSION="${TESTENV}.py${PYVERSION}"
PYTESTFLAGS="-n 6 --durations=20 --junit-xml=/opt/reports/junit.${VERSION}.xml --timeout=1800"
if [ "${VERSION}" == "complete.py3" ]; then
Expand All @@ -15,11 +17,11 @@ function send_status_update(){


function check_if_tests_should_run(){
echo "Should I run the tests in this environment?"
echo "Should I run the tests in this environment?"
runthem=false

if [[ "${CI_COMMIT_MESSAGE}" == *"--fast-ci-tests"* && "${VERSION}" != "complete.py3" ]]; then
echo "NO: found \"--fast-ci-tests\" flag in commit message; run complete.py3 only"
send_status_update 0 "Skipped (--fast-ci-tests flag in commit msg)"
exit 0
fi

Expand All @@ -44,7 +46,6 @@ function check_if_tests_should_run(){
echo "SKIPPING tests in this environment."
echo "To run these tests, add \"--testall\" to your commit message"
echo "(or work in the dev or deploy branches)"
send_status_update 0 "Skipped (dev/deploy branches only)"
exit 0
fi
}
Expand Down
1 change: 0 additions & 1 deletion deployment/docker.crypt

This file was deleted.

3 changes: 3 additions & 0 deletions deployment/moldesign-complete-cache.dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
FROM moldesign_complete:dev
ADD requirements.txt provision_testrunner_image.sh /tmp/
RUN cd /tmp && ./provision_testrunner_image.sh
RUN pip install twine
WORKDIR /opt/molecular-design-toolkit
RUN pip install -r DockerMakefiles/requirements.txt
25 changes: 25 additions & 0 deletions deployment/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Publish a new release (triggered by a git tag that conforms to a PEP440 release)
# Exit 1 if there's a mismatch between the git tag and the package's version
# Expects to run in base directory

# fail immediately if any command fails:
set -e

pyversion=$(python -m moldesign version | tail -n 1)

if [ "${pyversion}" == "${CI_BRANCH}" ]; then
echo "Deploying version ${CI_BRANCH}"
else
echo "Can't publish - moldesign package version '${pyversion}' differs from its Git tag '${CI_BRANCH}'"
exit 1
fi

docker-make -f DockerMakefiles/DockerMake.yml \
--repo docker.io/autodesk/moldesign: \
--tag ${pyversion} \
--all \
--push --user ${DOCKERHUB_USER} --token ${DOCKERHUB_PASSWORD}

twine upload -u ${PYPI_USER} -p ${PYPI_PASSWORD} dist/moldesign-${pyversion}.tar.gz
1 change: 0 additions & 1 deletion deployment/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ PyGithub
pytest-cov
pytest-xdist != 1.17.0
pytest-timeout
twine
2 changes: 1 addition & 1 deletion deployment/tokens.crypt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
JbDr9gK2wjC1kxhF/omEUkq2sLSIML6yZ0bzhKs//sDOOrApuFkyCzLm2p2EFPnVDK8kcuJ6353Cc9+gDLO92JaOrct2Tw+Q9O9UxOj+FUKuVRTEz9pjBJMbyl+W7WhOeKEfH+3SeBBPmLXCn5YZCxr1yw9hqKX9kIKh/QLY69MWMPy2O1Xar7M2BkaYW8f7BmxA5a4OipZVYk6zaOqlAFA1Yy9CseNl3GWTe1DBIboWY08cGw==
on37G8kkndvo2yloV66PWzQ/0bbTTKmj7SyjwcYHKbJKDi9jilWpcx8pXbtr1DLKeR0tweY7EXErHFpra0R3VUEm0qbPH3kpOFDZLiGAJKotYPhrRjthsId6yQH8lXot9PIiN128Eu1MUQmLnwk3+J8RZ3++3ILZinK2Jw3Ts8sbmn/OGIz6eGad9PTnV4/BdilF+VvOrr+l9fKvpM4XpTJDYh6SFsPr2S0mtTsU78cZUwDI3PpPP+SjpL9aVb/2zCK1jDpG7Q8Mlvun0zqlV0CcECJorX0vcbDcnKuF+krxw8fmJShCrDtf6ME/DZrK0Q==
7 changes: 5 additions & 2 deletions moldesign/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
EXAMPLE_DIR_SRC = unit_def_file = os.path.join(MOLDESIGN_SRC, '_notebooks')
MDTVERSION = subprocess.check_output(['python', '-c',
"import _version; print(_version.get_versions()['version'])"],
cwd=MOLDESIGN_SRC).strip()
cwd=MOLDESIGN_SRC).splitlines()[-1].decode('ascii')
VERFILEPATH = os.path.join(EXAMPLE_DIR_TARGET, '.mdtversion')


Expand All @@ -64,7 +64,6 @@
def main():
print('Molecular Design Toolkit v%s Launcher' % MDTVERSION)


global CONFIG_PATH
parser = argparse.ArgumentParser('python -m moldesign')

Expand All @@ -79,6 +78,7 @@ def main():
subparsers.add_parser('copyexamples', help='Copy example notebooks')
subparsers.add_parser('devbuild', help='rebuild required docker containers locally')
subparsers.add_parser('devpull', help='Pull development images for latest release')
subparsers.add_parser('version', help='Write version string and exit')

parser.add_argument('-f', '--config-file', type=str,
help='Path to config file')
Expand Down Expand Up @@ -108,6 +108,9 @@ def main():
elif args.command == 'copyexamples':
copy_example_dir(use_existing=False)

elif args.command == 'version':
print(MDTVERSION)

elif args.command == 'config':
print('Reading config file from: %s' % CONFIG_PATH)
print('----------------------------')
Expand Down

0 comments on commit f03040a

Please sign in to comment.