From d9c7c72ad19e4c539f153cbd4177a6286a23be96 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 5 Jul 2023 20:06:12 -0500 Subject: [PATCH] [ci] [python-package] Add CI job testing compatibility with oldest possible versions (#5936) --- .ci/test-python-oldest.sh | 49 ++++++++++++++++++++++++++++ .github/workflows/python_package.yml | 28 +++++++++++++++- 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 .ci/test-python-oldest.sh diff --git a/.ci/test-python-oldest.sh b/.ci/test-python-oldest.sh new file mode 100644 index 000000000000..09cc24633e15 --- /dev/null +++ b/.ci/test-python-oldest.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# oldest versions of dependencies published after +# minimum supported Python version's first release +# +# see https://devguide.python.org/versions/ +# +echo "installing lightgbm's dependencies" +pip install \ + 'numpy==1.12.0' \ + 'pandas==0.24.0' \ + 'scikit-learn==0.18.2' \ + 'scipy==0.19.0' \ +|| exit -1 +echo "done installing lightgbm's dependencies" + +echo "installing lightgbm" +pip install --no-deps dist/*.whl || exit -1 +echo "done installing lightgbm" + +echo "installed package versions:" +pip freeze + +echo "" +echo "checking that examples run without error" + +# run a few examples to test that Python package minimally works +echo "" +echo "--- advanced_example.py ---" +echo "" +python ./examples/python-guide/advanced_example.py || exit -1 + +echo "" +echo "--- logistic_regression.py ---" +echo "" +python ./examples/python-guide/logistic_regression.py || exit -1 + +echo "" +echo "--- simple_example.py ---" +echo "" +python ./examples/python-guide/simple_example.py || exit -1 + +echo "" +echo "--- sklearn_example.py ---" +echo "" +python ./examples/python-guide/sklearn_example.py || exit -1 + +echo "" +echo "done testing on oldest supported Python version" diff --git a/.github/workflows/python_package.yml b/.github/workflows/python_package.yml index 5b536b1ea52d..90ec721be712 100644 --- a/.github/workflows/python_package.yml +++ b/.github/workflows/python_package.yml @@ -76,10 +76,36 @@ jobs: export PATH=${CONDA}/bin:${PATH} $GITHUB_WORKSPACE/.ci/setup.sh || exit -1 $GITHUB_WORKSPACE/.ci/test.sh || exit -1 + test-oldest-versions: + name: Python - oldest supported versions (ubuntu-latest) + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 5 + submodules: true + - name: Create wheel + run: | + docker run \ + --rm \ + -v $(pwd):/opt/lgb-build \ + -w /opt/lgb-build \ + lightgbm/vsts-agent:manylinux_2_28_x86_64 \ + /bin/bash -c 'PATH=/opt/miniforge/bin:$PATH sh ./build-python.sh bdist_wheel --nomp' + - name: Test compatibility + run: | + docker run \ + --rm \ + -v $(pwd):/opt/lgb-build \ + -w /opt/lgb-build \ + python:3.6 \ + /bin/bash ./.ci/test-python-oldest.sh all-python-package-jobs-successful: if: always() runs-on: ubuntu-latest - needs: [test] + needs: [test, test-oldest-versions] steps: - name: Note that all tests succeeded uses: re-actors/alls-green@v1.2.2