services:
    unit-tests:
        profiles:
            - unit-tests
        build:
            context: .
            target: tests
        volumes:
            - ./reports:/var/app/reports
        networks:
            - unit-net
        command:
            - "./test_scripts/run-unit-tests-and-style-check.sh"

    integration-tests:
        profiles:
            - integration-tests
        build:
            context: .
            target: tests
        environment:
            - AWS_REGION
            - AWS_ACCESS_KEY_ID
            - AWS_SECRET_ACCESS_KEY
            - AWS_SESSION_TOKEN
        networks:
            - integration-net
        command:
            - "./test_scripts/run-integration-tests.sh"

    neo4j-integration-tests:
        profiles:
            - neo4j-integration-tests
        build:
            context: .
            target: tests
        environment:
            - NEO4J_URL=neo4j://neo4j-db:7687
        networks:
            - neo4j-net
        command:
            - "./test_scripts/run-neo4j-tests.sh"
        depends_on:
            neo4j-db:
                condition: service_healthy

    neo4j-db:
        profiles:
            - neo4j-integration-tests
        image: neo4j:5.26
        environment:
            - NEO4J_AUTH=none
        networks:
            - neo4j-net
        healthcheck:
            test: [ "CMD", "cypher-shell", "RETURN 1" ]
            interval: 5s
            timeout: 5s
            retries: 5

networks:
    unit-net:
    integration-net:
    neo4j-net:
