Skip to content

Commit

Permalink
[ci] ensure shell script exit codes are in range 0-255
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Feb 8, 2024
1 parent 7435cd8 commit 50af277
Show file tree
Hide file tree
Showing 27 changed files with 182 additions and 182 deletions.
4 changes: 2 additions & 2 deletions .ci/append_comment.sh
Expand Up @@ -14,12 +14,12 @@ set -e

if [ -z "$GITHUB_ACTIONS" ]; then
echo "Must be run inside GitHub Actions CI"
exit -1
exit 1
fi

if [ $# -ne 2 ]; then
echo "Usage: $0 <COMMENT_ID> <BODY>"
exit -1
exit 1
fi

comment_id=$1
Expand Down
12 changes: 6 additions & 6 deletions .ci/check_python_dists.sh
Expand Up @@ -7,14 +7,14 @@ echo "checking Python package distributions in '${DIST_DIR}'"
pip install \
-qq \
check-wheel-contents \
twine || exit -1
twine || exit 1

echo "twine check..."
twine check --strict ${DIST_DIR}/* || exit -1
twine check --strict ${DIST_DIR}/* || exit 1

if { test "${TASK}" = "bdist" || test "${METHOD}" = "wheel"; }; then
echo "check-wheel-contents..."
check-wheel-contents ${DIST_DIR}/*.whl || exit -1
check-wheel-contents ${DIST_DIR}/*.whl || exit 1
fi

PY_MINOR_VER=$(python -c "import sys; print(sys.version_info.minor)")
Expand All @@ -27,22 +27,22 @@ if [ $PY_MINOR_VER -gt 7 ]; then
--ignore 'compiled-objects-have-debug-symbols,distro-too-large-compressed' \
--max-allowed-size-uncompressed '100M' \
--max-allowed-files 800 \
${DIST_DIR}/* || exit -1
${DIST_DIR}/* || exit 1
elif { test $(uname -m) = "aarch64"; }; then
pydistcheck \
--inspect \
--ignore 'compiled-objects-have-debug-symbols' \
--max-allowed-size-compressed '5M' \
--max-allowed-size-uncompressed '15M' \
--max-allowed-files 800 \
${DIST_DIR}/* || exit -1
${DIST_DIR}/* || exit 1
else
pydistcheck \
--inspect \
--max-allowed-size-compressed '5M' \
--max-allowed-size-uncompressed '15M' \
--max-allowed-files 800 \
${DIST_DIR}/* || exit -1
${DIST_DIR}/* || exit 1
fi
else
echo "skipping pydistcheck (does not support Python 3.${PY_MINOR_VER})"
Expand Down
4 changes: 2 additions & 2 deletions .ci/install_opencl.ps1
Expand Up @@ -12,7 +12,7 @@ if (Test-Path "$installer") {
Write-Output "Unable to download OpenCL platform installer"
Write-Output "Setting EXIT"
$host.SetShouldExit(-1)
Exit -1
exit 1
}

# Install OpenCL platform from installer executable
Expand All @@ -26,7 +26,7 @@ if ($property -eq $null) {
Get-Content "opencl.log"
Write-Output "Setting EXIT"
$host.SetShouldExit(-1)
Exit -1
exit 1
} else {
Write-Output "Successfully installed OpenCL CPU platform"
Write-Output "Current OpenCL drivers:"
Expand Down
6 changes: 3 additions & 3 deletions .ci/lint-cpp.sh
Expand Up @@ -4,7 +4,7 @@ echo "running cpplint"
cpplint \
--filter=-build/c++11,-build/include_subdir,-build/header_guard,-whitespace/line_length \
--recursive ./src ./include ./R-package ./swig ./tests \
|| exit -1
|| exit 1
echo "done running cpplint"

echo "running cmakelint"
Expand All @@ -16,7 +16,7 @@ cmakelint \
--linelength=120 \
--filter=-convention/filename,-package/stdargs,-readability/wonkycase \
${cmake_files} \
|| exit -1
|| exit 1
echo "done running cmakelint"

echo "checking that all OpenMP pragmas specify num_threads()"
Expand All @@ -39,6 +39,6 @@ if test "${PROBLEMATIC_LINES}" != ""; then
get_omp_pragmas_without_num_threads
echo "Found '#pragma omp parallel' not using explicit num_threads() configuration. Fix those."
echo "For details, see https://www.openmp.org/spec-html/5.0/openmpse14.html#x54-800002.6"
exit -1
exit 1
fi
echo "done checking OpenMP pragmas"
4 changes: 2 additions & 2 deletions .ci/lint-python.sh
Expand Up @@ -4,15 +4,15 @@ echo "running ruff"
ruff check \
--config=./python-package/pyproject.toml \
. \
|| exit -1
|| exit 1
echo "done running ruff"

echo "running isort"
isort \
--check-only \
--settings-path=./python-package/pyproject.toml \
. \
|| exit -1
|| exit 1
echo "done running isort"

echo "running mypy"
Expand Down
4 changes: 2 additions & 2 deletions .ci/rerun_workflow.sh
Expand Up @@ -16,12 +16,12 @@ set -e

if [ -z "$GITHUB_ACTIONS" ]; then
echo "Must be run inside GitHub Actions CI"
exit -1
exit 1
fi

if [ $# -ne 3 ]; then
echo "Usage: $0 <WORKFLOW_ID> <PR_NUMBER> <PR_BRANCH>"
exit -1
exit 1
fi

workflow_id=$1
Expand Down
4 changes: 2 additions & 2 deletions .ci/set_commit_status.sh
Expand Up @@ -18,12 +18,12 @@ set -e

if [ -z "$GITHUB_ACTIONS" ]; then
echo "Must be run inside GitHub Actions CI"
exit -1
exit 1
fi

if [ $# -ne 3 ]; then
echo "Usage: $0 <NAME> <STATUS> <SHA>"
exit -1
exit 1
fi

name=$1
Expand Down
12 changes: 6 additions & 6 deletions .ci/setup.sh
Expand Up @@ -4,10 +4,10 @@ if [[ $OS_NAME == "macos" ]]; then
if [[ $COMPILER == "clang" ]]; then
brew install libomp
if [[ $AZURE == "true" ]]; then
sudo xcode-select -s /Applications/Xcode_11.7.app/Contents/Developer || exit -1
sudo xcode-select -s /Applications/Xcode_11.7.app/Contents/Developer || exit 1
fi
else # gcc
sudo xcode-select -s /Applications/Xcode_14.1.app/Contents/Developer || exit -1
sudo xcode-select -s /Applications/Xcode_14.1.app/Contents/Developer || exit 1
if [[ $TASK != "mpi" ]]; then
brew install gcc
fi
Expand Down Expand Up @@ -49,7 +49,7 @@ else # Linux
locales-all \
netcat \
unzip \
zip || exit -1
zip || exit 1
if [[ $COMPILER == "clang" ]]; then
sudo apt-get install --no-install-recommends -y \
clang \
Expand Down Expand Up @@ -82,7 +82,7 @@ else # Linux
sudo yum update -y
sudo yum install -y \
openmpi-devel \
|| exit -1
|| exit 1
fi
fi
if [[ $TASK == "gpu" ]]; then
Expand All @@ -98,7 +98,7 @@ else # Linux
boost-devel \
ocl-icd-devel \
opencl-headers \
|| exit -1
|| exit 1
fi
fi
if [[ $TASK == "gpu" || $TASK == "bdist" ]]; then
Expand All @@ -111,7 +111,7 @@ else # Linux
sudo yum install -y \
ocl-icd-devel \
opencl-headers \
|| exit -1
|| exit 1
fi
fi
if [[ $TASK == "cuda" ]]; then
Expand Down
12 changes: 6 additions & 6 deletions .ci/test-python-oldest.sh
Expand Up @@ -14,11 +14,11 @@ pip install \
'pyarrow==6.0.1' \
'scikit-learn==0.18.2' \
'scipy==0.19.0' \
|| exit -1
|| exit 1
echo "done installing lightgbm's dependencies"

echo "installing lightgbm"
pip install --no-deps dist/*.whl || exit -1
pip install --no-deps dist/*.whl || exit 1
echo "done installing lightgbm"

echo "installed package versions:"
Expand All @@ -31,22 +31,22 @@ echo "checking that examples run without error"
echo ""
echo "--- advanced_example.py ---"
echo ""
python ./examples/python-guide/advanced_example.py || exit -1
python ./examples/python-guide/advanced_example.py || exit 1

echo ""
echo "--- logistic_regression.py ---"
echo ""
python ./examples/python-guide/logistic_regression.py || exit -1
python ./examples/python-guide/logistic_regression.py || exit 1

echo ""
echo "--- simple_example.py ---"
echo ""
python ./examples/python-guide/simple_example.py || exit -1
python ./examples/python-guide/simple_example.py || exit 1

echo ""
echo "--- sklearn_example.py ---"
echo ""
python ./examples/python-guide/sklearn_example.py || exit -1
python ./examples/python-guide/sklearn_example.py || exit 1

echo ""
echo "done testing on oldest supported Python version"

0 comments on commit 50af277

Please sign in to comment.