name: "Test and code quality"
description: "Run tests and code quality checks"
inputs:
  NEO4J_VERSION:
    description: "Neo4j version"

runs:
  using: "composite"
  steps:
    #----------------------------------------------
    #    setup docker containers for testing
    #----------------------------------------------
    # currently only running on Linux due to technical limitations
    # - name: Install Docker
    #   uses: douglascamata/setup-docker-macos-action@v1-alpha
    #   if: ${{ runner.os == 'macOS' }}
    - name: Start Neo4j Docker
      run: docker run --restart always --publish=7474:7474 --publish=7687:7687 --env NEO4J_AUTH=neo4j/your_password_here --env NEO4J_PLUGINS='["apoc"]' --env=NEO4J_ACCEPT_LICENSE_AGREEMENT=yes -d neo4j:${{ inputs.NEO4J_VERSION }}
      shell: bash
      if: ${{ runner.os == 'Linux' }}
    - name: Start Postgres Docker
      run: docker run --restart always --publish=5432:5432 --env POSTGRES_PASSWORD=postgres -d postgres:11.21-bullseye
      shell: bash
      if: ${{ runner.os == 'Linux' }}
    #----------------------------------------------
    #     run tests and code quality checks
    #----------------------------------------------
    - name: Run Tests (Windows)
      run: |
        poetry run pytest --version
        poetry run pytest --password=your_password_here
      shell: bash
      if: runner.os == 'Windows'
    - name: Run tests (Linux and MacOS)
      run: |
        poetry run pytest --version
        poetry run pytest --password=your_password_here
      shell: bash
      if: runner.os != 'Windows'
    - name: Check code quality
      uses: pre-commit/action@v3.0.0
