Skip to content

Commit

Permalink
Streamline coverage upload script
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Bainian <[email protected]>

Abstract python pip installation


install setup tool as well
  • Loading branch information
Briancbn committed Dec 16, 2020
1 parent d268fde commit ef8a320
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 49 deletions.
11 changes: 0 additions & 11 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,4 @@ DIR_THIS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export TARGET_REPO_PATH=${TARGET_REPO_PATH:-$(pwd)}
export TARGET_REPO_NAME=${TARGET_REPO_NAME:-${TARGET_REPO_PATH##*/}}

function upload_coverage_report {
case "$CODE_COVERAGE" in
"coveralls.io")
sudo apt install -qq -y python3-pip python3-setuptools python3-dev python3-wheel
python3 -m pip install --user coveralls
python3 -m coveralls --merge=.ici_coverage_report/coverage.json
;;
esac
}

env "$@" bash "$DIR_THIS/industrial_ci/src/ci_main.sh"
"$@" upload_coverage_report
1 change: 0 additions & 1 deletion gitlab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ if [ -n "$SSH_PRIVATE_KEY" ]; then
fi

env "$@" bash "$DIR_THIS/industrial_ci/src/ci_main.sh"
PATH="$PATH:$HOME/.local/bin" env "$@" bash "$DIR_THIS"/industrial_ci/src/upload_coverage_report.sh
4 changes: 4 additions & 0 deletions industrial_ci/src/ci_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ fi

ici_hook "after_script"

if [ -n "$CODE_COVERAGE" ] && [ "$IN_DOCKER" = false ]; then
ici_run "upload_coverage_report" upload_coverage_report
fi

ici_exit 0
38 changes: 38 additions & 0 deletions industrial_ci/src/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,41 @@ function ici_collect_coverage_report {
;;
esac
}

function upload_coverage_report {
case "$CODE_COVERAGE" in
"codecov.io")
bash <(curl -s https://codecov.io/bash) -Z
;;
"coveralls.io")
# Check pip/pip3 installation (prioritize using python3)
local PYTHON_VERSION
if command -v python3 &> /dev/null; then
if ! command -v pip3 &> /dev/null; then
ici_warn "pip3 not found. Try installing pip3..."
ici_apt_install python3-pip
fi
# Check setuptools installation
if ! pip3 show setuptools &> /dev/null; then
ici_warn "pip3 setup_tools not found. Try installing pip3 setup_tools..."
ici_apt_install python3-setuptools python3-dev python3-wheel
fi
PYTHON_VERSION=3
elif command -v python &> /dev/null; then
if ! command -v pip &> /dev/null; then
ici_warn "pip not found. Try installing pip3..."
ici_apt_install python-pip
fi
# Check setuptools installation
if ! pip show setuptools &> /dev/null; then
ici_warn "pip setup_tools not found. Try installing pip setup_tools..."
ici_apt_install python-setuptools python-dev python-wheel
fi
fi

python"$PYTHON_VERSION" -m pip install --user --upgrade pip
python"$PYTHON_VERSION" -m pip install --user coveralls
python"$PYTHON_VERSION" -m coveralls --merge=.ici_coverage_report/coverage.json
;;
esac
}
34 changes: 0 additions & 34 deletions industrial_ci/src/upload_coverage_report.sh

This file was deleted.

3 changes: 0 additions & 3 deletions travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,3 @@ function watch_output() {

set -o pipefail
env "$@" stdbuf -oL -eL bash "$DIR_THIS"/industrial_ci/src/ci_main.sh |& watch_output
if [ -n "$CODE_COVERAGE" ]; then
bash "$DIR_THIS"/industrial_ci/src/upload_coverage_report.sh
fi

0 comments on commit ef8a320

Please sign in to comment.