name: cuda

on:
  pull_request:
  push:
    branches:
      - master
    paths:
      - 'setup.py'
      - 'torchani/cuaev/**'
      - 'torchani/aev.py'
      - 'ci/**'
      - 'test/test_cuaev.py'
  schedule:
    - cron: '0 0 * * *'

jobs:
  cuda:

    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version: [3.8]

    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python-version }}
    - name: Fetch submodules
      run: git submodule update --init
    - name: Install cuda
      run: |
        source ci/install_cuda.sh
        echo "CUDA_HOME=${CUDA_HOME}" >> $GITHUB_ENV
        echo "LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
        echo "PATH=${CUDA_HOME}/bin:$PATH" >> $GITHUB_ENV
    - name: Install dependencies
      run: ci/install_dependencies.sh
    - name: Install TorchANI
      run: |
        echo $CUDA_HOME
        echo $LD_LIBRARY_PATH
        nvcc -V
        python setup.py install --cuaev --only-sm80
    - name: Run cuaev test
      run: pytest tests/test_cuaev.py -v
