Skip to content

Tests with minimum versions #440

Tests with minimum versions

Tests with minimum versions #440

name: Tests with minimum versions
on:
push:
branches:
- master
pull_request: {}
schedule:
- cron: '0 23 * * SUN-THU'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_number || github.ref }}
cancel-in-progress: true
jobs:
tests-with-minimum-versions:
if: (github.event_name == 'schedule' && github.repository == 'optuna/optuna') || (github.event_name != 'schedule')
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9']
services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup cache
uses: actions/cache@v3
env:
cache-name: test-with-minimum-versions
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ env.cache-name }}-${{ hashFiles('**/setup.py') }}-v1
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-${{ env.cache-name }}-${{ hashFiles('**/setup.py') }}
- name: Setup pip
run: |
python -m pip install --upgrade pip
pip install --progress-bar off -U setuptools
- name: Install
run: |
# Install minimal dependencies and confirm that `import optuna` is successful.
pip install --progress-bar off .
python -c 'import optuna'
optuna --version
pip install --progress-bar off .[test] --extra-index-url https://download.pytorch.org/whl/cpu
pip install --progress-bar off .[optional] --extra-index-url https://download.pytorch.org/whl/cpu
- name: Install dependencies with minimum versions
run: |
# Install dependencies with minimum versions.
pip uninstall -y alembic cmaes packaging sqlalchemy plotly scikit-learn pillow
pip install alembic==1.5.0 cmaes==0.10.0 packaging==20.0 sqlalchemy==1.3.0 tqdm==4.27.0 colorlog==0.3 PyYAML==5.1 'pillow<10.4.0'
pip uninstall -y matplotlib pandas scipy
# Python v3.6 was dropped at NumPy v1.20.3.
if [ "${{ matrix.python-version }}" = "3.7" ]; then
pip install matplotlib==3.5.3 pandas==1.3.5 scipy==1.7.3 numpy==1.20.3
elif [ "${{ matrix.python-version }}" = "3.8" ]; then
pip install matplotlib==3.7.5 pandas==2.0.3 scipy==1.10.1 numpy==1.20.3
elif [ "${{ matrix.python-version }}" = "3.9" ]; then
pip install matplotlib==3.8.4 pandas==2.2.2 scipy==1.13.0 numpy==1.26.4
fi
pip install plotly==5.0.0 scikit-learn==0.24.2 # optional extras
- name: Output installed packages
run: |
pip freeze --all
- name: Output dependency tree
run: |
pip install pipdeptree
pipdeptree
- name: Scheduled tests
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
run: |
pytest tests
- name: Tests
if: ${{ github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' }}
run: |
pytest tests -m "not slow"