Skip to content

Commit

Permalink
[ci] fix conda activation issues (fixes #6799)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Jan 25, 2025
1 parent 3654eca commit b4da894
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 11 additions & 8 deletions .ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ ARCH=$(uname -m)

LGB_VER=$(head -n 1 "${BUILD_DIRECTORY}/VERSION.txt")

activate-conda-env() {
set +u
# shellcheck disable=SC1091
source activate "${1}"
set -u
}

if [[ $OS_NAME == "macos" ]] && [[ $COMPILER == "gcc" ]]; then
export CXX=g++-12
export CC=gcc-12
Expand Down Expand Up @@ -69,8 +76,7 @@ CONDA_PYTHON_REQUIREMENT="python=${PYTHON_VERSION}[build=*cpython]"

if [[ $TASK == "if-else" ]]; then
conda create -q -y -n "${CONDA_ENV}" "${CONDA_PYTHON_REQUIREMENT}" numpy
# shellcheck disable=SC1091
source activate "${CONDA_ENV}"
activate-conda-env "${CONDA_ENV}"
cmake -B build -S . || exit 1
cmake --build build --target lightgbm -j4 || exit 1
cd "$BUILD_DIRECTORY/tests/cpp_tests"
Expand Down Expand Up @@ -112,8 +118,7 @@ if [[ $TASK == "lint" ]]; then
'pyarrow-core>=17.0' \
'scikit-learn>=1.5.2' \
'r-lintr>=3.1.2'
# shellcheck disable=SC1091
source activate "${CONDA_ENV}"
activate-conda-env "${CONDA_ENV}"
echo "Linting Python and bash code"
bash ./.ci/lint-python-bash.sh || exit 1
echo "Linting R code"
Expand All @@ -135,8 +140,7 @@ if [[ $TASK == "check-docs" ]] || [[ $TASK == "check-links" ]]; then
-n "${CONDA_ENV}" \
'doxygen>=1.10.0' \
'rstcheck>=6.2.4' || exit 1
# shellcheck disable=SC1091
source activate "${CONDA_ENV}"
activate-conda-env "${CONDA_ENV}"
# check reStructuredText formatting
find "${BUILD_DIRECTORY}/python-package" -type f -name "*.rst" \
-exec rstcheck --report-level warning {} \+ || exit 1
Expand Down Expand Up @@ -174,8 +178,7 @@ conda create \
"${CONDA_PYTHON_REQUIREMENT}" \
|| exit 1

# shellcheck disable=SC1091
source activate $CONDA_ENV
activate-conda-env "${CONDA_ENV}"

cd "${BUILD_DIRECTORY}"

Expand Down
2 changes: 2 additions & 0 deletions docs/build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ conda env create \
--name docs-env \
--file env.yml || exit 1

set +u
# shellcheck disable=SC1091
source activate docs-env
set -u
make clean html || exit 1

echo "Done building docs. Open docs/_build/html/index.html in a web browser to view them."

0 comments on commit b4da894

Please sign in to comment.