Skip to content

Commit

Permalink
Get tests up and running in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
avirshup committed Nov 9, 2017
1 parent 0c6d660 commit 135e62b
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 92 deletions.
3 changes: 2 additions & 1 deletion DockerMakefiles/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DockerMake >= 0.6.1a1
DockerMake >= 0.6.1a2
shyaml
47 changes: 19 additions & 28 deletions codeship-services.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_base: &build-base
image_builder:
build:
context: .
dockerfile: ./deployment/build-env.dockerfile
Expand All @@ -8,37 +8,19 @@ build_base: &build-base
cached: true
environment:
chemdocker_tag: 0.9.0rc5

python_builder:
<<: *build-base
working_dir: /opt/molecular-design-toolkit

image_builder:
<<: *build-base
working_dir: /opt/molecular-design-toolkit/DockerMakefiles


publisher:
<<: *build-base
working_dir: /opt/molecular-design-toolkit
encrypted_env_file: deployment/tokens.crypt
add_docker: true
working_dir: /opt/molecular-design-toolkit
volumes:
- ./tmp/reports:/opt/reports


test_base: &test-base
image: dummy
test_moldesign_minimal: &test-base
working_dir: /opt/molecular-design-toolkit/
add_docker: true
volumes:
- ./tmp/reports:/opt/reports


test_moldesign_minimal:
<<: *test-base
image: moldesign_minimal:dev
build: &test-build-base
context: ./
dockerfile: deployment/test-env.dockerfile
args:
baseimage: moldesign_minimal
environment:
TESTENV: minimal
PYVERSION: 3
Expand All @@ -47,7 +29,10 @@ test_moldesign_minimal:

test_moldesign_minimal_py2:
<<: *test-base
image: moldesign_minimal_py2:dev
build:
<<: *test-build-base
args:
baseimage: moldesign_minimal_py2
environment:
TESTENV: minimal
PYVERSION: 2
Expand All @@ -56,7 +41,10 @@ test_moldesign_minimal_py2:

test_moldesign_complete:
<<: *test-base
image: moldesign_complete:dev
build:
<<: *test-build-base
args:
baseimage: moldesign_complete
environment:
TESTENV: complete
PYVERSION: 3
Expand All @@ -65,7 +53,10 @@ test_moldesign_complete:

test_moldesign_complete_py2:
<<: *test-base
image: moldesign_complete_py2:dev
build:
<<: *test-build-base
args:
baseimage: moldesign_complete_py2
environment:
TESTENV: complete
PYVERSION: 2
Expand Down
78 changes: 34 additions & 44 deletions codeship-steps.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,56 @@
- name: pull-cache
service: image_builder
command: ../deployment/pull-cache.sh
command: deployment/pull-cache.sh

- name: build-sdist
service: image_builder
command: docker-make --tag dev moldesign_py_build
command: docker-make moldesign_py_build
--keep-build-tags
-f DockerMakefiles/DockerMake.yml --tag dev

- name: build_and_pull_images
service: image_builder
type: parallel
steps:
- name: pull-dependent-images
command: ../deployment/pull-chemdocker.sh
- type: serial
steps:
- name: build_py3
command:
docker-make moldesign_minimal moldesign_complete
--tag dev --keep-build-tags
--cache-repo moldesign --cache-tag cache
steps:
- name: build_py2
command:
docker-make moldesign_minimal_py2 moldesign_complete_py2
--tag dev --keep-build-tags
--cache-repo moldesign --cache-tag cache
command: deployment/pull-chemdocker.sh
- name: build_py3
command:
docker-make moldesign_minimal moldesign_complete moldesign_notebook
-f DockerMakefiles/DockerMake.yml
--tag dev --keep-build-tags
--cache-repo moldesign --cache-tag cache
- name: build_py2
command:
docker-make moldesign_minimal_py2 moldesign_complete_py2
-f DockerMakefiles/DockerMake.yml
--tag dev --keep-build-tags
--cache-repo moldesign --cache-tag cache

- name: push_images
service: image_builder
command: deployment/push.sh

- name: print_environments
type: parallel
type: serial
services:
- test_moldesign_complete
- test_moldesign_complete_py2
- test_moldesign_minimal
- test_moldesign_minimal_py2
steps:
- command: deployment/print_environment.sh

- name: run_tests
services:
- test_moldesign_complete
- test_moldesign_complete_py2
- test_moldesign_minimal
- test_moldesign_minimal_py2
- test_moldesign_minimal
steps:
- command: ../deployment/print_environment.sh

- service: test_moldesign_complete
name: test_moldesign_complete
command: deployment/codeship_runtests.sh

- service: test_moldesign_complete_py2
name: test_moldesign_complete_py2
command: deployment/codeship_runtests.sh

- service: test_moldesign_minimal
name: test_moldesign_minimal
command: deployment/codeship_runtests.sh

- service: test_moldesign_minimal_py2
name: test_moldesign_minimal_py2
command: deployment/codeship_runtests.sh

- service: image_builder
command: docker-make --tag dev moldesign_notebook --cache-repo moldesign --cache-tag cache
name: build-notebook

- name: push
service: publisher
command: deployment/push.sh
- command: deployment/codeship_runtests.sh

- name: publish
- name: publish_python
service: publisher
# 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*))?$'
Expand Down
5 changes: 2 additions & 3 deletions deployment/codeship_runtests.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env bash
# this script expects to run from the root of the repository

set -e # fail immediately if any command fails


VERSION="${TESTENV}.py${PYVERSION}"
PYTESTFLAGS="-n 3 --spec --durations=20 --junit-xml=/opt/reports/junit.${VERSION}.xml --timeout=3600 --tb=short"
if [ "${VERSION}" == "complete.py3" ]; then
Expand Down Expand Up @@ -59,7 +57,8 @@ function run_tests(){
echo "py.test ${PYTESTFLAGS}"
echo

py.test ${PYTESTFLAGS} | tee /opt/reports/pytest.${VERSION}.log
cd tests && \
py.test ${PYTESTFLAGS} | tee /opt/reports/pytest.${VERSION}.log
exitstat=${PIPESTATUS[0]}

statline="$(tail -n1 /opt/reports/pytest.${VERSION}.log)"
Expand Down
14 changes: 2 additions & 12 deletions deployment/print_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,12 @@ echo " * Python interpreter: $(python -c "import sys; print(sys.version)")"
echo
echo " * Conda version: $(conda --version 2>/dev/null || echo 'not installed')"
echo
echo " * Missing optional interfaces:"

# This will print logging messages about optional interfaces
plats=$(python -c "import moldesign;
if not moldesign.interfaces.openmm.force_remote: print(moldesign.interfaces.openmm.list_openmmplatforms())"
)

if [ "$?" != "0" ]; then
plats="None (OpenMM not installed)"
fi

echo
echo " * OpenMM platforms:"
echo ${plats}
python -c "import moldesign; moldesign.compute.packages.print_env()"
echo
echo " * Conda environment: $(conda list 2>/dev/null || echo "not installed")"
echo
echo " * Installed python packages: "
pip freeze

2 changes: 1 addition & 1 deletion deployment/pull-cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function run-pull(){
}

# we copy binaries out of this one for our build
echocmd docker pull chemdocker/pyscf-build-1.3.1:0.9.0rc5:${chemdocker_tag}
echocmd docker pull chemdocker/pyscf-build-1.3.1:${chemdocker_tag} | tee -a pull.log | egrep -i 'pull|already';

for img in moldesign_minimal \
moldesign_minimal_py2 \
Expand Down
9 changes: 7 additions & 2 deletions deployment/push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

if [ -z ${CI_BRANCH} ]; then
echo "\$CI_BRANCH" var not set.
exit 10
exit 1
fi

if [ -z ${DOCKERHUB_USER} ] || [ -z ${DOCKERHUB_PASSWORD} ]; then
echo "Dockerhub credentials not provided. Skipping push ..."
exit 0
fi

function echocmd() {
Expand All @@ -15,7 +20,7 @@ imgs=$(cat DockerMakefiles/DockerMake.yml | shyaml get-values _ALL_)
docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD}

for img in ${imgs}; do
remote_img=autodesk/moldesign:${img}-${CI_BRANCH}
remote_img=autodesk/moldesign:${img}-${CI_BRANCH}-devbuild

echocmd docker tag ${img}:dev ${remote_img}
echocmd docker push ${remote_img} | tee -a push.log | egrep -i 'push|already';
Expand Down
7 changes: 7 additions & 0 deletions deployment/test-env.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# For building test images
ARG baseimage
FROM ${baseimage}:dev
ADD ./deployment /opt/molecular-design-toolkit/deployment
ADD ./moldesign/_tests /opt/molecular-design-toolkit/tests
RUN pip install -r /opt/molecular-design-toolkit/deployment/requirements.txt
WORKDIR /opt/molecular-design-toolkit
17 changes: 16 additions & 1 deletion moldesign/compute/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def installed_version(self):
return None

def is_installed(self):
if self.path is None:
if not self.path:
return False

return os.path.exists(self.path)
Expand Down Expand Up @@ -279,4 +279,19 @@ def _getimage(name):
executables = [nwchem, opsin, nab, symmol, tleap, antechamber]


def print_env():
print(' * Interfaces: ')
for pkg in packages:
if pkg.is_installed():
print(' %s: installed' % pkg.name)
else:
print(' %s: not found' % pkg.name)

print('\n * Executables:')
for exe in executables:
if exe.is_installed():
print(' %s: installed' % exe.name)
else:
print(' %s: not found' % exe.name)

__all__ = [x.name for x in packages + executables]

0 comments on commit 135e62b

Please sign in to comment.