Skip to content

Commit

Permalink
Combine coverage from all environments
Browse files Browse the repository at this point in the history
  • Loading branch information
avirshup committed Nov 29, 2017
1 parent 70c794b commit d7e619b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[paths]
source =
moldesign

*/moldesign

[run]
source = moldesign
Expand Down
8 changes: 8 additions & 0 deletions codeship-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 8 additions & 14 deletions codeship-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions deployment/build-env.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions deployment/push-coverage.sh
Original file line number Diff line number Diff line change
@@ -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"
23 changes: 9 additions & 14 deletions deployment/run-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down Expand Up @@ -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}
}

Expand Down

0 comments on commit d7e619b

Please sign in to comment.