Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split static analysis workflow #51

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -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"
34 changes: 7 additions & 27 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this forward the inputs instead of using the defaults of the phpstan.yml workflow ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, good catch!

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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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)$"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down