diff --git a/.github/actions/php-build/action.yml b/.github/actions/php-build/action.yml index cac3160..41d58ad 100644 --- a/.github/actions/php-build/action.yml +++ b/.github/actions/php-build/action.yml @@ -1,16 +1,16 @@ name: 'PHP Build' -description: '' +description: 'Create PHP build, installing required dependencies.' inputs: cache-deps: - description: '' + description: 'Whether to cache composer dependencies.' required: false default: true composer-args: - description: '' + description: 'The arguments to pass to composer when installing dependencies.' required: false default: '' php-version: - description: '' + description: 'The PHP version to use.' required: false default: 'latest' runs: @@ -35,4 +35,4 @@ runs: uses: php-actions/composer@v6 with: args: ${{ inputs.composer-args }} - php_version: ${{ inputs.php-version }} + php_version: ${{ inputs.php-version }} \ No newline at end of file diff --git a/.github/actions/php-test/action.yml b/.github/actions/php-test/action.yml index e69de29..b90acf8 100644 --- a/.github/actions/php-test/action.yml +++ b/.github/actions/php-test/action.yml @@ -0,0 +1,62 @@ +name: 'PHP Tests' +description: 'Run PHPStan and/or PHPUnit tests.' +inputs: + php-version: + description: 'The PHP version to use.' + default: 'latest' + required: false + + # PHPStan options + phpstan-enable: + description: 'Whether to enable PHPStan.' + default: true + required: false + phpstan-config: + description: 'The location of the PHPStan configuration file (phpstan.neon).' + default: 'phpstan.neon' + required: false + phpstan-memory-limit: + description: 'The memory limit for PHPStan.' + default: '512M' + required: false + phpstan-php-version: + description: 'The PHP version to use with PHPStan.' + default: 'latest' + required: false + phpstan-version: + description: 'The version of PHPStan to use.' + default: 'latest' + required: false + + # PHPUnit options + phpunit-enable: + description: 'Whether to enable PHPUnit.' + default: true + required: false + phpunit-config-file: + description: 'The location of the PHPUnit configuration file (phpunit.xml.dist).' + default: 'phpunit.xml.dist' + required: false + phpunit-version: + description: 'The version of PHPUnit to use.' + default: 'latest' + required: false +runs: + using: 'composite' + steps: + - name: 'PHPStan' + if: ${{ inputs.phpstan-enable && inputs.php-version == inputs.phpstan-php-version }} + uses: php-actions/phpstan@v3 + with: + configuration: ${{ inputs.phpstan-config }} + memory_limit: ${{ inputs.phpstan-memory-limit }} + php_version: ${{ inputs.phpstan-php-version }} + version: ${{ inputs.phpstan-version }} + + - name: 'PHPUnit' + if: ${{ inputs.phpunit-enable }} + uses: php-actions/phpunit@v3 + with: + configuration: ${{ inputs.phpunit-config }} + php_version: ${{ inputs.php-version }} + version: ${{ inputs.phpunit-version }} \ No newline at end of file diff --git a/.github/workflows/php-build.yml b/.github/workflows/php-build.yml index 1dfef3e..1e6a0ba 100644 --- a/.github/workflows/php-build.yml +++ b/.github/workflows/php-build.yml @@ -55,12 +55,7 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} path: './src/vendor' - - name: 'Install Composer Dependencies' - if: ${{ steps.composer-cache.outputs.cache-hit != 'true' }} - uses: php-actions/composer@v6 - with: - args: ${{ inputs.composer_args }} - php_version: ${{ matrix.php }} + - name: 'Create Build Archive' run: |