on:
  pull_request:
    branches:
      - main
    paths:
      - backend/**

name: Run testing on the backend code

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:

    - uses: https://gitea.com/actions/checkout@v4

    - name: Install dependencies
      run: |
        apt-get update && apt-get install -y python3 python3-pip
        pip install pipenv        

    - name: Install packages
      run: |
        ls -la
        # install all packages, including dev-packages
        pipenv install --dev
      working-directory: backend

    - name: Run Tests
      run: pipenv run pytest src --html=report.html --self-contained-html --log-cli-level=DEBUG
      working-directory: backend

    - name: Upload HTML report
      if: always()
      uses: https://gitea.com/actions/upload-artifact@v3
      with:
        name: pytest-html-report
        path: backend/report.html
