services:
  mailhost:
    image: docker.io/greenmail/standalone
  browserhost:
    image: docker.io/selenium/standalone-chromium
    ports:
      # Allow to watch the remote controlled browser (comment out the
      # `--headless` argument in TestCase::driver() before).
      - '127.0.0.1:7900:7900'
    volumes:
      - '/dev/shm:/dev/shm'
      - '../tests/Browser/downloads:/downloads'

  browser_tests:
    depends_on:
      - mailhost
      - browserhost
    hostname: 'testrunner'
    image: ghcr.io/roundcube/roundcubemail-testrunner:php8.3
    volumes:
      - '..:/app'
      - '../tests/Browser/downloads:/downloads'
    environment:
      WEBDRIVER_CONNECT_URL: 'http://browserhost:4444'
      SERVER_URL: 'http://testrunner:8000'
      SERVER_BIND: '0.0.0.0:8000'
      BROWSER_DOWNLOADS_DIR: '/downloads'
      TESTRUNNER_DOWNLOADS_DIR: '../tests/Browser/downloads'
      RC_CONFIG_IMAP_HOST: 'tls://mailhost:3143'
      RC_CONFIG_SMTP_HOST: 'mailhost:3025'
    command: 
      - .ci/run_browser_tests.sh

  tests:
    depends_on:
      - mailhost
    image: ghcr.io/roundcube/roundcubemail-testrunner:php8.3
    volumes:
      - '..:/app'
    command:
      - .ci/run_tests.sh

  codespell:
    image: ghcr.io/roundcube/roundcubemail-testrunner:php8.3
    volumes:
      - '..:/app'
    command:
      - vendor/bin/php-cs-fixer
      - fix
      - --dry-run
      - --using-cache=no
      - --diff
      - --verbose

  codestyle:
    image: ghcr.io/roundcube/roundcubemail-testrunner:php8.3
    volumes:
      - '..:/app'
    command:
      - npx
      - eslint
      - .
