version: 2

jobs:
  linux:
    docker:
      - image: swift:4.1
    steps:
      - checkout
      - run: 
          name: Compile code
          command: swift build
      - run: 
          name: Run unit tests
          command: swift test

  linux-release:
    docker:
      - image: swift:4.1
    steps:
      - checkout
      - run: 
          name: Compile code with optimizations
          command: swift build -c release

workflows:
  version: 2
  tests:
    jobs:
      - linux
      - linux-release

  nightly:
    triggers:
      - schedule:
          cron: "0 0 * * *"
          filters:
            branches:
              only:
                - master
    jobs:
      - linux
      - linux-release
      