From 86ee5fc1e2a5ed52ce3210d7f4f4444c9e19655c Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Mon, 20 Nov 2017 16:55:06 -0800 Subject: [PATCH 01/18] Use correct docker image names for releases --- codeship-services.yml | 6 +++++ codeship-steps.yml | 46 +++++++++++++++++++++++++++----------- deployment/README.md | 6 ++++- deployment/publish.sh | 10 +++++++++ deployment/pull-cache.sh | 3 ++- deployment/push.sh | 5 +++-- deployment/run-ci-tests.sh | 27 +++++++++++++++++++--- 7 files changed, 83 insertions(+), 20 deletions(-) diff --git a/codeship-services.yml b/codeship-services.yml index ab5f69b..c5417bb 100644 --- a/codeship-services.yml +++ b/codeship-services.yml @@ -7,6 +7,8 @@ image_builder: &build-base add_docker: true cached: true working_dir: /opt/molecular-design-toolkit + environment: &repo + REPO: "docker.io/autodesk/moldesign:" publisher: @@ -26,6 +28,7 @@ test_moldesign_minimal: &test-base args: baseimage: moldesign_minimal environment: + <<: *repo TESTENV: minimal PYVERSION: 3 OPENMM_CPU_THREADS: 1 @@ -38,6 +41,7 @@ test_moldesign_minimal_py2: args: baseimage: moldesign_minimal_py2 environment: + <<: *repo TESTENV: minimal PYVERSION: 2 OPENMM_CPU_THREADS: 1 @@ -50,6 +54,7 @@ test_moldesign_complete: args: baseimage: moldesign_complete environment: + <<: *repo TESTENV: complete PYVERSION: 3 OPENMM_CPU_THREADS: 1 @@ -62,6 +67,7 @@ test_moldesign_complete_py2: args: baseimage: moldesign_complete_py2 environment: + <<: *repo TESTENV: complete PYVERSION: 2 OPENMM_CPU_THREADS: 1 diff --git a/codeship-steps.yml b/codeship-steps.yml index a6b8fa1..d4bfed8 100644 --- a/codeship-steps.yml +++ b/codeship-steps.yml @@ -1,13 +1,21 @@ +# Pull previous builds from DockerHub to use as a cache. +# These images are tagged as [imagename]-cache - name: pull-cache service: image_builder command: deployment/pull-cache.sh +# Build the python package to be tested (and uploaded to PyPI if this is a release) +# The package is built in the "autodesk/moldesign:moldesign_py_build-[branch name]" image - name: build-sdist service: image_builder - command: docker-make moldesign_py_build + command: bash -c "docker-make moldesign_py_build + --repo ${REPO} --tag ${CI_BRANCH} --keep-build-tags - -f DockerMakefiles/DockerMake.yml --tag dev + -f DockerMakefiles/DockerMake.yml" +# Build docker images for all test environments. They will be tagged as +# autodesk/moldesign:[imagename]-[branchname] +# (For the sake of parallelism, we also download other images that the tests depend on) - name: build-and-pull-images service: image_builder type: parallel @@ -15,23 +23,28 @@ - name: pull-dependent-images command: deployment/pull-chemdocker.sh - name: build_py3 - command: - docker-make moldesign_minimal moldesign_complete + command: bash -c + "docker-make moldesign_minimal moldesign_complete -f DockerMakefiles/DockerMake.yml - --tag dev --keep-build-tags - --cache-repo moldesign --cache-tag cache + --repo ${REPO} --tag ${CI_BRANCH} + --keep-build-tags + --cache-repo moldesign --cache-tag cache" - name: build_py2 - command: - docker-make moldesign_minimal_py2 moldesign_complete_py2 + command: bash -c + "docker-make moldesign_minimal_py2 moldesign_complete_py2 -f DockerMakefiles/DockerMake.yml - --tag dev --keep-build-tags - --cache-repo moldesign --cache-tag cache + --repo ${REPO} --tag ${CI_BRANCH} + --keep-build-tags + --cache-repo moldesign --cache-tag cache" + +# Push build artifacts to Dockerhub. +# These are tagged as autodesk/moldesign:[imagename]-[branchame]-devbuild - name: push-images type: parallel steps: - name: push-artifacts - command: deployment/push.sh moldesign_minimal moldesign_py2 + command: deployment/push.sh moldesign_minimal moldesign_py2 moldesign_py_build moldesign_complete moldesign_complete_py2 service: publisher - type: serial @@ -39,14 +52,17 @@ steps: - name: build-notebook service: image_builder - command: docker-make moldesign_notebook + command: bash -c + "docker-make moldesign_notebook -f DockerMakefiles/DockerMake.yml - --tag dev --cache-repo moldesign --cache-tag cache + --repo ${REPO} --tag ${CI_BRANCH} + --cache-tag cache" - name: push-notebook service: publisher command: deployment/push.sh moldesign_notebook +# Prints out internal information about the test environments - name: print-environments type: parallel services: @@ -58,6 +74,7 @@ - command: deployment/print-environment.sh name: env-report +# Run the tests in each environment. - name: run-tests type: serial services: @@ -69,6 +86,9 @@ - command: deployment/run-ci-tests.sh name: testrunner +# If this build is tagged with a PEP440-compliant version number AND the tests have passed, +# upload the package to PyPI, and push the docker images to dockerhub as +# autodesk/moldesign:[imagename]-[version-number] - name: publish-python service: publisher # matches tags that are valid PEP440 versions diff --git a/deployment/README.md b/deployment/README.md index 0602eb8..44507d8 100644 --- a/deployment/README.md +++ b/deployment/README.md @@ -1 +1,5 @@ -Files in this directory are for use with our Codeship CI/CD setup, and aren't generally useful outside of that context. \ No newline at end of file +Files in this directory are for use with our Codeship CI/CD setup, +and aren't generally useful outside of that context. + + +The build process is annotated in ../codeship-steps.yml \ No newline at end of file diff --git a/deployment/publish.sh b/deployment/publish.sh index 8756aaa..b10de52 100755 --- a/deployment/publish.sh +++ b/deployment/publish.sh @@ -18,6 +18,16 @@ else fi +# Push images +for img in moldesign_minimal \ + moldesign_minimal_py2 \ + moldesign_complete \ + moldesign_complete_py2 \ + moldesign_notebook; do + docker push ${REPO}{$img}-${CI_BRANCH} | tee -a push.log | egrep -i 'pull|already' +done + + # Copy build artifacts sdist=moldesign-${pyversion}.tar.gz docker run moldesign_py_build:dev -v ./tmp/dists:/hostdists cp dist/${sdist} /hostdists diff --git a/deployment/pull-cache.sh b/deployment/pull-cache.sh index 737a51c..7c35b4c 100755 --- a/deployment/pull-cache.sh +++ b/deployment/pull-cache.sh @@ -14,7 +14,7 @@ function run-pull(){ # pull an image. If successful, retags the image with the "cache" tag img=$1 tag=$2 - imgpath="autodesk/moldesign:${img}-${tag}" + imgpath="${REPO}${img}-${tag}" echocmd docker pull ${imgpath} | tee -a pull.log | egrep -i 'pull|already'; @@ -34,6 +34,7 @@ for img in moldesign_minimal \ moldesign_minimal_py2 \ moldesign_complete \ moldesign_complete_py2 \ + moldesign_py_build \ moldesign_notebook; do run-pull ${img} ${CI_BRANCH}-devbuild || run-pull ${img} master || \ echo " --> Failed to pull cache for ${img}" diff --git a/deployment/push.sh b/deployment/push.sh index 53a54e4..79bbbbb 100755 --- a/deployment/push.sh +++ b/deployment/push.sh @@ -18,8 +18,9 @@ function echocmd() { docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD} for img in $@; do - remote_img=autodesk/moldesign:${img}-${CI_BRANCH}-devbuild + local_img=${REPO}${img}-${CI_BRANCH} + remote_img=${local_img}-devbuild - echocmd docker tag ${img}:dev ${remote_img} + echocmd docker tag ${local_img} ${remote_img} echocmd docker push ${remote_img} | tee -a push.log | egrep -i 'push|already'; done \ No newline at end of file diff --git a/deployment/run-ci-tests.sh b/deployment/run-ci-tests.sh index be6d0f3..de341a1 100755 --- a/deployment/run-ci-tests.sh +++ b/deployment/run-ci-tests.sh @@ -1,7 +1,19 @@ #!/usr/bin/env bash +# Drives tests for our CI system. This looks for the following environment variables: +# Defined by codeship +# - CI_BRANCH +# - CI_COMMIT_MESSAGE +# Defined in ../codeship-services.yml +# - TESTENV +# - PYVERSION set -e # fail immediately if any command fails +if [ -z "${CI_BRANCH}" ]; then + echo "FAILURE: Variable \$CI_BRANCH not defined." + exit 1 +fi + install_location=$(python -c "import moldesign, os; print(moldesign.__path__[0])") test_location=$(dirname "${install_location}") @@ -19,22 +31,31 @@ function send_status_update(){ function check_if_tests_should_run(){ 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" exit 0 fi + if [[ "${CI_BRANCH}" =~ ^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)((a|rc|b)(0|[1-9]\d*))?$ ]] + then + echo "YES: this is a release version: \"${CI_BRANCH}\"" + return 0 + else # otherwise, point to the appropriate docker image tag + mkdir -p ~/.moldesign + echo "default_version_tag: ${CI_BRANCH}" >> ~/.moldesign/moldesign.yml + fi + + if [ "${TESTENV}" == "complete" ]; then - runthem=true echo "YES: always run in 'complete' environment" + return 0 fi case "${CI_BRANCH}" in master|deploy|dev) - runthem=true echo "YES: always run in branch \"${CI_BRANCH}\"" + return 0 ;; esac From 7417a0a4a433487b772831d542d97d35760a1a88 Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Tue, 21 Nov 2017 11:36:11 -0800 Subject: [PATCH 02/18] Better docker tag handling --- codeship-steps.yml | 26 ++++++++++++++----------- deployment/pull-cache.sh | 2 +- deployment/{push.sh => push-and-tag.sh} | 10 ++++++---- 3 files changed, 22 insertions(+), 16 deletions(-) rename deployment/{push.sh => push-and-tag.sh} (55%) diff --git a/codeship-steps.yml b/codeship-steps.yml index d4bfed8..d94ba79 100644 --- a/codeship-steps.yml +++ b/codeship-steps.yml @@ -14,7 +14,7 @@ -f DockerMakefiles/DockerMake.yml" # Build docker images for all test environments. They will be tagged as -# autodesk/moldesign:[imagename]-[branchname] +# [imagename]-dev # (For the sake of parallelism, we also download other images that the tests depend on) - name: build-and-pull-images service: image_builder @@ -26,26 +26,30 @@ command: bash -c "docker-make moldesign_minimal moldesign_complete -f DockerMakefiles/DockerMake.yml - --repo ${REPO} --tag ${CI_BRANCH} - --keep-build-tags - --cache-repo moldesign --cache-tag cache" + --tag dev + --keep-build-tags + --cache-tag cache" - name: build_py2 command: bash -c "docker-make moldesign_minimal_py2 moldesign_complete_py2 -f DockerMakefiles/DockerMake.yml - --repo ${REPO} --tag ${CI_BRANCH} + --tag dev --keep-build-tags - --cache-repo moldesign --cache-tag cache" + --cache-tag cache" # Push build artifacts to Dockerhub. # These are tagged as autodesk/moldesign:[imagename]-[branchame]-devbuild -- name: push-images +# For testing purposes, they are also tagged as +# autodesk/moldesign:[imagename]-[branchname] (this is the tag that will be pushed +# to dockerhub for successful releases) +- name: tag-and-push-images type: parallel steps: - name: push-artifacts - command: deployment/push.sh moldesign_minimal moldesign_py2 moldesign_py_build - moldesign_complete moldesign_complete_py2 + command: deployment/push-and-tag.sh + moldesign_minimal moldesign_py2 moldesign_py_build + moldesign_complete moldesign_complete_py2 service: publisher - type: serial name: make-notebook @@ -55,11 +59,11 @@ command: bash -c "docker-make moldesign_notebook -f DockerMakefiles/DockerMake.yml - --repo ${REPO} --tag ${CI_BRANCH} + --tag dev --cache-tag cache" - name: push-notebook service: publisher - command: deployment/push.sh moldesign_notebook + command: deployment/push-and-tag.sh moldesign_notebook # Prints out internal information about the test environments diff --git a/deployment/pull-cache.sh b/deployment/pull-cache.sh index 7c35b4c..362aa1a 100755 --- a/deployment/pull-cache.sh +++ b/deployment/pull-cache.sh @@ -22,7 +22,7 @@ function run-pull(){ if [ "$success" -ne 0 ]; then return ${success}; else - docker tag ${imgpath} moldesign/${img}:cache + docker tag ${imgpath} ${img}:cache fi } diff --git a/deployment/push.sh b/deployment/push-and-tag.sh similarity index 55% rename from deployment/push.sh rename to deployment/push-and-tag.sh index 79bbbbb..9046c4e 100755 --- a/deployment/push.sh +++ b/deployment/push-and-tag.sh @@ -18,9 +18,11 @@ function echocmd() { docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD} for img in $@; do - local_img=${REPO}${img}-${CI_BRANCH} - remote_img=${local_img}-devbuild + build_img=${img}:dev + release_tag=${REPO}${img}-${CI_BRANCH} + artifact_tag=${release_tag}-devbuild - echocmd docker tag ${local_img} ${remote_img} - echocmd docker push ${remote_img} | tee -a push.log | egrep -i 'push|already'; + echocmd docker tag ${build_img} ${release_tag} + echocmd docker tag ${build_img} ${artifact_tag} + echocmd docker push ${artifact_tag} | tee -a push.log | egrep -i 'push|already'; done \ No newline at end of file From f4b797ecc70f4de02903dce3b386abbd82142ef9 Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Tue, 21 Nov 2017 13:56:46 -0800 Subject: [PATCH 03/18] Better handling of the PyPI deploy archive --- codeship-services.yml | 2 -- codeship-steps.yml | 15 +++++++++++++-- deployment/publish.sh | 18 +++++------------- deployment/run-ci-tests.sh | 1 + deployment/test-version-number.sh | 22 ++++++++++++++++++++++ 5 files changed, 41 insertions(+), 17 deletions(-) create mode 100755 deployment/test-version-number.sh diff --git a/codeship-services.yml b/codeship-services.yml index c5417bb..6a110cb 100644 --- a/codeship-services.yml +++ b/codeship-services.yml @@ -2,8 +2,6 @@ image_builder: &build-base build: context: . dockerfile: ./deployment/build-env.dockerfile - volumes: - - ./tmp/dist:/opt/molecular-design-toolkit/dist add_docker: true cached: true working_dir: /opt/molecular-design-toolkit diff --git a/codeship-steps.yml b/codeship-steps.yml index d94ba79..c9d2400 100644 --- a/codeship-steps.yml +++ b/codeship-steps.yml @@ -90,12 +90,23 @@ - command: deployment/run-ci-tests.sh name: testrunner + # If this build is tagged with a PEP440-compliant version number AND the tests have passed, # upload the package to PyPI, and push the docker images to dockerhub as # autodesk/moldesign:[imagename]-[version-number] -- name: publish-python +- name: release service: publisher # matches tags that are valid PEP440 versions + type: serial tag: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)((a|rc|b)(0|[1-9]\d*))?$' - command: deployment/publish.sh + steps: + - type: parallel + services: + - test_moldesign_complete + - test_moldesign_complete_py2 + steps: + - command: deployment/test-version-number.sh + - name: upload + command: deployment/publish.sh + service: publisher diff --git a/deployment/publish.sh b/deployment/publish.sh index b10de52..d2c40c9 100755 --- a/deployment/publish.sh +++ b/deployment/publish.sh @@ -8,17 +8,11 @@ # 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 - +# Copy python package out of the docker image +sdist=moldesign-${pyversion}.tar.gz +docker run moldesign_py_build:dev -v ./tmp/dist:/hostdists cp dist/${sdist} /hostdists -# Push images +# Push images to dockerhub for img in moldesign_minimal \ moldesign_minimal_py2 \ moldesign_complete \ @@ -28,8 +22,6 @@ for img in moldesign_minimal \ done -# Copy build artifacts -sdist=moldesign-${pyversion}.tar.gz -docker run moldesign_py_build:dev -v ./tmp/dists:/hostdists cp dist/${sdist} /hostdists +# Push python package to PyPI echo "Uploading version ${CI_BRANCH} to PyPI:" twine upload -u ${PYPI_USER} -p ${PYPI_PASSWORD} ./tmp/dists/moldesign-${pyversion}.tar.gz diff --git a/deployment/run-ci-tests.sh b/deployment/run-ci-tests.sh index de341a1..e0c8cb3 100755 --- a/deployment/run-ci-tests.sh +++ b/deployment/run-ci-tests.sh @@ -3,6 +3,7 @@ # Defined by codeship # - CI_BRANCH # - CI_COMMIT_MESSAGE +# - PROJECT_ID # Defined in ../codeship-services.yml # - TESTENV # - PYVERSION diff --git a/deployment/test-version-number.sh b/deployment/test-version-number.sh new file mode 100755 index 0000000..2505562 --- /dev/null +++ b/deployment/test-version-number.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -e + +if [ -z "${CI_BRANCH}" ]; then + echo "Error: env var CI_BRANCH not set" + exit 1 +fi + + +pyversion=$(python -m moldesign version | tail -n 1) + +echo "Expecting moldesign==${pyversion}" +echo "Found moldesign==${pyversion}" + + +if [ "${pyversion}" == "${CI_BRANCH}" ]; then + echo "All good" + exit 0 +else + echo "Error: moldesign package version '${pyversion}' differs from its Git tag '${CI_BRANCH}'" + exit 1 +fi From b7054d3bf7b15ec9cbf1e88de7ec70a246a12a01 Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Tue, 21 Nov 2017 14:01:56 -0800 Subject: [PATCH 04/18] Fix yml typo --- codeship-steps.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codeship-steps.yml b/codeship-steps.yml index c9d2400..2908acc 100644 --- a/codeship-steps.yml +++ b/codeship-steps.yml @@ -91,11 +91,12 @@ name: testrunner + + # If this build is tagged with a PEP440-compliant version number AND the tests have passed, # upload the package to PyPI, and push the docker images to dockerhub as # autodesk/moldesign:[imagename]-[version-number] - name: release - service: publisher # matches tags that are valid PEP440 versions type: serial tag: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)((a|rc|b)(0|[1-9]\d*))?$' From f6fbb72ff7749dc4bfc072984b0649bc78135f7b Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Mon, 27 Nov 2017 14:29:36 -0800 Subject: [PATCH 05/18] Build python package from complete git repo to keep version clean --- DockerMakefiles/Moldesign.yml | 1 - deployment/test-version-number.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/DockerMakefiles/Moldesign.yml b/DockerMakefiles/Moldesign.yml index 2d40dbc..8b3c51c 100644 --- a/DockerMakefiles/Moldesign.yml +++ b/DockerMakefiles/Moldesign.yml @@ -5,7 +5,6 @@ moldesign_py_build: requires: - python_deploy build_directory: .. - ignorefile: buildfiles/moldesign/moldesign.dockerignore build: | COPY . /opt/molecular-design-toolkit WORKDIR /opt/molecular-design-toolkit diff --git a/deployment/test-version-number.sh b/deployment/test-version-number.sh index 2505562..73ad170 100755 --- a/deployment/test-version-number.sh +++ b/deployment/test-version-number.sh @@ -9,7 +9,7 @@ fi pyversion=$(python -m moldesign version | tail -n 1) -echo "Expecting moldesign==${pyversion}" +echo "Expecting moldesign==${CI_BRANCH}" echo "Found moldesign==${pyversion}" From c41061884f4d40ecd82267bbd3bc8424809dd3ab Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Tue, 28 Nov 2017 11:18:43 -0800 Subject: [PATCH 06/18] Fix mdt-py-build tag --- codeship-steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codeship-steps.yml b/codeship-steps.yml index 2908acc..7eec4b4 100644 --- a/codeship-steps.yml +++ b/codeship-steps.yml @@ -9,7 +9,7 @@ - name: build-sdist service: image_builder command: bash -c "docker-make moldesign_py_build - --repo ${REPO} --tag ${CI_BRANCH} + --tag dev --keep-build-tags -f DockerMakefiles/DockerMake.yml" From 1326783d650a33a0f52968d324991e6e9026c541 Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Tue, 28 Nov 2017 15:56:14 -0800 Subject: [PATCH 07/18] Fix commands in publish script --- codeship-services.yml | 1 + deployment/publish.sh | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/codeship-services.yml b/codeship-services.yml index 6a110cb..719f777 100644 --- a/codeship-services.yml +++ b/codeship-services.yml @@ -11,6 +11,7 @@ image_builder: &build-base publisher: <<: *build-base + cached: false encrypted_env_file: ./deployment/deploy-tokens.crypt diff --git a/deployment/publish.sh b/deployment/publish.sh index d2c40c9..6cb4db5 100755 --- a/deployment/publish.sh +++ b/deployment/publish.sh @@ -8,9 +8,11 @@ # fail immediately if any command fails: set -e +echo "Now deploying moldesign-${pyversion}" + # Copy python package out of the docker image sdist=moldesign-${pyversion}.tar.gz -docker run moldesign_py_build:dev -v ./tmp/dist:/hostdists cp dist/${sdist} /hostdists +docker run -v ${PWD}/tmp/dist:/hostdists moldesign_py_build:dev cp dist/${sdist} /hostdists # Push images to dockerhub for img in moldesign_minimal \ From 70c794b179b055ea2f45b7cd8ffb65e453d71fc2 Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Tue, 28 Nov 2017 23:21:28 -0800 Subject: [PATCH 08/18] Fix publish version determination --- deployment/publish.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deployment/publish.sh b/deployment/publish.sh index 6cb4db5..1119b02 100755 --- a/deployment/publish.sh +++ b/deployment/publish.sh @@ -8,10 +8,10 @@ # fail immediately if any command fails: set -e -echo "Now deploying moldesign-${pyversion}" +echo "Now deploying moldesign-${CI_BRANCH}" # Copy python package out of the docker image -sdist=moldesign-${pyversion}.tar.gz +sdist=moldesign-${CI_BRANCH}.tar.gz docker run -v ${PWD}/tmp/dist:/hostdists moldesign_py_build:dev cp dist/${sdist} /hostdists # Push images to dockerhub @@ -26,4 +26,4 @@ done # Push python package to PyPI echo "Uploading version ${CI_BRANCH} to PyPI:" -twine upload -u ${PYPI_USER} -p ${PYPI_PASSWORD} ./tmp/dists/moldesign-${pyversion}.tar.gz +twine upload -u ${PYPI_USER} -p ${PYPI_PASSWORD} ./tmp/dists/moldesign-${CI_BRANCH}.tar.gz From d7e619b72a20acec686305593227597e3e4a7b0f Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Tue, 28 Nov 2017 23:22:11 -0800 Subject: [PATCH 09/18] Combine coverage from all environments --- .coveragerc | 2 +- codeship-services.yml | 8 ++++++++ codeship-steps.yml | 22 ++++++++-------------- deployment/build-env.dockerfile | 5 +++-- deployment/push-coverage.sh | 11 +++++++++++ deployment/run-ci-tests.sh | 23 +++++++++-------------- 6 files changed, 40 insertions(+), 31 deletions(-) create mode 100755 deployment/push-coverage.sh diff --git a/.coveragerc b/.coveragerc index 2d586d5..f5572e2 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,7 +1,7 @@ [paths] source = moldesign - + */moldesign [run] source = moldesign diff --git a/codeship-services.yml b/codeship-services.yml index 719f777..dc731cd 100644 --- a/codeship-services.yml +++ b/codeship-services.yml @@ -9,6 +9,14 @@ image_builder: &build-base REPO: "docker.io/autodesk/moldesign:" +coverage_pusher: + <<: *build-base + cached: false + encrypted_env_file: ./deployment/test-tokens.crypt + volumes: + - ./tmp/reports:/opt/reports + + publisher: <<: *build-base cached: false diff --git a/codeship-steps.yml b/codeship-steps.yml index 7eec4b4..7bac42a 100644 --- a/codeship-steps.yml +++ b/codeship-steps.yml @@ -66,19 +66,7 @@ command: deployment/push-and-tag.sh moldesign_notebook -# Prints out internal information about the test environments -- name: print-environments - type: parallel - services: - - test_moldesign_complete - - test_moldesign_complete_py2 - - test_moldesign_minimal - - test_moldesign_minimal_py2 - steps: - - command: deployment/print-environment.sh - name: env-report - -# Run the tests in each environment. +# Run the tests in each environment - name: run-tests type: serial services: @@ -87,10 +75,16 @@ - test_moldesign_minimal_py2 - test_moldesign_minimal steps: + - command: deployment/print-environment.sh + name: environment - command: deployment/run-ci-tests.sh - name: testrunner + name: tests +# Upload coverage results +- name: push-coverage + service: coverage_pusher + command: deployment/push-coverage.sh # If this build is tagged with a PEP440-compliant version number AND the tests have passed, diff --git a/deployment/build-env.dockerfile b/deployment/build-env.dockerfile index 9f0a20f..467efb0 100644 --- a/deployment/build-env.dockerfile +++ b/deployment/build-env.dockerfile @@ -10,6 +10,7 @@ RUN curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-17.04.0-ce.tgz && mv docker/docker /usr/local/bin \ && rm -r docker docker-17.04.0-ce.tgz -ADD . /opt/molecular-design-toolkit -RUN pip install -r /opt/molecular-design-toolkit/DockerMakefiles/requirements.txt +ADD ./DockerMakefiles/requirements.txt /tmp/reqs.txt +RUN pip install -r /tmp/reqs.txt && pip install coveralls +ADD . /opt/molecular-design-toolkit diff --git a/deployment/push-coverage.sh b/deployment/push-coverage.sh new file mode 100755 index 0000000..05de8e8 --- /dev/null +++ b/deployment/push-coverage.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# combines coverage from all test environments and pushes it to coveralls.io + +set -e + +mkdir -p /opt/reports/env-coverage +cp /opt/reports/env-coverage/coverage.* /opt/reports/ + +coverage combine /opt/reports/coverage.* \ + && coveralls \ + || echo "Failed to upload coverage to coveralls.io" \ No newline at end of file diff --git a/deployment/run-ci-tests.sh b/deployment/run-ci-tests.sh index e0c8cb3..33f7fd4 100755 --- a/deployment/run-ci-tests.sh +++ b/deployment/run-ci-tests.sh @@ -19,10 +19,9 @@ install_location=$(python -c "import moldesign, os; print(moldesign.__path__[0]) test_location=$(dirname "${install_location}") VERSION="${TESTENV}.py${PYVERSION}" -PYTESTFLAGS="moldesign/_tests/ -n 2 --spec --durations=20 --junit-xml=/opt/reports/junit.${VERSION}.xml --timeout=3600 --tb=short" -if [ "${VERSION}" == "complete.py3" ]; then - PYTESTFLAGS="${PYTESTFLAGS} --cov moldesign --cov-config /opt/molecular-design-toolkit/.coveragerc" -fi +PYTESTFLAGS="moldesign/_tests/ -n 2 --spec --durations=20 + --junit-xml=/opt/reports/junit.${VERSION}.xml --timeout=3600 --tb=short + --cov moldesign --cov-config /opt/molecular-design-toolkit/.coveragerc" function send_status_update(){ @@ -78,29 +77,25 @@ function run_tests(){ send_status_update "na" "Starting tests for ${VERSION}" cd ${test_location} + echo echo "Test command running in working dir '$(pwd)':" echo "py.test ${PYTESTFLAGS}" echo - py.test ${PYTESTFLAGS} | tee /opt/reports/pytest.${VERSION}.log + py.test ${PYTESTFLAGS} -k test_bond_alignment_on_axis | tee /opt/reports/pytest.${VERSION}.log exitstat=${PIPESTATUS[0]} - statline="$(tail -n1 /opt/reports/pytest.${VERSION}.log)" + # Make a copy of the coverage report + mkdir -p /opt/reports/env-coverage/ + cp .coverage /opt/reports/env-coverage/coverage.${VERSION} + echo 'Test status:' echo ${statline} send_status_update "${exitstat}" "${statline}" - if [ "${VERSION}" == "complete.py3" ]; then - if [[ ${exitstat} == 0 && "$CI_BRANCH" != "" ]]; then - coveralls || echo "Failed to upload code coverage stats" - else - echo "Skipping coveralls upload: tests not passing or \$CI_COMMIT not set." - fi - fi - exit ${exitstat} } From 422ed256cabf8a91cba1c1968a87631bf920c280 Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Fri, 1 Dec 2017 10:44:22 -0800 Subject: [PATCH 10/18] Fix dumb typos --- deployment/publish.sh | 2 +- deployment/run-ci-tests.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/publish.sh b/deployment/publish.sh index 1119b02..4f16ee6 100755 --- a/deployment/publish.sh +++ b/deployment/publish.sh @@ -20,7 +20,7 @@ for img in moldesign_minimal \ moldesign_complete \ moldesign_complete_py2 \ moldesign_notebook; do - docker push ${REPO}{$img}-${CI_BRANCH} | tee -a push.log | egrep -i 'pull|already' + docker push ${REPO}${img}-${CI_BRANCH} | tee -a push.log | egrep -i 'pull|already' done diff --git a/deployment/run-ci-tests.sh b/deployment/run-ci-tests.sh index 33f7fd4..aa7a01e 100755 --- a/deployment/run-ci-tests.sh +++ b/deployment/run-ci-tests.sh @@ -83,7 +83,7 @@ function run_tests(){ echo "py.test ${PYTESTFLAGS}" echo - py.test ${PYTESTFLAGS} -k test_bond_alignment_on_axis | tee /opt/reports/pytest.${VERSION}.log + py.test ${PYTESTFLAGS} | tee /opt/reports/pytest.${VERSION}.log exitstat=${PIPESTATUS[0]} statline="$(tail -n1 /opt/reports/pytest.${VERSION}.log)" From 926b7e1a24dc68c47bc07a6205e507e6d253eb2c Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Fri, 1 Dec 2017 15:18:19 -0800 Subject: [PATCH 11/18] Add dockerhub auth --- deployment/publish.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deployment/publish.sh b/deployment/publish.sh index 4f16ee6..98625d4 100755 --- a/deployment/publish.sh +++ b/deployment/publish.sh @@ -10,6 +10,9 @@ set -e echo "Now deploying moldesign-${CI_BRANCH}" +docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD} + + # Copy python package out of the docker image sdist=moldesign-${CI_BRANCH}.tar.gz docker run -v ${PWD}/tmp/dist:/hostdists moldesign_py_build:dev cp dist/${sdist} /hostdists From 43baaf3298c036b06607133639d05427827492a5 Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Mon, 4 Dec 2017 10:04:44 -0800 Subject: [PATCH 12/18] Add missing tag --- codeship-steps.yml | 2 +- deployment/push-and-tag.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/codeship-steps.yml b/codeship-steps.yml index 7bac42a..8cb5feb 100644 --- a/codeship-steps.yml +++ b/codeship-steps.yml @@ -48,7 +48,7 @@ steps: - name: push-artifacts command: deployment/push-and-tag.sh - moldesign_minimal moldesign_py2 moldesign_py_build + moldesign_minimal moldesign_minimal_py2 moldesign_py_build moldesign_complete moldesign_complete_py2 service: publisher - type: serial diff --git a/deployment/push-and-tag.sh b/deployment/push-and-tag.sh index 9046c4e..9655ec6 100755 --- a/deployment/push-and-tag.sh +++ b/deployment/push-and-tag.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + if [ -z ${CI_BRANCH} ]; then echo "\$CI_BRANCH" var not set. exit 1 From e30a97508499c16584a4e20a1b29d8530c4bf2a7 Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Mon, 4 Dec 2017 10:51:14 -0800 Subject: [PATCH 13/18] Install twine, add option for skipping tests --skip-ci-tests --- deployment/build-env.dockerfile | 3 ++- deployment/run-ci-tests.sh | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/deployment/build-env.dockerfile b/deployment/build-env.dockerfile index 467efb0..9252040 100644 --- a/deployment/build-env.dockerfile +++ b/deployment/build-env.dockerfile @@ -11,6 +11,7 @@ RUN curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-17.04.0-ce.tgz && rm -r docker docker-17.04.0-ce.tgz ADD ./DockerMakefiles/requirements.txt /tmp/reqs.txt -RUN pip install -r /tmp/reqs.txt && pip install coveralls +RUN pip install -r /tmp/reqs.txt \ + && pip install coveralls twine ADD . /opt/molecular-design-toolkit diff --git a/deployment/run-ci-tests.sh b/deployment/run-ci-tests.sh index aa7a01e..f0e8668 100755 --- a/deployment/run-ci-tests.sh +++ b/deployment/run-ci-tests.sh @@ -32,6 +32,11 @@ function send_status_update(){ function check_if_tests_should_run(){ echo "Should I run the tests in this environment?" + if [[ "${CI_COMMIT_MESSAGE}" == *"--skip-ci-tests"* ]]; then + echo "NO: found \"--skip-ci-tests\" flag in commit message; will not run any test suites" + exit 0 + fi + 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" exit 0 From 32c238f58fbb908442780da2d01dc12da27876f8 Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Mon, 4 Dec 2017 15:20:24 -0800 Subject: [PATCH 14/18] Ignore missing coverage files if tests skipped --- deployment/push-coverage.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/deployment/push-coverage.sh b/deployment/push-coverage.sh index 05de8e8..14202fe 100755 --- a/deployment/push-coverage.sh +++ b/deployment/push-coverage.sh @@ -6,6 +6,8 @@ set -e mkdir -p /opt/reports/env-coverage cp /opt/reports/env-coverage/coverage.* /opt/reports/ -coverage combine /opt/reports/coverage.* \ - && coveralls \ - || echo "Failed to upload coverage to coveralls.io" \ No newline at end of file +if $(coverage combine /opt/reports/coverage.*); then + coveralls || echo "Failed to upload coverage to coveralls.io" +else + echo "No coverage files found, skipping coveralls upload" +fi From bc2826dd1fb44611c8ffb3f1bc1934b86c906d8a Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Mon, 4 Dec 2017 16:04:44 -0800 Subject: [PATCH 15/18] Correct leaks in sanity --skip-ci-tests --- deployment/publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/publish.sh b/deployment/publish.sh index 98625d4..7841dc8 100755 --- a/deployment/publish.sh +++ b/deployment/publish.sh @@ -29,4 +29,4 @@ done # Push python package to PyPI echo "Uploading version ${CI_BRANCH} to PyPI:" -twine upload -u ${PYPI_USER} -p ${PYPI_PASSWORD} ./tmp/dists/moldesign-${CI_BRANCH}.tar.gz +twine upload -u ${PYPI_USER} -p ${PYPI_PASSWORD} ./tmp/dist/moldesign-${CI_BRANCH}.tar.gz From 3ce8e27ba6ec5b1f33e4239262f32c6a737ee7f6 Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Mon, 4 Dec 2017 16:08:58 -0800 Subject: [PATCH 16/18] Rename commit message flags to avoid clashes --- deployment/run-ci-tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/run-ci-tests.sh b/deployment/run-ci-tests.sh index f0e8668..a832708 100755 --- a/deployment/run-ci-tests.sh +++ b/deployment/run-ci-tests.sh @@ -32,12 +32,12 @@ function send_status_update(){ function check_if_tests_should_run(){ echo "Should I run the tests in this environment?" - if [[ "${CI_COMMIT_MESSAGE}" == *"--skip-ci-tests"* ]]; then + if [[ "${CI_COMMIT_MESSAGE}" == *"--no-tests"* ]]; then echo "NO: found \"--skip-ci-tests\" flag in commit message; will not run any test suites" exit 0 fi - if [[ "${CI_COMMIT_MESSAGE}" == *"--fast-ci-tests"* && "${VERSION}" != "complete.py3" ]]; then + if [[ "${CI_COMMIT_MESSAGE}" == *"--fast-tests"* && "${VERSION}" != "complete.py3" ]]; then echo "NO: found \"--fast-ci-tests\" flag in commit message; run complete.py3 only" exit 0 fi From 37e6035665fdba5ab4ef78ef3179394ebdfc800c Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Tue, 5 Dec 2017 18:08:32 -0800 Subject: [PATCH 17/18] Fix coverage pusher better --- deployment/push-coverage.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/deployment/push-coverage.sh b/deployment/push-coverage.sh index 14202fe..214da24 100755 --- a/deployment/push-coverage.sh +++ b/deployment/push-coverage.sh @@ -4,9 +4,8 @@ set -e mkdir -p /opt/reports/env-coverage -cp /opt/reports/env-coverage/coverage.* /opt/reports/ - -if $(coverage combine /opt/reports/coverage.*); then +if $(cp /opt/reports/env-coverage/coverage.* /opt/reports/); then + coverage combine /opt/reports/coverage.* coveralls || echo "Failed to upload coverage to coveralls.io" else echo "No coverage files found, skipping coveralls upload" From fd2b0f0f7230424474365f46291b21570ac01981 Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Tue, 5 Dec 2017 19:07:02 -0800 Subject: [PATCH 18/18] Really copy the sdist correctly --- codeship-services.yml | 2 ++ deployment/publish.sh | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/codeship-services.yml b/codeship-services.yml index dc731cd..62dc1d5 100644 --- a/codeship-services.yml +++ b/codeship-services.yml @@ -21,6 +21,8 @@ publisher: <<: *build-base cached: false encrypted_env_file: ./deployment/deploy-tokens.crypt + volumes: + - ./tmp/dist:/opt/dist test_moldesign_minimal: &test-base diff --git a/deployment/publish.sh b/deployment/publish.sh index 7841dc8..85ba9f8 100755 --- a/deployment/publish.sh +++ b/deployment/publish.sh @@ -15,7 +15,7 @@ docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD} # Copy python package out of the docker image sdist=moldesign-${CI_BRANCH}.tar.gz -docker run -v ${PWD}/tmp/dist:/hostdists moldesign_py_build:dev cp dist/${sdist} /hostdists +docker run moldesign_py_build:dev cat dist/${sdist} > /opt/dist/${sdist} # Push images to dockerhub for img in moldesign_minimal \ @@ -29,4 +29,4 @@ done # Push python package to PyPI echo "Uploading version ${CI_BRANCH} to PyPI:" -twine upload -u ${PYPI_USER} -p ${PYPI_PASSWORD} ./tmp/dist/moldesign-${CI_BRANCH}.tar.gz +twine upload -u ${PYPI_USER} -p ${PYPI_PASSWORD} /opt/dist/${sdist}