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 f046aecc1d9d..e05821443627 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