diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..25aae2f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,88 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + name: PHP ${{ matrix.php-version }} Test + runs-on: ubuntu-latest + permissions: + contents: read + + strategy: + fail-fast: false + matrix: + php-version: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: dom, mbstring + coverage: xdebug + + - name: Validate composer.json and composer.lock + run: composer validate --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v4 + with: + path: vendor + key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-php-${{ matrix.php-version }}- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-interaction + + - name: Run test suite + run: vendor/bin/phpunit --coverage-clover=coverage.xml + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + if: matrix.php-version == '8.3' + with: + files: ./coverage.xml + fail_ci_if_error: false + token: ${{ secrets.CODECOV_TOKEN }} + + code-quality: + name: Code Quality + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + extensions: dom, mbstring + tools: cs2pr + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v4 + with: + path: vendor + key: ${{ runner.os }}-php-8.3-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-php-8.3- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-interaction + + - name: Run PHP_CodeSniffer + run: vendor/bin/phpcs --report=checkstyle | cs2pr diff --git a/.gitignore b/.gitignore index 183037e..2a681d8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ vendor/ /demo/bower_components /demo/node_modules .DS_Store -.idea \ No newline at end of file +.idea +.phpunit.result.cache +coverage.xml \ No newline at end of file diff --git a/README.md b/README.md index 357c573..132f0e7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ php-htmldiff ============ -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/quality-score.png?b=master)][badge_score] -[![Build Status](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/build.png?b=master)][badge_status] -[![Code Coverage](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/coverage.png?b=master)][badge_coverage] +[![CI](https://github.com/caxy/php-htmldiff/workflows/CI/badge.svg)][badge_ci] +[![Code Coverage](https://codecov.io/gh/caxy/php-htmldiff/branch/master/graph/badge.svg)][badge_coverage] [![Packagist](https://img.shields.io/packagist/dt/caxy/php-htmldiff.svg)][badge_packagist] [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/caxy/php-htmldiff.svg)][badge_resolve] [![Percentage of issues still open](http://isitmaintained.com/badge/open/caxy/php-htmldiff.svg)][badge_issues] @@ -213,9 +212,8 @@ php-htmldiff is available under [GNU General Public License, version 2][gnu]. Se * Add documentation on alternative htmldiff engines and perhaps some comparisons -[badge_score]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/?branch=master -[badge_status]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/build-status/master -[badge_coverage]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/?branch=master +[badge_ci]: https://github.com/caxy/php-htmldiff/actions/workflows/ci.yml +[badge_coverage]: https://codecov.io/gh/caxy/php-htmldiff [badge_packagist]: https://packagist.org/packages/caxy/php-htmldiff [badge_resolve]: http://isitmaintained.com/project/caxy/php-htmldiff "Average time to resolve an issue" [badge_issues]: http://isitmaintained.com/project/caxy/php-htmldiff "Percentage of issues still open" diff --git a/composer.json b/composer.json index 9e7c0fd..2891b43 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ }, "require-dev": { "phpunit/phpunit": "~9.0", - "doctrine/cache": "~1.0" + "doctrine/cache": "~1.0", + "squizlabs/php_codesniffer": "^3.7" }, "suggest": { "doctrine/cache": "Used for caching the calculated diffs using a Doctrine Cache Provider"