version: 2.1

commands:
  prepare:
    steps:
      - checkout
      - run: sudo composer self-update
      - restore_cache:
          keys:
            - composer-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "composer.lock" }}
            - composer-v1-{{ .Environment.CIRCLE_JOB }}
      - run: composer install --no-interaction --prefer-dist
      - save_cache:
          key: composer-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "composer.lock" }}
          paths:
            - vendor
  run-tests:
    steps:
      - run: ./vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml
      - run: 
          command: bash <(curl -s https://codecov.io/bash)
          when: on_success

jobs: 
  php_5: 
    docker: 
      - image: circleci/php:5.6
    steps:
      - prepare
      - run-tests
  php_7: 
    docker: 
      - image: circleci/php:7.1
    steps:
      - prepare
      - run-tests

#Each workflow represents a Github check
workflows:
  build_php_5:
    jobs:
      - php_5
  build_php_7:
    jobs:
      - php_7
version: 2.1

commands:
  prepare:
    steps:
      - checkout
      - run: sudo composer self-update
      - restore_cache:
          keys:
            - composer-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "composer.lock" }}
            - composer-v1-{{ .Environment.CIRCLE_JOB }}
      - run: composer install --no-interaction --prefer-dist
      - save_cache:
          key: composer-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "composer.lock" }}
          paths:
            - vendor
  run-tests:
    steps:
      - run: ./vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml
      - run: 
          command: bash <(curl -s https://codecov.io/bash) -Z -C $CIRCLE_SHA1
          when: on_success

jobs: 
  php_5: 
    docker: 
      - image: circleci/php:5.6
    steps:
      - prepare
      - run-tests
  php_7: 
    docker: 
      - image: circleci/php:7.1
    steps:
      - prepare
      - run-tests

#Each workflow represents a Github check
workflows:
  build_php_5:
    jobs:
      - php_5
  build_php_7:
    jobs:
      - php_7

Fix codecov reporting invalid SHA1
Fix codecov reporting invalid SHA1