* Qual: Add pre-commit hooks for Perl code formatting and linting
- Added perltidy hook to format Perl code
- Added perlcritic hook to lint Perl code
* Qual: Update file opening syntax in build scripts (perltidy)
The changes update the syntax for opening files in several build scripts to use the three-argument form of the `open` function, which is more secure and recommended in modern Perl practices.
* Qual: Improve file handling and add strict/warnings pragmas (perlcritic)
The changes include:
- Adding 'use strict' and 'use warnings' pragmas to enforce better coding practices
- Improving file handling by using lexical filehandles (my $IN, my $SPECFROM, etc.)
- Fixing file opening and closing operations to use proper error handling
- Updating various file operations to use the new lexical filehandles
- Fixing indentation and formatting issues in the code
* Qual: Add strict and warnings pragmas to Perl scripts (perlcritic)
The changes add 'use strict;' and 'use warnings;' pragmas
- dev/build/doxygen/dolibarr-doxygen-build.pl
- dev/build/doxygen/dolibarr-doxygen-filter.pl
- dev/build/doxygen/dolibarr-doxygen-getversion.pl
- dev/build/gource/getavatars.pl
- dev/tools/dolibarr-mysql2pgsql.pl
* Qual: Add Perl no critic pragmas (perlcritic)
- Ignore some perlcritic notices
* Qual: Improve code formatting and readability
Perltidy:
- Indentation and spacing
- Improved variable naming and alignment
- Better code organization and structure
- Enhanced readability of conditional statements and loops
These changes do not alter the functionality of the script but make it more maintainable and easier to understand.
* qual: Exclude virtualmin from perltidy and perlcritic hooks
Exclude the virtualmin directory from both perltidy and perlcritic hooks due to specific reasons mentioned in the comment. This change ensures that these hooks do not process files in the virtualmin directory.
* Qual: Add installation of perltidy and perlcritic for pre-commit workflow
This commit adds the installation of perltidy and perlcritic as part of the pre-commit hooks workflow.
* Fix: Update version detection in dolibarr-doxygen-build.pl
- Add support for detecting version from DOL_MAJOR_VERSION and DOL_MINOR_VERSION constants
- Fix undefined variable issue in version detection
* Fix: Update getavatars.pl to use HTTPS and reverse git log
- Changed the URL from HTTP to HTTPS for Gravatar
- Added `--reverse` flag to git log command to process commits in chronological order (faster)
- Updated error message to indicate .git repository instead of .git directory (+ correct test)
* fix: Correct spelling in error messages and prompts
- Fixed typo in error message for missing environment variables
- Corrected spelling in prompt for module name input
- Improved clarity in comment for target checking
* QUAL: Add sqlfluff (SQL code and style check)
# QUAL: Add sqlfluff (SQL code and style check)
This adds a validity and style check on the .sql files.
The same tool can be used to fix style (which can be set up as a
pre-commit hook).
* Ignore some sqlfluff notices
* Ignore RF04 notice, warning about the use of sql keywords
* Adjust dialects for some directories
# Qual: Bump logToCheckStyle for better filename handling
Some notifications from the PHPCS step in pre-commit extracted too many
characters for the filename in a specific case.
The update to logToCheckStyle fixes that.
# Qual: Always run phpcs in pre-commit workflow
Developers are prioritizing the Travis Run because the pre-commit workflow
only runs the phpcs checks if the other pre-commit checks did not fail.
This modifies the action so that the phpcs checks are also run if the
previous step failed.
That should help limit travis load and delays.
* Qual: ci: Run pre-commit/php-cs with cache (#28079)
This adds a hook to .pre-commit-config.yaml and updates the workflow
to run php-cs with cache when it is run for all files.
When running on changed files only, the cache is not useful.
The php-codesniffer ruleset.xml was cleaned up (duplicates removal/formatted)
* Fix: Make all 'relative paths' absolute (#28196)
# Fix: Make all 'relative paths' absolute
The phpcs ruleset xml file's relative exclude patterns are relative to
the filename(s) provided on the command line.
Hence with partial verifications, the path exclusion does not function
as we would like.
Removing the relative-path attribute from the patterns the exclusion
works.
At the same time, the patterns were optimized and a comment was added.
* Qual: Optimize workflow (#28386)
# Qual: Optimize workflow
The log annotation based on the pre-commit logs is now simplified.
* Qual: Lower severity on php-cs messages that should not block (#28072)
# Qual: Lower severity on php-cs messages that should not block
Some warning messages result in php-cs having an exit code of 2 and others
only have an exit ocde of 1. When the exit code is 2, the warnings are fixable
by php-cbf.
In order to be able to filter on the warnings in the github ci flow, but still
show them in the travis flow, I lower the level of the warnings that should not
be blocking to 4.
At the same time, the php-cs configuration in pre-commit now requires that the
severity is minimum 5 to show the message (level 5 is the default for all warnings
and errors).
So this will limit the warning messages to the ones that should result in a failing
ci action. If any new cases are discovered, they should also be lowered in the
php-cs configuration file.
* Qual: ci: Run pre-commit/php-cs with cache (#28079)
This adds a hook to .pre-commit-config.yaml and updates the workflow
to run php-cs with cache when it is run for all files.
When running on changed files only, the cache is not useful.
The php-codesniffer ruleset.xml was cleaned up (duplicates removal/formatted)
This adds a hook to .pre-commit-config.yaml and updates the workflow
to run php-cs with cache when it is run for all files.
When running on changed files only, the cache is not useful.
The php-codesniffer ruleset.xml was cleaned up (duplicates removal/formatted)
This change to the workflow will run phpcs on all files in develop,
17.0, 18.0, ... (rule== branch ends in .0).
This ensures that phpcs is run in a github workflow for fast phpcs
issue detection in the develop and other main branches.
Ultimately, this means that the PHPCS action can be disabled
in branches where it is active. But I propose to verify that
the updated action does the job as expected (tested in a fork
it is ok).
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This change to the workflow will run phpcs on all files in develop,
17.0, 18.0, ... (rule== branch ends in .0).
This ensures that phpcs is run in a github workflow for fast phpcs
issue detection in the develop and other main branches.
Ultimately, this means that the PHPCS action can be disabled
in branches where it is active. But I propose to verify that
the updated action does the job as expected (tested in a fork
it is ok).
Backport the pre-commit tool to bring extra checks to the older versions
so that they are fixed earlier before merging in upper versions.
Other PRs will be created for backporting to 18.0 and 19.0.
The PRs should be accepted in reverse order:
- develop;
- 19.0:
- 18.0;
- 17.0.
That should avoid merge conflicts and ensure that options (and ignored
messages or steps) are adapted to the version branch.
# Qual: Optimize/explain workflows
phpstan checkout took about 1.5 minutes, while pre-commit only takes 10s.
So I removed the option to the checkout option which likely makes
the difference.
I removed the IMHO useless step of installing node - it may have been
useful during setting up the workflow, but not now.
I commented on the pre-commit workflow.
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.