From 411a18ec9f571131a3acbd86f6866cc75bd3bfbb Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 11 Feb 2026 12:58:04 +0100 Subject: [PATCH] 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 --- .github/workflows/ci-on-pull_request.yml | 13 ++++---- .github/workflows/phan.yml | 42 +++++++++++++++++++----- .pre-commit-config.yaml | 9 ++--- htdocs/public/members/new.php | 2 +- 4 files changed, 47 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci-on-pull_request.yml b/.github/workflows/ci-on-pull_request.yml index 415130fcb15..416598105f3 100644 --- a/.github/workflows/ci-on-pull_request.yml +++ b/.github/workflows/ci-on-pull_request.yml @@ -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 diff --git a/.github/workflows/phan.yml b/.github/workflows/phan.yml index 37f6dfcc4d3..04b424feb39 100644 --- a/.github/workflows/phan.yml +++ b/.github/workflows/phan.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 68a1ab347f3..a4dc9af9b98 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 2a10a0b078d..14d2dfab3a5 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -8,7 +8,7 @@ * Copyright (C) 2018 Alexandre Spangaro * Copyright (C) 2021 Waƫl Almoman * Copyright (C) 2022 Udo Tamm - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2026 MDW * * 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