Skip to content

Mac tests

Mac tests #649

Workflow file for this run

# Run tests and integration tests on Mac, which are triggered by each master push.
# Currently, Python3.8 is only used as an environment.
# This is mainly for the sake of speed.
name: mac-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-mac:
runs-on: macos-latest
# Scheduled Tests are disabled for forks.
if: (github.event_name == 'schedule' && github.repository == 'optuna/optuna') || (github.event_name != 'schedule')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Setup cache
uses: actions/cache@v3
env:
cache-name: test
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-3.8-${{ env.cache-name }}-${{ hashFiles('**/pyproject.toml') }}-v1
restore-keys: |
${{ runner.os }}-3.8-${{ env.cache-name }}-${{ hashFiles('**/pyproject.toml') }}
- name: Install
run: |
python -m pip install --upgrade pip
pip install --progress-bar off -U setuptools
# 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]
- 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 -m "not integration"
- name: Tests
if: ${{ github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' }}
run: |
pytest tests -m "not integration and not slow"
tests-integration-mac:
runs-on: macos-latest
# Scheduled Tests are disabled for forks.
if: (github.event_name == 'schedule' && github.repository == 'optuna/optuna') || (github.event_name != 'schedule')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Setup cache
uses: actions/cache@v3
env:
cache-name: test-integration
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-3.8-${{ env.cache-name }}-${{ hashFiles('**/pyproject.toml') }}-v1
restore-keys: |
${{ runner.os }}-3.8-${{ env.cache-name }}-${{ hashFiles('**/pyproject.toml') }}
- name: Setup mac environment
run: |
brew install libomp
brew install open-mpi
brew install openblas
- name: Install
run: |
python -m pip install --upgrade pip
# 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]
pip install --progress-bar off .[integration]
- name: Output installed packages
run: |
pip freeze --all
- name: Output dependency tree
run: |
pip install pipdeptree
pipdeptree
- name: Tests
run: |
pytest tests -m "integration"
env:
OMP_NUM_THREADS: 1
- name: Tests MPI
run: |
export OMPI_MCA_rmaps_base_oversubscribe=yes
mpirun -n 2 -- pytest tests/integration_tests/test_pytorch_distributed.py
env:
OMP_NUM_THREADS: 1