Unverified Commit 98936155 authored by vnherdeiro's avatar vnherdeiro Committed by GitHub
Browse files

[ci] fix some shellcheck warnings in package-building scripts (#6641)



* Shellcheck compliance improvement (commit squashing)

* rolledback some sh files to address PR review

* Addressing comments on PR review

* Update docs/build-docs.sh

* checking gh login

* fixing cmakelint

* another fix to failing ci

* fixing linting ignoring files

* Fixing shellcheck issues on build-python and build-cran-package scripts

* Update build-cran-package.sh
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>

* Update build-cran-package.sh
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>

* Update build-cran-package.sh
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>

* Adressing PR comments

* fixing CI

* Update build-python.sh
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>

* Update build-python.sh
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>

* Update build-python.sh
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>

* Update build-python.sh
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>

* Update build-python.sh
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>

* fixing quotemark typo

* fix CI

* fix CI

* triggering new CI (scikit-learn dev has changed)

* adressing PR comments

* ignore warnings about BUILD_ARGS and PIP_INSTALL_ARGS

---------
Co-authored-by: default avatarvnherdeiro <vnherdeiro@github.com>
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>
parent 668bf5da
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
# # skip vignette building # # skip vignette building
# sh build-cran-package.sh --no-build-vignettes # sh build-cran-package.sh --no-build-vignettes
set -e -E -u set -e -u
# Default values of arguments # Default values of arguments
BUILD_VIGNETTES=true BUILD_VIGNETTES=true
...@@ -63,7 +63,7 @@ CURRENT_DATE=$(date +'%Y-%m-%d') ...@@ -63,7 +63,7 @@ CURRENT_DATE=$(date +'%Y-%m-%d')
# R packages cannot have versions like 3.0.0rc1, but # R packages cannot have versions like 3.0.0rc1, but
# 3.0.0-1 is acceptable # 3.0.0-1 is acceptable
LGB_VERSION=$(cat VERSION.txt | sed "s/rc/-/g") LGB_VERSION=$(head -1 ./VERSION.txt | sed "s/rc/-/g")
# move relevant files # move relevant files
cp -R R-package/* "${TEMP_R_DIR}" cp -R R-package/* "${TEMP_R_DIR}"
...@@ -91,10 +91,10 @@ mkdir -p "${EIGEN_R_DIR}" ...@@ -91,10 +91,10 @@ mkdir -p "${EIGEN_R_DIR}"
modules="Cholesky Core Dense Eigenvalues Geometry Householder Jacobi LU QR SVD" modules="Cholesky Core Dense Eigenvalues Geometry Householder Jacobi LU QR SVD"
for eigen_module in ${modules}; do for eigen_module in ${modules}; do
cp external_libs/eigen/Eigen/${eigen_module} "${EIGEN_R_DIR}/${eigen_module}" cp "external_libs/eigen/Eigen/${eigen_module}" "${EIGEN_R_DIR}/${eigen_module}"
if [ ${eigen_module} != "Dense" ]; then if [ "${eigen_module}" != "Dense" ]; then
mkdir -p "${EIGEN_R_DIR}/src/${eigen_module}/" mkdir -p "${EIGEN_R_DIR}/src/${eigen_module}/"
cp -R external_libs/eigen/Eigen/src/${eigen_module}/* "${EIGEN_R_DIR}/src/${eigen_module}/" cp -R "external_libs/eigen/Eigen/src/${eigen_module}"/* "${EIGEN_R_DIR}/src/${eigen_module}/"
fi fi
done done
...@@ -130,6 +130,7 @@ cd "${TEMP_R_DIR}" ...@@ -130,6 +130,7 @@ cd "${TEMP_R_DIR}"
# Rtools35 (used with R 3.6 on Windows) doesn't support C++17 # Rtools35 (used with R 3.6 on Windows) doesn't support C++17
LGB_CXX_STD="C++17" LGB_CXX_STD="C++17"
using_windows_and_r3=$( using_windows_and_r3=$(
# shellcheck disable=SC2016
Rscript -e 'cat(.Platform$OS.type == "windows" && R.version[["major"]] < 4)' Rscript -e 'cat(.Platform$OS.type == "windows" && R.version[["major"]] < 4)'
) )
if test "${using_windows_and_r3}" = "TRUE"; then if test "${using_windows_and_r3}" = "TRUE"; then
...@@ -142,7 +143,7 @@ cd "${TEMP_R_DIR}" ...@@ -142,7 +143,7 @@ cd "${TEMP_R_DIR}"
# not allow you to use compiler flag '-Wno-unknown-pragmas' or # not allow you to use compiler flag '-Wno-unknown-pragmas' or
# pragmas that suppress warnings. # pragmas that suppress warnings.
echo "Removing unknown pragmas in headers" echo "Removing unknown pragmas in headers"
for file in $(find . -name '*.h' -o -name '*.hpp' -o -name '*.cpp'); do find . \( -name '*.h' -o -name '*.hpp' -o -name '*.cpp' \) -exec \
sed \ sed \
-i.bak \ -i.bak \
-e 's/^.*#pragma clang diagnostic.*$//' \ -e 's/^.*#pragma clang diagnostic.*$//' \
...@@ -151,9 +152,7 @@ cd "${TEMP_R_DIR}" ...@@ -151,9 +152,7 @@ cd "${TEMP_R_DIR}"
-e 's/^.*#pragma region.*$//' \ -e 's/^.*#pragma region.*$//' \
-e 's/^.*#pragma endregion.*$//' \ -e 's/^.*#pragma endregion.*$//' \
-e 's/^.*#pragma warning.*$//' \ -e 's/^.*#pragma warning.*$//' \
"${file}" {} +
done
find . -name '*.h.bak' -o -name '*.hpp.bak' -o -name '*.cpp.bak' -exec rm {} \;
# 'processx' is listed as a 'Suggests' dependency in DESCRIPTION # 'processx' is listed as a 'Suggests' dependency in DESCRIPTION
# because it is used in install.libs.R, a file that is not # because it is used in install.libs.R, a file that is not
...@@ -164,7 +163,7 @@ cd "${TEMP_R_DIR}" ...@@ -164,7 +163,7 @@ cd "${TEMP_R_DIR}"
DESCRIPTION DESCRIPTION
echo "Cleaning sed backup files" echo "Cleaning sed backup files"
rm *.bak find . -name '*.bak' -exec rm {} \;
cd "${ORIG_WD}" cd "${ORIG_WD}"
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
# Install into user-specific instead of global site-packages directory. # Install into user-specific instead of global site-packages directory.
# Only used with 'install' command. # Only used with 'install' command.
set -e -E -u set -e -u
echo "building lightgbm" echo "building lightgbm"
...@@ -91,42 +91,42 @@ while [ $# -gt 0 ]; do ...@@ -91,42 +91,42 @@ while [ $# -gt 0 ]; do
# customized library paths # # customized library paths #
############################ ############################
--boost-dir|--boost-dir=*) --boost-dir|--boost-dir=*)
if [[ "$1" != *=* ]]; if echo "$1" | grep -q '^*=*$';
then shift; then shift;
fi fi
BOOST_DIR="${1#*=}" BOOST_DIR="${1#*=}"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.Boost_DIR='${BOOST_DIR}'" BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.Boost_DIR='${BOOST_DIR}'"
;; ;;
--boost-include-dir|--boost-include-dir=*) --boost-include-dir|--boost-include-dir=*)
if [[ "$1" != *=* ]]; if echo "$1" | grep -q '^*=*$';
then shift; then shift;
fi fi
BOOST_INCLUDE_DIR="${1#*=}" BOOST_INCLUDE_DIR="${1#*=}"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.Boost_INCLUDE_DIR='${BOOST_INCLUDE_DIR}'" BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.Boost_INCLUDE_DIR='${BOOST_INCLUDE_DIR}'"
;; ;;
--boost-librarydir|--boost-librarydir=*) --boost-librarydir|--boost-librarydir=*)
if [[ "$1" != *=* ]]; if echo "$1" | grep -q '^*=*$';
then shift; then shift;
fi fi
BOOST_LIBRARY_DIR="${1#*=}" BOOST_LIBRARY_DIR="${1#*=}"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.BOOST_LIBRARYDIR='${BOOST_LIBRARY_DIR}'" BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.BOOST_LIBRARYDIR='${BOOST_LIBRARY_DIR}'"
;; ;;
--boost-root|--boost-root=*) --boost-root|--boost-root=*)
if [[ "$1" != *=* ]]; if echo "$1" | grep -q '^*=*$';
then shift; then shift;
fi fi
BOOST_ROOT="${1#*=}" BOOST_ROOT="${1#*=}"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.Boost_ROOT='${BOOST_ROOT}'" BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.Boost_ROOT='${BOOST_ROOT}'"
;; ;;
--opencl-include-dir|--opencl-include-dir=*) --opencl-include-dir|--opencl-include-dir=*)
if [[ "$1" != *=* ]]; if echo "$1" | grep -q '^*=*$';
then shift; then shift;
fi fi
OPENCL_INCLUDE_DIR="${1#*=}" OPENCL_INCLUDE_DIR="${1#*=}"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.OpenCL_INCLUDE_DIR='${OPENCL_INCLUDE_DIR}'" BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.OpenCL_INCLUDE_DIR='${OPENCL_INCLUDE_DIR}'"
;; ;;
--opencl-library|--opencl-library=*) --opencl-library|--opencl-library=*)
if [[ "$1" != *=* ]]; if echo "$1" | grep -q '^*=*$';
then shift; then shift;
fi fi
OPENCL_LIBRARY="${1#*=}" OPENCL_LIBRARY="${1#*=}"
...@@ -254,14 +254,14 @@ create_isolated_source_dir() { ...@@ -254,14 +254,14 @@ create_isolated_source_dir() {
modules="Cholesky Core Dense Eigenvalues Geometry Householder Jacobi LU QR SVD" modules="Cholesky Core Dense Eigenvalues Geometry Householder Jacobi LU QR SVD"
for eigen_module in ${modules}; do for eigen_module in ${modules}; do
cp \ cp \
external_libs/eigen/Eigen/${eigen_module} \ "external_libs/eigen/Eigen/${eigen_module}" \
./lightgbm-python/external_libs/eigen/Eigen/${eigen_module} "./lightgbm-python/external_libs/eigen/Eigen/${eigen_module}"
if [ ${eigen_module} != "Dense" ]; then if [ "${eigen_module}" != "Dense" ]; then
mkdir -p ./lightgbm-python/external_libs/eigen/Eigen/src/${eigen_module}/ mkdir -p "./lightgbm-python/external_libs/eigen/Eigen/src/${eigen_module}/"
cp \ cp \
-R \ -R \
external_libs/eigen/Eigen/src/${eigen_module}/* \ "external_libs/eigen/Eigen/src/${eigen_module}"/* \
./lightgbm-python/external_libs/eigen/Eigen/src/${eigen_module}/ "./lightgbm-python/external_libs/eigen/Eigen/src/${eigen_module}/"
fi fi
done done
...@@ -308,6 +308,7 @@ if test "${INSTALL}" = true; then ...@@ -308,6 +308,7 @@ if test "${INSTALL}" = true; then
# use regular-old setuptools for these builds, to avoid # use regular-old setuptools for these builds, to avoid
# trying to recompile the shared library # trying to recompile the shared library
sed -i.bak -e '/start:build-system/,/end:build-system/d' pyproject.toml sed -i.bak -e '/start:build-system/,/end:build-system/d' pyproject.toml
# shellcheck disable=SC2129
echo '[build-system]' >> ./pyproject.toml echo '[build-system]' >> ./pyproject.toml
echo 'requires = ["setuptools"]' >> ./pyproject.toml echo 'requires = ["setuptools"]' >> ./pyproject.toml
echo 'build-backend = "setuptools.build_meta"' >> ./pyproject.toml echo 'build-backend = "setuptools.build_meta"' >> ./pyproject.toml
...@@ -339,6 +340,7 @@ fi ...@@ -339,6 +340,7 @@ fi
if test "${BUILD_SDIST}" = true; then if test "${BUILD_SDIST}" = true; then
echo "--- building sdist ---" echo "--- building sdist ---"
rm -f ../dist/*.tar.gz rm -f ../dist/*.tar.gz
# shellcheck disable=SC2086
python -m build \ python -m build \
--sdist \ --sdist \
--outdir ../dist \ --outdir ../dist \
...@@ -349,6 +351,7 @@ fi ...@@ -349,6 +351,7 @@ fi
if test "${BUILD_WHEEL}" = true; then if test "${BUILD_WHEEL}" = true; then
echo "--- building wheel ---" echo "--- building wheel ---"
rm -f ../dist/*.whl || true rm -f ../dist/*.whl || true
# shellcheck disable=SC2086
python -m build \ python -m build \
--wheel \ --wheel \
--outdir ../dist \ --outdir ../dist \
...@@ -360,18 +363,19 @@ if test "${INSTALL}" = true; then ...@@ -360,18 +363,19 @@ if test "${INSTALL}" = true; then
echo "--- installing lightgbm ---" echo "--- installing lightgbm ---"
cd ../dist cd ../dist
if test "${BUILD_WHEEL}" = true; then if test "${BUILD_WHEEL}" = true; then
PACKAGE_NAME="lightgbm*.whl" PACKAGE_NAME="$(echo lightgbm*.whl)"
else else
PACKAGE_NAME="lightgbm*.tar.gz" PACKAGE_NAME="$(echo lightgbm*.tar.gz)"
fi fi
# ref for use of '--find-links': https://stackoverflow.com/a/52481267/3986677 # ref for use of '--find-links': https://stackoverflow.com/a/52481267/3986677
# shellcheck disable=SC2086
pip install \ pip install \
${PIP_INSTALL_ARGS} \ ${PIP_INSTALL_ARGS} \
--force-reinstall \ --force-reinstall \
--no-cache-dir \ --no-cache-dir \
--no-deps \ --no-deps \
--find-links=. \ --find-links=. \
${PACKAGE_NAME} "${PACKAGE_NAME}"
cd ../ cd ../
fi fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment