Qual: Partial phan run on PR's, complete run on integration branches (#37186)

* Qual: Partial phan run on PR's, complete on main

# Qual: Partial phan run on PR's, complete on main

The selection is based on the branch name.
To run a complete phan run in a PR, the branch name of the PR must include phan_full.
This can help to fix remaining phan issue before re-integrating to the develop branch.

* qual: Update workflow and pre-commit configurations

- Enable phan workflow by uncommenting the relevant lines
- Update actionlint version to v1.7.10
- Add manual stage to actionlint hook in pre-commit-config.yaml

* qual: Update Phan analysis conditions

The conditions for running Phan analysis have been updated to include an additional check for branches containing 'phan_full'.

* qual: Update Phan workflow

- Replace github.event.ref with github.ref_name
- Add FILE_CHANGE_LIST environment variable for better file handling
- Update file list creation and usage in the workflow

* qual: Update Phan workflow conditions

Fix the branch reference (head_ref in PR, ref_name otherwise)

* Add step for debug information

* Remove debug step

* Fix: Missing initialisations members/new.php

Following a suppression of assignments, the variables disabledphy and disabledmor were undefined.

* fix: Update budget selection dropdown arguments in member creation form

Correct the arguments in the member creation form.

* qual: Add cs2pr to phan workflow

- Add cs2pr to the tools list in the phan workflow
- Change the output mode of phan to checkstyle
- Add a step to add results to PR as Github notices
- Add a step to provide phan log as artifact

* qual: Update Phan workflow to use environment variable for file list

The change fixes the Phan workflow to use the environment variable `$FILE_CHANGED_LIST` to clear the file

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
MDW 2026-02-11 12:58:04 +01:00 committed by GitHub
parent 00136cf9e3
commit 411a18ec9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 47 additions and 19 deletions

View file

@ -8,12 +8,13 @@ jobs:
secrets: inherit
with:
gh_event: ${{ github.event_name }}
#phan:
# uses: ./.github/workflows/phan.yml
# secrets: inherit
# needs: [pre-commit]
# with:
# gh_event: ${{ github.event_name }}
phan:
# if: false # Uncommenting this line disables phan
uses: ./.github/workflows/phan.yml
secrets: inherit
needs: [pre-commit]
with:
gh_event: ${{ github.event_name }}
phpstan:
uses: ./.github/workflows/phpstan.yml
secrets: inherit

View file

@ -49,18 +49,44 @@ jobs:
with:
php-version: 8.2
coverage: none # disable xdebug, pcov
tools: phan:5.5.2
tools: cs2pr,phan:5.5.2
- name: Run Phan analysis
if: "! cancelled() && steps.changed-php.outputs.any_changed == 'true'"
# Proceed when:
# - the action is not cancelled
# AND
# - the branch is an integration branch (no merge), or,
# - the merge from branch contains 'phan_full', or,
# - there are changes in PHP files.
# Note: --output-mode=github does not provide file:line, so using checkstyle and cs2pr
if: ${{ ! cancelled() && (github.ref_name == 'develop' || github.ref_name == 'refs/heads/develop' || endsWith(github.ref_name, '.0') || contains(github.head_ref, 'phan_full') || steps.changed-php.outputs.any_changed == 'true') }}
env:
ALL_CHANGED_FILES: ${{ steps.changed-php.outputs.all_changed_files }}
# shellcheck disable=2086
FILE_CHANGE_LIST: /tmp/phan-changed.lst
run: |
# shellcheck disable=2086
> /tmp/phpstan-files.txt
for f in $ALL_CHANGED_FILES; do echo "$f" >> /tmp/phan-files.txt; done
cat /tmp/phan-files.txt
echo phan --file-list /tmp/phan-files.txt $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=github
#echo phan $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=github
phan --file-list /tmp/phan-files.txt $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=github
if [ "${{ github.ref_name }}" == "develop" ] || [[ "${{ github.ref_name }}" == *.0 ]]|| [[ "${{ github.head_ref }}" == *"phan_full"* ]] ; then
echo phan $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=checkstyle -o _phan.xml
phan $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=checkstyle -o _phan.xml
else
> $FILE_CHANGED_LIST
for f in $ALL_CHANGED_FILES; do echo "$f" >> $FILE_CHANGED_LIST; done
cat $FILE_CHANGED_LIST
echo phan --file-list $FILE_CHANGED_LIST $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=checkstyle -o _phan.xml
phan --file-list $FILE_CHANGED_LIST $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=checkstyle -o _phan.xml
fi
- name: Add results to PR as Github notices
if: ${{ always() }}
run: |
cs2pr --prepend-filename --prepend-source --notices-as-warnings _phan.xml
- name: Provide phan log as artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: phan-srcrt
path: ${{ github.workspace }}/_phan.xml
retention-days: 2

View file

@ -65,10 +65,11 @@ repos:
- id: gitleaks
# Check github actions
#- repo: https://github.com/rhysd/actionlint
# rev: v1.7.8
# hooks:
# - id: actionlint
- repo: https://github.com/rhysd/actionlint
rev: v1.7.10
hooks:
- id: actionlint
stages: [manual] # To run: pre-commit run -a --hook-stage=manual actionlint
# Beautify shell scripts
- repo: https://github.com/lovesegfault/beautysh.git

View file

@ -8,7 +8,7 @@
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2021 Waël Almoman <info@almoman.com>
* Copyright (C) 2022 Udo Tamm <dev@dolibit.de>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by