mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
The PHPStan steps run a long time for the latest runs and I suspect that this may be because of a bad cache, possibly includeing: ``` Result cache was not saved because of non-ignorable exception: Syntax error, unexpected } on line 378 ``` . This change should only save the cache if the run was successful or if no cache was loaded. The possibly preserves a cache that still reduces the run time. For instance, the following got an empty cache, saved at 2024-01-19T21:28:22.18Z. - https://github.com/Dolibarr/dolibarr/actions/runs/7589384926 That was an aborted run: - https://github.com/Dolibarr/dolibarr/actions/runs/7589372703/job/20673878193 So I added `cancelled()` to avoid overwriting valid cache and phpstan cache will only be written if the outcome was success or if the cache could not be loaded before. I also updated the version for the cache action.
70 lines
2.3 KiB
YAML
70 lines
2.3 KiB
YAML
# This is a basic workflow to check code with PHPSTAN tool
|
|
|
|
name: "PHPStan"
|
|
|
|
# Controls when the workflow will run
|
|
on: [push, pull_request]
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
|
jobs:
|
|
# This workflow contains a single job
|
|
php-stan:
|
|
# The type of runner that the job will run on
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
php-version:
|
|
# PHPStan requires PHP >= 7.2.
|
|
#- "7.2"
|
|
- "8.2"
|
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
steps:
|
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
# Get PHP and addons
|
|
- name: Setup PHP
|
|
id: setup-php
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: "${{ matrix.php-version }}"
|
|
tools: phpstan, cs2pr
|
|
extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap, mysql, pgsql, sqlite3, ldap, xml, mcrypt
|
|
# ???
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 14.x
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
# Restore old cache
|
|
- name: Restore phpstan cache
|
|
id: cache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: ./.github/tmp
|
|
key: "phpstan-cache-${{ matrix.php-version }}-${{ github.run_id }}"
|
|
restore-keys: |
|
|
phpstan-cache-${{ matrix.php-version }}-
|
|
- name: Show debug into
|
|
run: cd ./.github/tmp && ls -al
|
|
|
|
# Run PHPStan
|
|
- name: Run PHPStan
|
|
id: phpstan
|
|
run: phpstan -vvv analyse --error-format=checkstyle --memory-limit 4G -a build/phpstan/bootstrap_action.php -c phpstan.neon | cs2pr --graceful-warnings
|
|
# continue-on-error: true
|
|
|
|
# Save cache
|
|
- name: "Save phpstan cache"
|
|
uses: actions/cache/save@v4
|
|
if: ${{ success() || ( ! cancelled() && steps.cache.outputs.cache-hit != 'true' ) }}
|
|
with:
|
|
path: ./.github/tmp
|
|
key: "phpstan-cache-${{ matrix.php-version }}-${{ github.run_id }}"
|