# this file is not designed to be run directly
# instead, use the docker-compose.<os>.<swift> files
# eg docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.1804.51.yaml run test
version: "3"

services:

  runtime-setup:
    image: swift-crypto:default
    build:
      context: .
      dockerfile: Dockerfile

  common: &common
    image: swift-crypto:default
    depends_on: [runtime-setup]
    volumes:
      - ~/.ssh:/root/.ssh
      - ..:/code:z
    working_dir: /code
    cap_drop:
      - CAP_NET_RAW
      - CAP_NET_BIND_SERVICE

  soundness:
    <<: *common
    command: /bin/bash -xcl "./scripts/soundness.sh"

  test:
    <<: *common
    # FIXME: get rid of existing warnings
    #command: /bin/bash -xcl "swift test --enable-test-discovery -Xswiftc -warnings-as-errors $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-}"
    command: /bin/bash -xcl "swift test --enable-test-discovery $${IMPORT_CHECK_ARG-}"
    
  cmake:
    <<: *common
    command: /bin/bash -xcl "cmake -G Ninja -D CMAKE_BUILD_TYPE=Release -B out -S . && ninja -C out"

  # util

  shell:
    <<: *common
    entrypoint: /bin/bash
