KonstantinCodes/messenger-kafka

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2.1
orbs:
  wait-for: cobli/wait-for@0.0.2
jobs:
  build:
    parameters:
      php-version:
        type: string
    environment:
      CC_TEST_REPORTER_ID: ac6b0ffb95381a6e67239f27805263c12cdb85bc1b8f3bc295173a8cb12ae2b1
    working_directory: ~/messenger-kafka
    docker:
      - image: cimg/php:<< parameters.php-version >>
      - image: lensesio/fast-data-dev
        environment:
          SAMPLEDATA: 0
          RUNTESTS: 0
          FORWARDLOGS: 0

    steps:
      - checkout

      - run: sudo apt update
      - run: sudo apt install librdkafka1 librdkafka-dev kafkacat netcat
      - run: sudo pecl install rdkafka xdebug

      # Download and cache dependencies
      - restore_cache:
          keys:
            # "composer.lock" can be used if it is committed to the repo
            # - v1-dependencies-{{ checksum "composer.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-latest

      - run: composer install -n --prefer-dist
      - run: vendor/bin/php-cs-fixer --diff --dry-run -v fix

      # Pull Simple PHPUnit dependencies
      - run: ./vendor/bin/simple-phpunit --version

      - save_cache:
          key: v1-dependencies-latest
          paths:
            - ./vendor
            - ./vendor/bin/.phpunit/phpunit-8.3-0/vendor

      - run:
          name: Setup Code Climate test-reporter
          command: |
            # download test reporter as a static binary
            curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
            chmod +x ./cc-test-reporter

      # Wait for the Kafka container
      - wait-for/kafka

      # Test
      - run:
          name: PHPUnit
          command: |
            ./cc-test-reporter before-build
            XDEBUG_MODE=coverage ./vendor/bin/simple-phpunit --log-junit junit.xml --coverage-clover clover.xml
            ./cc-test-reporter after-build --coverage-input-type clover --exit-code $?

      - store_test_results:
          path: ~/messenger-kafka/junit.xml

      - store_test_results:
          path: ~/messenger-kafka/clover.xml

workflows:
  all-versions:
    jobs:
      - build:
          name: "php-7.4"
          php-version: "7.4"
      - build:
          name: "php-8.1"
          php-version: "8.1"