Skip to content

Commit

Permalink
GH Actions/reusable-phpstan.yml: add "version" configurable option
Browse files Browse the repository at this point in the history
This Monday, [PHPStan 2.0 will be released](https://phpc.social/@OndrejMirtes/113441109253809720).

To allow for packages which use this reusable workflow to choose whether to stay on PHPStan 1.x or to (automatically) move to PHPStan 2.x, this commit adds a new, optional `version` input option for the reusable PHPStan workflow.

* When not set, the workflow will instruct setup-php to install the latest available PHPStan version (same as before).
* When set, the workflow will instruct setup-php to install whatever version was given.

The version number provided by the calling workflow should comply with the supposed ways of providing a version nr as per setup-php: https://github.com/shivammathur/setup-php/?tab=readme-ov-file#wrench-tools-support
  • Loading branch information
jrfnl committed Nov 8, 2024
1 parent 643d6da commit 3b4e427
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion .github/workflows/reusable-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: PHPStan

on:
workflow_call:
inputs:
version:
description: "The PHPStan version to use. Defaults to the latest available version."
type: string
required: false
default: ""

jobs:
phpstan:
Expand All @@ -18,13 +24,22 @@ jobs:
with:
files: "phpstan.neon*"

- name: Create tools string
id: tools
run: |
if [ "${{ inputs.version }}" == "" ]; then
echo 'TOOLS=phpstan' >> "$GITHUB_OUTPUT"
else
echo 'TOOLS=phpstan:${{ inputs.version }}' >> "$GITHUB_OUTPUT"
fi
- name: Install PHP
if: ${{ steps.has_config.outputs.files_exists == 'true' }}
uses: shivammathur/setup-php@v2
with:
php-version: 'latest'
coverage: none
tools: phpstan
tools: ${{ steps.tools.outputs.TOOLS }}

# Install dependencies and handle caching in one go.
# Dependencies need to be installed to make sure the PHPUnit classes are recognized.
Expand Down

0 comments on commit 3b4e427

Please sign in to comment.