Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] resolve shellcheck errors in .ci/test_r_packages.sh #6501

Closed
wants to merge 28 commits into from
Closed
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
309a856
No errors in test_r_packages.sh
Kunal-Singh-Dadhwal Jun 21, 2024
5f7199d
Update .ci/test_r_package.sh
Kunal-Singh-Dadhwal Jun 21, 2024
9219ab1
Update .ci/test_r_package.sh
Kunal-Singh-Dadhwal Jun 21, 2024
c78b2a7
Update .ci/test_r_package.sh
Kunal-Singh-Dadhwal Jun 21, 2024
658d6f4
Changed the variable name
Kunal-Singh-Dadhwal Jun 21, 2024
2d37fa1
Merge branch 'master' into master
Kunal-Singh-Dadhwal Jun 21, 2024
d6da266
Merge branch 'master' into master
Kunal-Singh-Dadhwal Jun 21, 2024
e770ebf
Update .ci/test_r_package.sh
Kunal-Singh-Dadhwal Jun 21, 2024
9438bb0
Update test_r_package.sh
Kunal-Singh-Dadhwal Jun 21, 2024
b7830db
Update .ci/test_r_package.sh
Kunal-Singh-Dadhwal Jun 21, 2024
3c04ada
Update .ci/test_r_package.sh
Kunal-Singh-Dadhwal Jun 21, 2024
a0949fe
Update test_r_package.sh
Kunal-Singh-Dadhwal Jun 21, 2024
ff059f5
Update test_r_package.sh
Kunal-Singh-Dadhwal Jun 21, 2024
37b7a0d
Update test_r_package.sh
Kunal-Singh-Dadhwal Jun 21, 2024
ed5442a
Update .ci/test_r_package.sh
Kunal-Singh-Dadhwal Jun 22, 2024
bff81e2
Merge branch 'master' into master
Kunal-Singh-Dadhwal Jun 22, 2024
410ed06
Update test_r_package.sh
Kunal-Singh-Dadhwal Jun 22, 2024
0446d7b
Update test_r_package.sh
Kunal-Singh-Dadhwal Jun 22, 2024
18f411e
Update test_r_package.sh
Kunal-Singh-Dadhwal Jun 22, 2024
2be04c2
Update test_r_package.sh
Kunal-Singh-Dadhwal Jun 22, 2024
e1c71cc
remove extraneous whitespace
jameslamb Jun 22, 2024
0f3dca3
fix conditions on R version
jameslamb Jun 22, 2024
0285f9d
add quotes back
jameslamb Jun 22, 2024
dd643da
fix more quoting issues, indent to show shellcheck interpolation is b…
jameslamb Jun 22, 2024
a7e86c3
read into an array variable
jameslamb Jun 22, 2024
bee1d3d
declare
jameslamb Jun 22, 2024
5ebf72a
fix flags
jameslamb Jun 22, 2024
1c118bb
fix assignment
jameslamb Jun 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions .ci/test_r_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ if [[ $R_BUILD_TYPE != "cran" ]]; then
fi

# Get details needed for installing R components
R_MAJOR_VERSION=( ${R_VERSION//./ } )
if [[ "${R_MAJOR_VERSION}" == "3" ]]; then
R_MAJOR_VERSION=("${R_VERSION//./ }" )
if [[ "${R_MAJOR_VERSION[0]}" == "3" ]]; then
export R_MAC_VERSION=3.6.3
export R_MAC_PKG_URL=${CRAN_MIRROR}/bin/macosx/R-${R_MAC_VERSION}.nn.pkg
export R_LINUX_VERSION="3.6.3-1bionic"
export R_APT_REPO="bionic-cran35/"
elif [[ "${R_MAJOR_VERSION}" == "4" ]]; then
elif [[ "${R_MAJOR_VERSION[0]}" == "4" ]]; then
export R_MAC_VERSION=4.3.1
export R_MAC_PKG_URL=${CRAN_MIRROR}/bin/macosx/big-sur-${ARCH}/base/R-${R_MAC_VERSION}-${ARCH}.pkg
export R_LINUX_VERSION="4.3.1-1.2204.0"
Expand Down Expand Up @@ -70,17 +70,17 @@ if [[ $OS_NAME == "linux" ]]; then
sudo apt-get install \
--no-install-recommends \
-y \
autoconf=$(cat R-package/AUTOCONF_UBUNTU_VERSION) \
autoconf="$(cat R-package/AUTOCONF_UBUNTU_VERSION)" \
automake \
|| exit 1
fi
if [[ $INSTALL_CMAKE_FROM_RELEASES == "true" ]]; then
curl -O -L \
https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1-linux-${ARCH}.sh \
"https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1-linux-${ARCH}.sh" \
|| exit 1

sudo mkdir /opt/cmake || exit 1
sudo sh cmake-3.25.1-linux-${ARCH}.sh --skip-license --prefix=/opt/cmake || exit 1
sudo sh "cmake-3.25.1-linux-${ARCH}.sh" --skip-license --prefix=/opt/cmake || exit 1
sudo ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake || exit 1
fi
fi
Expand All @@ -100,15 +100,15 @@ if [[ $OS_NAME == "macos" ]]; then
sudo tlmgr --verify-repo=none update --self || exit 1
sudo tlmgr --verify-repo=none install inconsolata helvetic rsfs || exit 1

curl -sL ${R_MAC_PKG_URL} -o R.pkg || exit 1
curl -sL "${R_MAC_PKG_URL}" -o R.pkg || exit 1
sudo installer \
-pkg $(pwd)/R.pkg \
-pkg "$(pwd)/R.pkg" \
-target / || exit 1
fi

# fix for issue where CRAN was not returning {lattice} and {evaluate} when using R 3.6
# "Warning: dependency ‘lattice’ is not available"
if [[ "${R_MAJOR_VERSION}" == "3" ]]; then
if [[ "${R_MAJOR_VERSION[0]}" == "3" ]]; then
Rscript --vanilla -e "install.packages(c('https://cran.r-project.org/src/contrib/Archive/lattice/lattice_0.20-41.tar.gz', 'https://cran.r-project.org/src/contrib/Archive/evaluate/evaluate_0.23.tar.gz'), repos = NULL, lib = '${R_LIB_PATH}')"
else
# {Matrix} needs {lattice}, so this needs to run before manually installing {Matrix}.
Expand Down Expand Up @@ -148,7 +148,7 @@ elif [[ $R_BUILD_TYPE == "cran" ]]; then
# a change in a PR has changed configure.ac
if [[ $OS_NAME == "linux" ]]; then
./R-package/recreate-configure.sh

Kunal-Singh-Dadhwal marked this conversation as resolved.
Show resolved Hide resolved
Kunal-Singh-Dadhwal marked this conversation as resolved.
Show resolved Hide resolved
num_files_changed=$(
git diff --name-only | wc -l
)
Expand All @@ -167,18 +167,19 @@ elif [[ $R_BUILD_TYPE == "cran" ]]; then
if [[ "${TASK}" == "r-rchk" ]]; then
echo "Checking R package with rchk"
mkdir -p packages
cp ${PKG_TARBALL} packages
cp "${PKG_TARBALL}" packages
RCHK_LOG_FILE="rchk-logs.txt"
docker run \
-v $(pwd)/packages:/rchk/packages \
-v "$(pwd)/packages":/rchk/packages \
kalibera/rchk:latest \
"/rchk/packages/${PKG_TARBALL}" \
2>&1 > ${RCHK_LOG_FILE} \
> ${RCHK_LOG_FILE} 2>&1 \
|| (cat ${RCHK_LOG_FILE} && exit 1)
cat ${RCHK_LOG_FILE}

# the exceptions below are from R itself and not LightGBM:
# https://github.com/kalibera/rchk/issues/22#issuecomment-656036156
# shellcheck disable=SC2046
exit $(
cat ${RCHK_LOG_FILE} \
| grep -v "in function strptime_internal" \
Expand All @@ -192,9 +193,9 @@ elif [[ $R_BUILD_TYPE == "cran" ]]; then
# git repo around. This is to protect against the use of relative paths
# like ../../CMakeLists.txt that would only work if you are in the repo
R_CMD_CHECK_DIR="${HOME}/tmp-r-cmd-check/"
mkdir -p ${R_CMD_CHECK_DIR}
mv ${PKG_TARBALL} ${R_CMD_CHECK_DIR}
cd ${R_CMD_CHECK_DIR}
mkdir -p "${R_CMD_CHECK_DIR}"
mv "${PKG_TARBALL}" "${R_CMD_CHECK_DIR}"
cd "${R_CMD_CHECK_DIR}"
fi

# fails tests if either ERRORs or WARNINGs are thrown by
Expand All @@ -219,7 +220,9 @@ done

echo "R CMD check build logs:"
BUILD_LOG_FILE=lightgbm.Rcheck/00install.out
cat ${BUILD_LOG_FILE}
cat "${BUILD_LOG_FILE}"

check_succeeded=$check_r_package
Kunal-Singh-Dadhwal marked this conversation as resolved.
Show resolved Hide resolved

if [[ $check_succeeded == "no" ]]; then
exit 1
Expand All @@ -236,13 +239,12 @@ if [[ $used_correct_r_version -ne 1 ]]; then
echo "Unexpected R version was used. Expected '${R_VERSION}'."
exit 1
fi

if [[ $R_BUILD_TYPE == "cmake" ]]; then
passed_correct_r_version_to_cmake=$(
Kunal-Singh-Dadhwal marked this conversation as resolved.
Show resolved Hide resolved
cat $BUILD_LOG_FILE \
| grep --count "R version passed into FindLibR.cmake: ${R_VERSION}"
)
if [[ $used_correct_r_version -ne 1 ]]; then
if [[ $passed_correct_r_version_to_cmake -ne 1 ]]; then
echo "Unexpected R version was passed into cmake. Expected '${R_VERSION}'."
exit 1
fi
Expand Down