From e1d822fbe1d5b1399d1d2eb14ed29e4c5c42c46b Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Wed, 13 May 2020 22:26:21 -0500 Subject: clean up travis and fix coverage --- .travis.yml | 96 +++++++++++++++---------------------------------------------- 1 file changed, 23 insertions(+), 73 deletions(-) diff --git a/.travis.yml b/.travis.yml index b941f4c..e0f4340 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,11 +19,6 @@ install: # do the rest of the image setup - ./.travis/install.sh -# run coverage first as its still useful to collect -stages: - - Coverage - - Test - # Note: Travis does not provide a way to specify the order of # jobs within a Stage, which are "run in parallel", but with # limitations: from observation four or five are kicked @@ -41,106 +36,61 @@ jobs: # allow coverage to fail, so we can still do testing for all platforms allow_failures: - python: pypy3 - - stage: Coverage + include: - &test_job - stage: Test script: python runtest.py -a -t -j 2 || if [[ $? == 2 ]]; then true; else false; fi before_script: skip after_success: skip python: pypy3 - env: - - PYVER=pypy3 - - PYTHON=pypy3 - <<: *test_job python: 3.5 - env: - - PYVER=35 - - PYTHON=3.5 - <<: *test_job python: 3.6 - env: - - PYVER=36 - - PYTHON=3.6 - + - <<: *test_job python: 3.7 - env: - - PYVER=37 - - PYTHON=3.7 dist: xenial # required for Python >= 3.7 - <<: *test_job python: 3.8 - env: - - PYVER=38 - - PYTHON=3.8 dist: bionic # required for Python >= 3.8 - - &coverage_jobs - stage: Coverage dist: bionic python: 3.7 before_script: - # install our own python so we can modify usercustomize.py -# - deactivate -# - sudo add-apt-repository -y ppa:deadsnakes/ppa -# - sudo apt-get update || true -# - sudo apt-get -y install python$PYTHON -# - wget https://bootstrap.pypa.io/get-pip.py -# - sudo -H python$PYTHON get-pip.py - - which python - - python --version - python -m pip install -U coverage codecov - # set this ensure user sites are available - - export PYTHONNOUSERSITE= - # attempt to get a location where we can store the usercustomize.py file - python -m site -# - export PYSITEDIR=$(python -m site --user-site) + # setup sitecustomize so we can make all subprocess start coverage - export PYSITEDIR=$(python -c "import sys; print(sys.path[-1])") - - mkdir -p $PYSITEDIR - - export COVERAGE_FILE=$PWD/.coverage - # write the usercustomize.py file so all python processes use coverage and know where the config file is - - echo "import os" | tee --append ${PYSITEDIR}/sitecustomize.py - - echo "os.environ['COVERAGE_PROCESS_START'] = '$PWD/.coveragerc'" | tee --append ${PYSITEDIR}/sitecustomize.py - - echo "import coverage" | tee --append ${PYSITEDIR}/sitecustomize.py - - echo "coverage.process_startup()" | tee --append ${PYSITEDIR}/sitecustomize.py + - export COVERAGE_PROCESS_START="$PWD/.coveragerc" + - mkdir -p "$PYSITEDIR" + - echo "$PYSITEDIR" + - touch "${PYSITEDIR}/sitecustomize.py" + - echo "import os" | tee --append "${PYSITEDIR}/sitecustomize.py" + - echo "os.environ['COVERAGE_PROCESS_START'] = '$PWD/.coveragerc'" | tee --append "${PYSITEDIR}/sitecustomize.py" + - echo "import coverage" | tee --append "${PYSITEDIR}/sitecustomize.py" + - echo "coverage.process_startup()" | tee --append "${PYSITEDIR}/sitecustomize.py" + - cat "${PYSITEDIR}/sitecustomize.py" + # write the coverage config file + - echo "[run]" >> "$PWD/.coveragerc" + - echo "source = $PWD/SCons" >> "$PWD/.coveragerc" + - echo "parallel = True" >> "$PWD/.coveragerc" + - printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> "$PWD/.coveragerc" + - echo "[path]" >> "$PWD/.coveragerc" + - echo "source = $PWD" >> "$PWD/.coveragerc" + - echo "[report]" >> "$PWD/.coveragerc" + - printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> "$PWD/.coveragerc" + - cat "$PWD/.coveragerc" script: - - export TOTAL_BUILD_JOBS=1 - # write the coverage config file - - export COVERAGE_PROCESS_START=$PWD/.coveragerc - - echo "[run]" >> .coveragerc - - echo "source = $PWD/src" >> .coveragerc - - echo "parallel = True" >> .coveragerc - - printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> .coveragerc - - echo "[path]" >> .coveragerc - - echo "source = $PWD" >> .coveragerc - - echo "[report]" >> .coveragerc - - printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> .coveragerc - # get a list of all the tests to split them up - - python runtest.py -l -a > all_tests - - let "start = ($(wc -l < all_tests) / ${TOTAL_BUILD_JOBS}) * (${BUILD_JOB_NUM} - 1)"; true; - - let "end = ($(wc -l < all_tests) / ${TOTAL_BUILD_JOBS}) * ${BUILD_JOB_NUM}" - - if (( ${BUILD_JOB_NUM} == ${TOTAL_BUILD_JOBS} )); then end=$(wc -l < all_tests); fi - - if (( ${start} == 0 )); then start=1; fi - - sed -n ${start},${end}p all_tests > build_tests - - coverage run -p --rcfile=$PWD/.coveragerc runtest.py -f build_tests -j 2 || if [[ $? == 2 ]]; then true; else false; fi + - coverage run -p --rcfile="$PWD/.coveragerc" runtest.py -a -j 2 || if [[ $? == 2 ]]; then true; else false; fi after_script: - coverage combine - coverage report - coverage xml -o coverage_xml.xml - codecov -X gcov --file coverage_xml.xml - # not using coveralls but leaving it commented to - # make it easy to re-enable - #- python$PYTHON -m pip install --user -U coveralls - #- coveralls --rcfile=$PWD/.coveragerc - - env: - - PYVER=37 - - PYTHON=3.7 - - BUILD_JOB_NUM=1 -- cgit v0.12 From 4ccb6e88d4d8b25a43f230b21794168457f332f1 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Wed, 13 May 2020 22:56:30 -0500 Subject: give coverage a name --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e0f4340..1a632d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,6 +61,7 @@ jobs: - &coverage_jobs dist: bionic python: 3.7 + name: coverage before_script: - python -m pip install -U coverage codecov - python -m site -- cgit v0.12 From 186dea47a09857884c1447379326d304f0ff97cd Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Wed, 13 May 2020 23:12:31 -0500 Subject: clean up coveragerc file --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1a632d1..d2f06be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -80,11 +80,11 @@ jobs: - echo "[run]" >> "$PWD/.coveragerc" - echo "source = $PWD/SCons" >> "$PWD/.coveragerc" - echo "parallel = True" >> "$PWD/.coveragerc" - - printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> "$PWD/.coveragerc" + - echo "omit = *Tests.py" >> "$PWD/.coveragerc" - echo "[path]" >> "$PWD/.coveragerc" - echo "source = $PWD" >> "$PWD/.coveragerc" - echo "[report]" >> "$PWD/.coveragerc" - - printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> "$PWD/.coveragerc" + - echo "omit = *Tests.py" >> "$PWD/.coveragerc" - cat "$PWD/.coveragerc" script: -- cgit v0.12