diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..2170ec8 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,49 @@ + +name: "Static Analysis with PHPStan" + +on: + workflow_call: + inputs: + php-version: + description: "The PHP version to use when running the job" + default: "8.3" + required: false + type: "string" + composer-root-version: + description: "The version of the package being tested, in case of circular dependencies." + required: false + type: "string" + composer-options: + description: "Additional flags for the composer install command." + default: "--prefer-dist" + required: false + type: "string" + +jobs: + phpstan: + name: "PHPStan (PHP: ${{ inputs.php-version }})" + runs-on: "ubuntu-22.04" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v4" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ inputs.php-version }}" + + - name: "Set COMPOSER_ROOT_VERSION" + run: | + echo "COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}" >> $GITHUB_ENV + if: "${{ inputs.composer-root-version }}" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v3" + with: + dependency-versions: "highest" + composer-options: "${{ inputs.composer-options }}" + + - name: "Run a static analysis with phpstan/phpstan" + run: "vendor/bin/phpstan analyse -v" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 9e6f4d8..b0aaf7d 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -21,35 +21,15 @@ on: jobs: phpstan: - name: "PHPStan (PHP: ${{ inputs.php-version }})" - runs-on: "ubuntu-22.04" - - steps: - - name: "Checkout code" - uses: "actions/checkout@v4" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "${{ inputs.php-version }}" - - - name: "Set COMPOSER_ROOT_VERSION" - run: | - echo "COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}" >> $GITHUB_ENV - if: "${{ inputs.composer-root-version }}" - - - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v3" - with: - dependency-versions: "highest" - composer-options: "${{ inputs.composer-options }}" - - - name: "Run a static analysis with phpstan/phpstan" - run: "vendor/bin/phpstan analyse -v" + name: "PHPStan (deprecated in favor of phpstan.yml)" + uses: "./.github/workflows/phpstan.yml" + with: + php-version: "${{ inputs.php-version }}" + composer-root-version: "${{ inputs.composer-root-version }}" + composer-options: "${{ inputs.composer-options }}" psalm: - name: "Psalm (PHP: ${{ inputs.php-version }})" + name: "Psalm (PHP: ${{ inputs.php-version }}, deprecated without a replacement)" runs-on: "ubuntu-22.04" steps: diff --git a/workflow-templates/static-analysis.properties.json b/workflow-templates/phpstan.properties.json similarity index 65% rename from workflow-templates/static-analysis.properties.json rename to workflow-templates/phpstan.properties.json index e256cda..37187f7 100644 --- a/workflow-templates/static-analysis.properties.json +++ b/workflow-templates/phpstan.properties.json @@ -1,12 +1,11 @@ { - "name": "Static analysis", + "name": "Static analysis with PHPStan", "description": "Perform static analysis on the source code and tests", "iconName": "doctrine-logo", "categories": [ "PHP" ], "filePatterns": [ - "^phpstan\\.neon(?:\\.dist)$", - "^psalm\\.xml$" + "^phpstan\\.neon(?:\\.dist)$" ] } diff --git a/workflow-templates/static-analysis.yml b/workflow-templates/phpstan.yml similarity index 79% rename from workflow-templates/static-analysis.yml rename to workflow-templates/phpstan.yml index 3d15207..075a7f4 100644 --- a/workflow-templates/static-analysis.yml +++ b/workflow-templates/phpstan.yml @@ -6,21 +6,19 @@ on: branches: - "*.x" paths: - - ".github/workflows/static-analysis.yml" + - ".github/workflows/phpstan.yml" - "composer.*" - "src/**" - "phpstan*" - - "psalm*" - "tests/**" push: branches: - "*.x" paths: - - ".github/workflows/static-analysis.yml" + - ".github/workflows/phpstan.yml" - "composer.*" - "src/**" - "phpstan*" - - "psalm*" - "tests/**" jobs: