diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 7c6e099..7707a79 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -1,6 +1,6 @@ # GitHub Actions Documentation: https://docs.github.com/en/actions -name: "build" +name: "Continuous Integration" on: push: @@ -25,6 +25,7 @@ jobs: coding-standards: name: "Coding standards" runs-on: "ubuntu-latest" + steps: - name: "Checkout repository" uses: "actions/checkout@v4" @@ -39,14 +40,15 @@ jobs: uses: "ramsey/composer-install@v3" - name: "Check syntax (php-parallel-lint)" - run: "composer lint -- --colors" + run: "composer dev:lint:syntax" - name: "Check coding standards (PHP_CodeSniffer)" - run: "./vendor/bin/phpcs --colors" + run: "composer dev:lint:style" static-analysis: name: "Static analysis" runs-on: "ubuntu-latest" + steps: - name: "Checkout repository" uses: "actions/checkout@v4" @@ -61,7 +63,7 @@ jobs: uses: "ramsey/composer-install@v3" - name: "Statically analyze code (PHPStan)" - run: "composer phpstan -- --ansi" + run: "composer dev:analyze:phpstan" benchmark: name: "Benchmark" @@ -106,13 +108,14 @@ jobs: with: dependency-versions: "${{ matrix.dependency-versions }}" - - name: "Run PHPBench" - run: "composer phpbench -- --ansi" + - name: "Run benchmarks (PHPBench)" + run: "composer dev:bench" code-coverage: name: "Code coverage" needs: ["coding-standards", "static-analysis"] runs-on: "ubuntu-latest" + steps: - name: "Checkout repository" uses: "actions/checkout@v4" @@ -127,7 +130,7 @@ jobs: with: php-version: "latest" extensions: bcmath, gmp, sodium, uuid - coverage: "pcov" + coverage: "xdebug" ini-values: "memory_limit=-1" - name: "Install dependencies (Composer)" @@ -136,10 +139,17 @@ jobs: dependency-versions: "${{ matrix.dependencies }}" - name: "Run unit tests (PHPUnit)" - run: "./vendor/bin/phpunit --verbose --colors=always --coverage-text --coverage-clover build/logs/clover.xml" + run: "composer dev:test:coverage:ci" - name: "Publish coverage report to Codecov" - uses: "codecov/codecov-action@v5.0.2" + uses: "codecov/codecov-action@v5" + + - name: "Upload test results to Codecov" + if: ${{ !cancelled() }} + uses: "codecov/test-results-action@v1" + with: + disable_search: true + file: "./build/junit.xml" unit-tests: name: "Unit Tests" @@ -195,4 +205,4 @@ jobs: dependency-versions: "${{ matrix.dependency-versions }}" - name: "Run unit tests (PHPUnit)" - run: "./vendor/bin/phpunit --verbose --colors=always --no-coverage" + run: "composer dev:test:unit" diff --git a/.github/workflows/merge-dependabot-upgrades.yml b/.github/workflows/merge-dependabot-upgrades.yml deleted file mode 100644 index 60665f8..0000000 --- a/.github/workflows/merge-dependabot-upgrades.yml +++ /dev/null @@ -1,24 +0,0 @@ -# See https://github.com/ridedott/merge-me-action/ -# This workflow automates merges from patches sent by Dependabot, and -# only by dependabot, once the other CI workflows pass -name: Auto-merge Dependabot PRs - -on: - workflow_run: - types: - - completed - workflows: - - "build" - -jobs: - merge-me: - name: Auto-merge Dependabot PRs - runs-on: ubuntu-latest - steps: - - name: Auto-Merge - if: ${{ github.event.workflow_run.conclusion == 'success' }} - uses: ridedott/merge-me-action@v2.10.111 - with: - # This must be used as GitHub Actions token does not support pushing - # to protected branches. - GITHUB_TOKEN: ${{ secrets.MERGE_TOKEN }} diff --git a/.github/workflows/merge-me.yml b/.github/workflows/merge-me.yml new file mode 100644 index 0000000..ec8cd91 --- /dev/null +++ b/.github/workflows/merge-me.yml @@ -0,0 +1,29 @@ +# Merge Me! Documentation: https://github.com/ridedott/merge-me-action/ + +name: "Merge Dependabot PRs" + +on: + workflow_run: + types: + - "completed" + workflows: + - "Continuous Integration" + +jobs: + merge-me: + name: "Merge me!" + runs-on: "ubuntu-latest" + steps: + - name: "Auto-merge" + if: ${{ github.event.workflow_run.conclusion == 'success' }} + uses: "ridedott/merge-me-action@v2" + with: + # This must be used as the GitHub Actions token does not support pushing + # to protected branches. + # + # Create a token with repository permissions: + # https://github.com/settings/tokens/new?scopes=repo&description=Merge+Me!+GitHub+Actions+Workflow + # + # Set MERGE_TOKEN as an environment variable on your repository: + # https://github.com/yourname/repo-name/settings/secrets/actions/new + GITHUB_TOKEN: ${{ secrets.MERGE_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8535a9e..3fc17a7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -85,7 +85,7 @@ When you do begin working on your feature, here are some guidelines to consider: ## Developing -To develop this project, you will need [PHP](https://www.php.net) 7.4 or greater +To develop this project, you will need [PHP](https://www.php.net) 8.0 or greater and [Composer](https://getcomposer.org). After cloning this repository locally, execute the following commands: @@ -99,7 +99,7 @@ Now, you are ready to develop! ### Tooling -This project uses [CaptainHook](https://github.com/CaptainHookPhp/captainhook) +This project uses [CaptainHook](https://github.com/captainhook-git/captainhook) to validate all staged changes prior to commit. ### Commands @@ -113,7 +113,7 @@ composer list ### Coding Standards This project follows a superset of [PSR-12](https://www.php-fig.org/psr/psr-12/) -coding standards, enforced by [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer). +coding standards, enforced by [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer). CaptainHook will run coding standards checks before committing. @@ -121,10 +121,10 @@ You may lint the codebase manually using the following commands: ``` bash # Lint -composer phpcs +composer dev:lint # Attempt to auto-fix coding standards issues -composer phpcbf +composer dev:lint:fix ``` ### Static Analysis @@ -139,7 +139,7 @@ following command: ``` bash # Static analysis -composer analyze +composer dev:analyze ``` ### Project Structure diff --git a/composer.json b/composer.json index 5befc20..e24314d 100644 --- a/composer.json +++ b/composer.json @@ -75,22 +75,41 @@ } }, "scripts": { - "analyze": "@phpstan", - "build:clean": "git clean -fX build/", - "lint": "parallel-lint src tests", - "lint:paths": "parallel-lint", - "phpbench": "phpbench run", - "phpcbf": "phpcbf -vpw --cache=build/cache/phpcs.cache", - "phpcs": "phpcs --cache=build/cache/phpcs.cache", - "phpstan": "phpstan analyse --memory-limit=1G", - "phpunit": "phpunit --verbose --colors=always", - "phpunit-coverage": "phpunit --verbose --colors=always --coverage-html build/coverage", - "test": [ - "@lint", - "@phpbench", - "@phpcs", - "@phpstan", - "@phpunit" - ] + "dev:analyze": "@dev:analyze:phpstan", + "dev:analyze:phpstan": "phpstan analyse --ansi --memory-limit 1G", + "dev:bench": "phpbench run", + "dev:build:clean": "git clean -fX build/", + "dev:lint": [ + "@dev:lint:syntax", + "@dev:lint:style" + ], + "dev:lint:fix": "phpcbf --cache=build/cache/phpcs.cache", + "dev:lint:style": "phpcs --cache=build/cache/phpcs.cache --colors", + "dev:lint:syntax": "parallel-lint --colors src/ tests/", + "dev:test": [ + "@dev:lint", + "@dev:bench", + "@dev:analyze", + "@dev:test:unit" + ], + "dev:test:coverage:ci": "@php -d 'xdebug.mode=coverage' vendor/bin/phpunit --colors=always --coverage-text --coverage-clover build/coverage/clover.xml --coverage-cobertura build/coverage/cobertura.xml --coverage-crap4j build/coverage/crap4j.xml --coverage-xml build/coverage/coverage-xml --log-junit build/junit.xml", + "dev:test:coverage:html": "@php -d 'xdebug.mode=coverage' vendor/bin/phpunit --colors=always --coverage-html build/coverage/coverage-html/", + "dev:test:unit": "phpunit --colors=always", + "test": "@dev:test" + }, + "scripts-descriptions": { + "dev:analyze": "Runs all static analysis checks.", + "dev:analyze:phpstan": "Runs the PHPStan static analyzer.", + "dev:bench": "Runs PHPBench benchmark tests.", + "dev:build:clean": "Cleans the build/ directory.", + "dev:lint": "Runs all linting checks.", + "dev:lint:fix": "Auto-fixes coding standards issues, if possible.", + "dev:lint:style": "Checks for coding standards issues.", + "dev:lint:syntax": "Checks for syntax errors.", + "dev:test": "Runs linting, static analysis, and unit tests.", + "dev:test:coverage:ci": "Runs unit tests and generates CI coverage reports.", + "dev:test:coverage:html": "Runs unit tests and generates HTML coverage report.", + "dev:test:unit": "Runs unit tests.", + "test": "Runs linting, static analysis, and unit tests." } }