Tests #384
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
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: | |
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', '3.10', '3.11', '3.12'] | |
test-trigger-type: | |
- ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && 'Scheduled' || '' }} | |
exclude: | |
- test-trigger-type: "" | |
python-version: "3.8" | |
- test-trigger-type: "" | |
python-version: "3.9" | |
- test-trigger-type: "" | |
python-version: "3.10" | |
- test-trigger-type: "" | |
python-version: "3.11" | |
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@v3 | |
- name: Setup Python${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Setup cache | |
uses: actions/cache@v3 | |
env: | |
cache-name: test | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ env.cache-name }}-${{ hashFiles('**/pyproject.toml') }}-v1 | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.python-version }}-${{ env.cache-name }}-${{ hashFiles('**/pyproject.toml') }} | |
- 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] | |
pip install --progress-bar off .[optional] --extra-index-url https://download.pytorch.org/whl/cpu | |
# TODO(c-bata): Remove a version constraint after releasing https://github.com/cunla/fakeredis-py/pull/303 | |
pip install --progress-bar off 'fakeredis[lua]<2.21.2' | |
- name: Output installed packages | |
run: | | |
pip freeze --all | |
- name: Output dependency tree | |
run: | | |
pip install pipdeptree | |
pipdeptree | |
- name: Tests | |
run: | | |
if [ "${{ github.event_name }}" = "schedule" ] || \ | |
[ "${{ github.event_name }}" = "workflow_dispatch" ] ; then | |
target="" | |
else | |
target="not slow" | |
fi | |
if [ "${{ matrix.python-version }}" = "3.12" ] ; then | |
# TODO(not522): Remove ignores when BoTorch/Torch supports Python 3.12 | |
ignore_option="--ignore tests/terminator_tests/ \ | |
--ignore tests/terminator_tests/improvement_tests/ \ | |
--ignore tests/visualization_tests/test_terminator_improvement.py" | |
else | |
ignore_option="" | |
fi | |
pytest tests -m "$target" $ignore_option | |
env: | |
SQLALCHEMY_WARN_20: 1 |