ibudasov/php7-iptc-manager

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2

defaults: &defaults
  environment:
    CC_TEST_REPORTER_ID: b0187fb7571ffbc6bf3d8532353794f0dc7815a119943657e9287a379f835399
  docker:
      # specify the version you desire here
      - image: circleci/php:7.1

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/mysql:9.4

  working_directory: ~/repo

install_composer: &install_composer
    command: |
        cd /tmp
        EXPECTED_SIGNATURE=$(curl -q https://composer.github.io/installer.sig)
        php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
        ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")

        if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
        then
            >&2 echo 'ERROR: Invalid installer signature'
            rm composer-setup.php
            exit 1
        fi

        sudo php composer-setup.php --quiet --install-dir /usr/local/bin --filename composer
        RESULT=$?
        rm composer-setup.php
        exit $RESULT

jobs:

  build:
    <<: *defaults

    steps:
      - checkout

      - run:
          name: Install Composer
          <<: *install_composer

      - run:
          name: Setup CodeClimate test-reporter
          command: |
            curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
            chmod +x ./cc-test-reporter

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

      - run:
          name: Installing dependencies
          command: composer install -n --prefer-dist

      - save_cache:
          paths:
            - ./vendor
          key: v1-dependencies-{{ checksum "composer.json" }}

      - run:
          name: Run tests
          command: |
            composer test

      - run:
          name: Check and upload test coverage
          command: |
            sudo docker-php-ext-enable xdebug
            ./cc-test-reporter before-build
            composer test:coverage
            ./cc-test-reporter after-build --coverage-input-type clover --exit-code $?

workflows:
  version: 2
  test_and_lint:
    jobs:
      - build