version: 2

jobs:
  build:
    macos:
      xcode: "9.3.0"
    environment:
      LC_ALL: en_US.UTF-8
      LANG: en_US.UTF-8
    shell: /bin/bash --login -eo pipefail

    steps:
      - checkout
      - restore_cache:
          key: v1-gems-{{ checksum "Gemfile.lock" }}
      - run: bundle check || bundle install --path .bundle
      - save_cache:
          key: v1-gems-{{ checksum "Gemfile.lock" }}
          paths:
            - .bundle
      - restore_cache:
          key: libvlc-v4-{{ checksum "compileAndBuildVLCKit.sh" }}
      - run:
          name: Build VLCKit
          command: |
            rake build:vlckit:ios
            rake build:vlckit:tv
            rake build:vlckit:mac
      - save_cache:
          key: libvlc-v4-{{ checksum "compileAndBuildVLCKit.sh" }}
          paths:
            - build
            - libvlc
            - Resources
      - run:
          name: Run Tests
          command: |
            rake test:ios
            rake test:tv
            rake test:mac
      - run:
          name: Generate Coverage Reports
          command: |
            rake codecov:ios
            rake codecov:tv
            rake codecov:mac
      - store_artifacts:
          path: Tests/Coverage
          destination: Coverage

