particleflux/password-manager-connection

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2.1
jobs:
  build:
    shell: /bin/bash --login
    docker:
      - image: cimg/php:<< parameters.version >>
    environment:
      SECURITY_CHECKER_VERSION: "v2.1.3"

    parameters:
      version:
        type: string
        default: "8.2"

    steps:
      - checkout

      - run:
          name: Install xdebug for coverage
          command: |
            sudo -E install-php-extensions xdebug
            sudo docker-php-ext-enable xdebug

      - restore_cache:
          keys:
            - v1-dep-{{ .Branch }}-
            - v1-dep-master-
            - v1-dep-
      - run:
          name: Install dependencies
          command: |
            composer install \
              --no-interaction \
              --no-progress \
              --prefer-dist \
              --optimize-autoloader
      - run:
          name: Install CI tools
          command: |
            if [[ ! -f "/tmp/cc-test-reporter" ]]; then
              curl -sL https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > /tmp/cc-test-reporter
            fi
            chmod +x /tmp/cc-test-reporter

            # php dependency security checker
            sudo curl -sSL "https://github.com/fabpot/local-php-security-checker/releases/download/${SECURITY_CHECKER_VERSION}/local-php-security-checker_linux_amd64" \
                   -o '/usr/local/bin/php-security-checker'
            sudo chmod +x '/usr/local/bin/php-security-checker'
      # Save dependency cache
      - save_cache:
          key: v1-dep-{{ .Branch }}-{{ epoch }}
          paths:
            - ~/.composer/cache
            - /tmp/cc-test-reporter

      - run:
          name: Check for known dependency vulnerabilities
          command: |
            commitMsg="$(git log --format=%B -n 1 $CIRCLE_SHA1)"
            if ! echo "$commitMsg" | grep '\[skip security\]' ; then
              php-security-checker
            else
              echo -e "\e[33mWARNING: Skipping security test on user request!\e[0m"
            fi

      - run:
          name: Check Codestyle & language compatibility
          command: |
            # fail only on errors, not on warnings
            vendor/bin/phpcs -s --error-severity=1 --warning-severity=0

      - run:
          name: Static analysis
          command: |
            vendor/bin/phpstan --no-progress

      - run:
          name: Run Tests
          command: |
            /tmp/cc-test-reporter before-build
            # required for xdebug >=3.0.0
            export XDEBUG_MODE=coverage
            vendor/bin/phpunit
            /tmp/cc-test-reporter after-build --exit-code $? || /bin/true

      - store_artifacts:
          path: build

workflows:
  version: 2
  commit:
    jobs:
      - build:
          matrix:
            parameters:
              version: ["8.1", "8.2", "8.3"]
  nightly:
    triggers:
      - schedule:
          cron: 0 0 * * *
          filters:
            branches:
              only:
                - master
    jobs:
      - build:
          matrix:
            parameters:
              version: ["8.1", "8.2"]