version: 2
jobs:
  ios:
    macos:
      xcode: 13.0.0

    steps:
      - checkout

      - run:
          name: Install React Native dependencies
          command: |
            brew update
            brew install watchman cocoapods || true
            brew link --overwrite cocoapods || true

      - run:
          name: Install Node dependencies
          command: |
            npm ci --legacy-peer-deps

      - run:
          name: Run unit tests
          command: npm test

      - run:
          name: Install command line interfaces
          command: npm install -g cavy-cli wml

      - run:
          name: Clone CavyTester repo
          command:
            git clone https://github.com/pixielabs/cavy-tester.git ~/cavy-tester

      - run:
          name: Install CavyTester dependencies
          command: |
            cd ~/cavy-tester
            npm i --legacy-peer-deps
            cd ios
            pod install

      - run:
          name: Link local Cavy version
          command: |
            (sleep 1; echo -e 'y\n'; sleep 1; echo -e 'y\n') | wml add ~/project ~/cavy-tester/node_modules/cavy

      - run:
          name: Build app and run tests
          command: |
            cd ~/cavy-tester
            rm -rf $TMPDIR/react-* $TMPDIR/haste-* $TMPDIR/metro-*
            watchman watch-del-all
            wml start &
            npx react-native start --reset-cache &
            cavy run-ios

workflows:
  version: 2
  ios:
    jobs:
      - ios

version: 2
jobs:
  ios:
    macos:
      xcode: 13.0.0

    steps:
      - checkout

      - run:
          name: Install React Native dependencies
          command: |
            brew update
            brew install watchman cocoapods yarn || true
            brew link --overwrite cocoapods || true

      - run:
          name: Install Node dependencies
          command: |
            npm ci --legacy-peer-deps

      - run:
          name: Run unit tests
          command: npm test

      - run:
          name: Install command line interfaces
          command: npm install -g cavy-cli wml

      - run:
          name: Clone CavyTester repo
          command:
            git clone https://github.com/pixielabs/cavy-tester.git ~/cavy-tester

      - run:
          name: Install CavyTester dependencies
          command: |
            cd ~/cavy-tester
            yarn
            cd ios
            pod install

      - run:
          name: Link local Cavy version
          command: |
            (sleep 1; echo -e 'y\n'; sleep 1; echo -e 'y\n') | wml add ~/project ~/cavy-tester/node_modules/cavy

      - run:
          name: Build app and run tests
          command: |
            cd ~/cavy-tester
            rm -rf $TMPDIR/react-* $TMPDIR/haste-* $TMPDIR/metro-*
            watchman watch-del-all
            wml start &
            npx react-native start --reset-cache &
            cavy run-ios

workflows:
  version: 2
  ios:
    jobs:
      - ios

Use yarn to install cavy-tester dependencies
Use yarn to install cavy-tester dependencies
