Skip to content

Commit

Permalink
Merge pull request #51 from greg0ire/split-sa-workflow
Browse files Browse the repository at this point in the history
Split static analysis workflow
  • Loading branch information
greg0ire authored Oct 9, 2024
2 parents 86f67a2 + c5b75c1 commit a233747
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 34 deletions.
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"
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

0 comments on commit a233747

Please sign in to comment.