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-unit-tests:
    steps:
      - run: ./vendor/bin/phpunit --coverage-text
      - store_artifacts:
          path: build/coverage.xml

jobs:
  php_7_3:
    docker: 
      - image: circleci/php:7.3
    steps:
      - prepare
      - run-unit-tests
  php_7_4:
    docker:
      - image: circleci/php:7.4
    steps:
      - prepare
      - run-unit-tests
  php_8_0:
    docker:
      - image: circleci/php:8.0
    steps:
      - prepare
      - run-unit-tests

#Each workflow represents a Github check
workflows:
  build-and-test:
    jobs:
      - php_7_3
      - php_7_4
      - php_8_0


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-unit-tests:
    steps:
      - run: ./vendor/bin/phpunit --coverage-text
      - store_artifacts:
          path: build/coverage.xml

jobs:
  php_7_3:
    docker:
      - image: circleci/php:7.3
    steps:
      - prepare
      - run-unit-tests
      - run:
          command: bash <(curl -s https://codecov.io/bash)
          when: on_success
  php_7_4:
    docker:
      - image: circleci/php:7.4
    steps:
      - prepare
      - run-unit-tests
  php_8_0:
    docker:
      - image: circleci/php:8.0
    steps:
      - prepare
      - run-unit-tests

#Each workflow represents a Github check
workflows:
  build-and-test:
    jobs:
      - php_7_3
      - php_7_4
      - php_8_0

Update codecov during CI tests
fix: Update codecov during CI tests
