diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..2ef96c3 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,76 @@ +name: "Continuous Integration" + +on: + - push + - pull_request + +env: + COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist" + +jobs: + tests: + name: "CI" + + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: + - "7.1" + - "7.2" + - "7.3" + - "7.4" + - "8.0" + dependencies: [highest] + include: + - php-version: "7.1" + dependencies: lowest + - php-version: "7.2" + dependencies: lowest + - php-version: "7.3" + dependencies: lowest + - php-version: "7.4" + dependencies: lowest + - php-version: "8.0" + dependencies: lowest + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + + - name: Get composer cache directory + id: composercache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composercache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Unpin PHP version in the platform config + run: "composer config platform.config.php --unset" + + - name: "Handle lowest dependencies update" + if: "contains(matrix.dependencies, 'lowest')" + run: + 'echo "COMPOSER_FLAGS=$COMPOSER_FLAGS --prefer-lowest" >> $GITHUB_ENV' + + - name: "Update dependencies" + run: composer update ${{ env.COMPOSER_FLAGS }} + + - name: "Run tests" + run: | + vendor/bin/phpunit --coverage-clover=./tests/report/coverage.clover --testsuite unit + + - name: Report Code Coverage + run: | + test -f ./tests/report/coverage.clover && (wget https://scrutinizer-ci.com/ocular.phar; php ocular.phar code-coverage:upload --format=php-clover ./tests/report/coverage.clover) + if: + "${{ matrix.php-version == '7.4' && contains(matrix.dependencies, 'highest') }}" diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 0000000..76ea93d --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,53 @@ +name: "PHPCS" + +on: + - push + - pull_request + +env: + COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist" + +jobs: + tests: + name: "CI" + + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: + - "7.1" + - "7.2" + - "7.3" + - "7.4" + - "8.0" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + + - name: Get composer cache directory + id: composercache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composercache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Unpin PHP version in the platform config + run: "composer config platform.config.php --unset" + + - name: "Update dependencies" + run: composer update ${{ env.COMPOSER_FLAGS }} + + - name: "Run PHPCS" + run: | + vendor/bin/phpcs -p --warning-severity=0 src/ tests/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a48ac6f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -language: php - -dist: trusty - -cache: - directories: - - $HOME/.composer/cache/files - -php: - - 7.1 - - 7.2 - - 7.3 - - 7.4 - - 8.0 - - nightly - -env: - global: - - XDEBUG_MODE=coverage - jobs: - - PREFER_LOWEST=--prefer-lowest - - PREFER_LOWEST= - -matrix: - allow_failures: - - php: nightly - - php: 8.0 - -before_script: - - make ensure-composer-file PHP_VER=$(php -r "echo PHP_VERSION;") - - travis_retry composer update --no-interaction --prefer-dist $PREFER_LOWEST - -script: - - vendor/bin/phpcs -p --warning-severity=0 src/ tests/ - - vendor/bin/phpunit --coverage-clover=./tests/report/coverage.clover - --testsuite unit - -after_script: - - test -f ./tests/report/coverage.clover && (wget - https://scrutinizer-ci.com/ocular.phar; php ocular.phar code-coverage:upload - --format=php-clover ./tests/report/coverage.clover)