#
# THIS FILE IS GENERATED. SEE https://github.com/Chia-Network/chia-blockchain/tree/main/tests#readme
#
name: Ubuntu TEST_NAME Test

on:
  push:
    branches:
      - main
    tags:
        - '**'
  pull_request:
    branches:
      - '**'

jobs:
  build:
    name: Ubuntu TEST_NAME Test
    runs-on: ${{ matrix.os }}
    timeout-minutes: JOB_TIMEOUT
    strategy:
      fail-fast: false
      max-parallel: 4
      matrix:
        python-version: [3.7, 3.8, 3.9]
        os: [ubuntu-latest]

    steps:
    - name: Cancel previous runs on the same branch
      if: ${{ github.ref != 'refs/heads/main' }}
      uses: styfle/cancel-workflow-action@0.9.0
      with:
        access_token: ${{ github.token }}

    - name: Checkout Code
      uses: actions/checkout@v2
      with:
        fetch-depth: 0

    - name: Setup Python environment
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}

    - name: Cache npm
      uses: actions/cache@v2.1.6
      with:
        path: ~/.npm
        key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
        restore-keys: |
          ${{ runner.os }}-node-

    - name: Get pip cache dir
      id: pip-cache
      run: |
        echo "::set-output name=dir::$(pip cache dir)"

    - name: Cache pip
      uses: actions/cache@v2.1.6
      with:
        path: ${{ steps.pip-cache.outputs.dir }}
        key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
        restore-keys: |
          ${{ runner.os }}-pip-

CHECKOUT_TEST_BLOCKS_AND_PLOTS

    - name: Link home directory
      run: |
        cd $HOME
        ln -s $GITHUB_WORKSPACE/.chia
        echo "$HOME/.chia"
        ls -al $HOME/.chia

    - name: Install ubuntu dependencies
      run: |
        sudo apt-get install software-properties-common
        sudo add-apt-repository ppa:deadsnakes/ppa
        sudo apt-get update
        sudo apt-get install python${{ matrix.python-version }}-venv python${{ matrix.python-version }}-distutils git -y

    - name: Run install script
      env:
        INSTALL_PYTHON_VERSION: ${{ matrix.python-version }}
      run: |
        sh install.sh

INSTALL_TIMELORD

    - name: Install developer requirements
      run: |
        . ./activate
        venv/bin/python -m pip install pytest pytest-asyncio pytest-xdist pytest-monitor

    - name: Test TEST_NAME code with pytest
      run: |
        . ./activate
        ./venv/bin/py.test TEST_DIR -s -v --durations 0 PYTEST_PARALLEL_ARGS

CHECK_RESOURCE_USAGE
#
# THIS FILE IS GENERATED. SEE https://github.com/Chia-Network/chia-blockchain/tree/main/tests#readme
#
