From d7e619b72a20acec686305593227597e3e4a7b0f Mon Sep 17 00:00:00 2001 From: Aaron Virshup Date: Tue, 28 Nov 2017 23:22:11 -0800 Subject: [PATCH] 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} }