name: Run tests

on: [push, pull_request]

jobs:
  black:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v1
        with:
          python-version: 3.8
      - name: Ensure files are formatted with black
        run: |
          pip install --upgrade pip
          pip install black
          black --check tests.py

  run-test:
    needs: [black]
    runs-on: ubuntu-latest
    container: tensorflow/tensorflow
    steps:
      - uses: actions/checkout@v2
      - run: |
          apt-get update
          apt install -y tar libavcodec-dev libavformat-dev libswscale-dev
          apt-get update
          apt install -y libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
          apt-get update
          apt install -y libpng-dev libjpeg-dev libopenexr-dev libtiff-dev libwebp-dev
          pip install --upgrade pip
          pip install -r requirements.txt
          pip install gdown==4.3.1
          gdown --id 1-5OxB8eQTkiE7HStTkk4sOsdixKKQxsq
          tar -xvf "new_data.tar" "new_data"
          rm -rf heart_test_data.tar
          sh scripts/test.sh
