Skip to content

Commit

Permalink
Merge branch 'develop' into update_next_fkstatut_status
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy authored Feb 16, 2024
2 parents cbf51f9 + 62626a4 commit e9bf15f
Show file tree
Hide file tree
Showing 900 changed files with 8,624 additions and 14,431 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ indent_style = tab
indent_style = tab
[*.md]
trim_trailing_whitespace = false
[*.sql]
indent_style = tab
trim_trailing_whitespace = true
indent_size = 4
File renamed without changes.
12 changes: 10 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
CACHE_KEY_PART: >
${{ ( github.event_name == 'pull_request' ) && github.base_ref
}}${{ ( github.event_name == 'pull_request' ) && '-' }}${{ github.head_ref }}
GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action
# 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
Expand Down Expand Up @@ -41,8 +46,11 @@ jobs:
uses: actions/cache/restore@v4
with:
path: ./.github/tmp
key: "phpstan-cache-${{ matrix.php-version }}-${{ github.run_id }}"
key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ github.run_id }}
restore-keys: |
phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-
phpstan-cache-${{ matrix.php-version }}-${{ github.head_ref }}-
phpstan-cache-${{ matrix.php-version }}-${{ github.base_ref }}-
phpstan-cache-${{ matrix.php-version }}-
- name: Show debug into
run: cd ./.github/tmp && ls -al
Expand All @@ -59,4 +67,4 @@ jobs:
if: ${{ success() || ( ! cancelled() && steps.cache.outputs.cache-hit != 'true' ) }}
with:
path: ./.github/tmp
key: "phpstan-cache-${{ matrix.php-version }}-${{ github.run_id }}"
key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ github.run_id }}
38 changes: 30 additions & 8 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
if: github.event_name == 'pull_request'
with:
files: |
**.php
**.php
# Checkout git sources to analyze
- uses: actions/checkout@v4
Expand All @@ -37,7 +37,7 @@ jobs:
- uses: actions/setup-python@v5
with:
cache: pip
python-version: '3.11'
python-version: "3.11"
- run: python -m pip install pre-commit regex
# Restore previous cache of precommit
- uses: actions/cache/restore@v4
Expand Down Expand Up @@ -66,10 +66,20 @@ jobs:

- name: Setup PHPCS
uses: shivammathur/setup-php@v2
if: steps.changed-php.outputs.any_changed == 'true'
# Install when we're going to run phpcs
if: |
steps.changed-php.outputs.any_changed == 'true'
||
(
github.event_name == 'push'
&& (
github.event.ref == 'refs/heads/develop'
|| endsWith(github.event.ref, '.0')
)
)
with:
php-version: 8.1
coverage: none # disable xdebug, pcov
coverage: none # disable xdebug, pcov
tools: phpcs

- name: Run some pre-commit hooks on selected changed files only
Expand All @@ -80,6 +90,19 @@ jobs:
set -o pipefail
pre-commit run php-cs --files ${ALL_CHANGED_FILES} | tee -a ${RAW_LOG}
- name: Run some pre-commit hooks on all files on push to "main" branches
if: |
github.event_name == 'push'
&& (
github.event.ref == 'refs/heads/develop'
|| endsWith(github.event.ref, '.0')
)
run: |
set -o pipefail
ln -sf ~/.cache .cache # Absolute path in .pre-commit-config.yaml
pre-commit run --hook-stage manual -a php-cs-with-cache | tee -a ${RAW_LOG}
ls -l ~/.cache/pre-commit/
# If error, we convert log in the checkstyle format
- name: Convert Raw Log to CheckStyle format
if: ${{ failure() }}
Expand All @@ -91,15 +114,14 @@ jobs:
if: ${{ failure() }}
with:
files: ${{ env.CS_XML }}
notices-as-warnings: true # optional
prepend-filename: true # optional
notices-as-warnings: true # optional
prepend-filename: true # optional
# Save the precommit cache
- uses: actions/cache/save@v4
if: ${{ ! cancelled() }}
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml')
}}
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
# Upload result log files of precommit into the Artifact shared store
- name: Provide log as artifact
uses: actions/upload-artifact@v4
Expand Down
127 changes: 127 additions & 0 deletions .github/workflows/windows-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
name: Win CI
on:
push:
# branches:
# - main
pull_request:
# branches:
# - main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
strategy:
matrix:
os: [windows-latest]
#php_version: [7.4, 8.0] # Add more versions if needed
php_version: [7.4] # Add more versions if needed
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup MariaDB
uses: ankane/setup-mariadb@v1
with:
# mariadb-version: ${{ matrix.mariadb-version }}
database: travis # Specify your database name

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
# ini-values: post_max_size=256M, max_execution_time=180
extensions: >
calendar, gd, imagick, imap, intl, json, ldap, mbstring,
mcrypt, mysql, mysqli, opcache, pgsql, sqlite3, xml, zip
tools: >
composer,
phpunit:9.5
coverage: none
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# phpts: ts # ts for thread-safe, default nts

- name: Get composer cache directory
id: composer-cache
if: false
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
if: false
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
if: false
run: |
composer -n config -g vendor-dir htdocs/includes
# composer self-update 2.4.4
composer -n require \
php-parallel-lint/php-parallel-lint ^1.2 \
php-parallel-lint/php-console-highlighter ^0 \
php-parallel-lint/php-var-dump-check ~0.4
# which phpunit phpcs php-parallel-lint
- run: |
where php
php -v
php -r 'phpinfo();'
echo ok
- name: "Windows: Cygwin download"
if: false && runner.os == 'Windows'
run: |
Invoke-WebRequest 'https://cygwin.com/setup-x86_64.exe' -OutFile 'setup-x86_64.exe'
- name: "Windows: Cygwin setup"
if: false && runner.os == 'Windows'
shell: cmd
#run: .\setup-x86_64.exe --quiet-mode --site http://cygwin.mirror.constant.com --symlink-type=sys --packages mingw64-i686-binutils=2.37-2,mingw64-x86_64-binutils=2.37-2,curl,diffutils,git,m4,make,mercurial,mingw64-i686-gcc-core,mingw64-i686-gcc-g++,mingw64-x86_64-gcc-core,mingw64-x86_64-gcc-g++,patch,perl,rsync,unzip
run: .\setup-x86_64.exe --quiet-mode --site http://cygwin.mirror.constant.com --symlink-type=sys --packages sed

- name: Setup MSYS (provides 'bash' and other unix-tools on windows)
uses: msys2/setup-msys2@v2
if: false
with:
path-type: inherit
cache: true
release: false
msystem: UCRT64
update: false
install: git mingw-w64-ucrt-x86_64-gcc

- name: Run Bash script
# shell: msys2 {0}
shell: bash
run: |
# Replace the following commands with your bash script commands
# Example:
# ./script.sh arg1 arg2
# would be
# bash script.sh arg1 arg2
# env
php -r 'phpinfo();'
${SHELL} -xv dev/setup/phpunit/setup_conf.sh
sed -i -e 's/stopOnFailure="[^"]*"/stopOnFailure="false"/' test/phpunit/phpunittest.xml
- name: Run PHPUnit tests
shell: cmd
run: |-
php --ini
REM TODO Uncomment next line to restrict directory access
REM SET PHP_INI_SCAN_DIR=C:\myphpini
SET INIFILE="C:\myphpini\dolibarr.ini"
mkdir c:\myphpini
echo [php] > %INIFILE%
echo open_basedir^="%CD%;%PHPROOT%" >> %INIFILE%
type %INIFILE%
php --ini
php "%PHPROOT%\phpunit" -d memory_limit=-1 -c "test\phpunit\phpunittest.xml" "test\phpunit\AllTests.php"
74 changes: 63 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@ repos:
hooks:
- id: no-commit-to-branch
args: [--branch, develop, --pattern, \d+.0]
- id: check-xml
exclude: |
(?x)^(htdocs/includes/.*)$
- id: check-yaml
args: [--unsafe]
- id: check-json
- id: mixed-line-ending
exclude: (?x)^(htdocs/includes/tecnickcom/tcpdf/fonts/.*)$
# alternative for dev/tools/fixdosfiles.sh
exclude: |
(?x)^(htdocs/includes/tecnickcom/tcpdf/fonts/.*
|.*/CRLF.*.php # Files in swiftmailer
)$
args: [--fix=lf]
- id: trailing-whitespace
exclude_types: [markdown]
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
exclude: (?x)^( dev/tools/dolibarr-postgres2mysql.php |test/other/test_serialize.php
exclude:
(?x)^( dev/tools/dolibarr-postgres2mysql.php |test/other/test_serialize.php
|test/phpunit/textutf8.txt |test/phpunit/textiso.txt |htdocs/includes/.*
|htdocs/modulebuilder/template/.* |build/debian/dolibarr.postrm |build/debian/dolibarr.postinst
|build/debian/dolibarr.config )$
Expand All @@ -40,8 +49,8 @@ repos:
# ```shell
# #!/bin/bash
# MYDIR=$(dirname "$0")
# CHANGED_INTERNALS=$(git diff --name-only | grep -v includes)
# "$MYDIR/dev/tools/updatelicense.php" $CHANGED_INTERNALS
# git diff HEAD --name-only | grep -v includes | \
# xargs "$MYDIR/dev/tools/updatelicense.php"
# ```
- repo: local
hooks:
Expand All @@ -50,17 +59,59 @@ repos:
language: system
entry: bash -c '[ ! -x local.sh ] || ./local.sh'
pass_filenames: false
- id: duplicate-lang-lines
stages: [manual]
name: Find duplicate language lines
files: (?x)^(htdocs/langs/en_US/.*\.lang)
language: script
entry: ./dev/tools/fixduplicatelanglines.sh
pass_filenames: false
args: [list]
- id: duplicate-lang-keys
stages: [manual]
name: Find duplicate language keys
files: (?x)^(htdocs/langs/en_US/.*\.lang)
language: script
entry: ./dev/tools/fixduplicatelangkey.sh
pass_filenames: false
args: [list]
- id: fix-alt-languages
stages: [manual]
name: Fix alt languages
# Selection: see fixaltlanguages.sh script
files: (?x)^(htdocs/langs/(e[lnstu]|k[akmno]|s[lqrv]|b[nrs]|c[asy]|n[bel]|[ip]t|a[mr]|d[ae]|f[ar]|h[ei]|m[sy]|t[ag]|u[kr]|gl|ja|lo|ru|vi|zh)_[^/]*/.*\.lang)
language: script
entry: ./dev/tools/fixaltlanguages_pre-commit.sh
pass_filenames: true

# Check PHP syntax
- repo: https://github.com/mdeweerd/pre-commit-php
rev: v1.6.3
rev: v1.6.5
hooks:
- id: php-cbf
files: \.(php)$
args: [--standard=dev/setup/codesniffer/ruleset.xml]
- id: php-cs
files: \.(php)$
args: [--standard=dev/setup/codesniffer/ruleset.xml, --report=emacs]
args:
[
--standard=dev/setup/codesniffer/ruleset.xml,
--report=emacs,
--severity=5,
]
- alias: php-cs-with-cache
id: php-cs
# Configuration for ci - run on all files with cache
stages: [manual]
args:
[
--standard=dev/setup/codesniffer/ruleset.xml,
--report=emacs,
--severity=5,
--cache=.cache/pre-commit/dolibarr-php-cs.cache,
.,
]
pass_filenames: false # Run on all files
- id: php-lint
- id: php-stan
stages: [manual]
Expand All @@ -72,7 +123,8 @@ repos:
hooks:
- id: prettier
stages: [manual]
exclude: (?x)^( .*\.(phar |min\.css |lock) |htdocs/(includes|theme/common)/.*
exclude:
(?x)^( .*\.(phar |min\.css |lock) |htdocs/(includes|theme/common)/.*
)$
exclude_types:
- php
Expand All @@ -96,7 +148,7 @@ repos:
args:
- --no-warnings
- -d
- '{extends: relaxed, rules: {line-length: {max: 120}}}'
- "{extends: relaxed, rules: {line-length: {max: 120}}}"

# Execute codespell to fix typo errors (setup of codespell into dev/tools/codespell/)
- repo: https://github.com/codespell-project/codespell
Expand All @@ -109,7 +161,7 @@ repos:
# dev/tools/codespell/addCodespellIgnores.sh
args:
- -D
- '-'
- "-"
- -D
- dev/tools/codespell/codespell-dict.txt
- -I
Expand All @@ -129,7 +181,7 @@ repos:
files: ^htdocs/langs/en_US/.*$
args:
- -D
- '-'
- "-"
- -D
- dev/tools/codespell/codespell-dict.txt
- -L
Expand All @@ -148,4 +200,4 @@ repos:
rev: v0.9.0.6
hooks:
- id: shellcheck
args: [-W, '100']
args: [-W, "100"]
Loading

0 comments on commit e9bf15f

Please sign in to comment.