Skip to content

Commit

Permalink
Merge branch '18.0' into v18_Updating_Invoice_Notes_32134
Browse files Browse the repository at this point in the history
  • Loading branch information
JonBendtsen authored Dec 1, 2024
2 parents 0e1744a + e9009ed commit 7a50097
Show file tree
Hide file tree
Showing 1,078 changed files with 15,934 additions and 7,856 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "PHPCS"

on:
pull_request:
paths:
- "**.php"
- "phpcs.xml"
- ".github/workflows/phpcs.yml"

jobs:
phpcs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50 # important!

# we may use whatever way to install phpcs, just specify the path on the next step
# however, curl seems to be the fastest
- name: Install PHP_CodeSniffer
run: |
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
php phpcs.phar --version
- uses: thenabeel/action-phpcs@v8
with:
files: "**.php" # you may customize glob as needed
phpcs_path: php phpcs.phar
standard: dev/setup/codesniffer/ruleset.xml
fail_on_warnings: false
File renamed without changes.
42 changes: 42 additions & 0 deletions .github/workflows/pr-18.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- "18.0"
push:
branches:
- "18.0"

permissions: write-all

jobs:
run:
runs-on: ubuntu-latest

env:
# GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_TOKEN: ${{ github.token }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install GitHub CLI
run: |
sudo apt update
sudo apt install gh -y
#- name: Authenticate GitHub CLI
# run: |
# echo "GH_TOKEN=$GH_TOKEN"
# gh auth login --with-token <<< "$GH_TOKEN"

- name: Assign reviewer
env:
#REVIEWER: "eldy,lvessiller-opendsi,rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer
REVIEWER: "rycks" # Remplacez par le nom d'utilisateur GitHub du reviewer
run: |
echo "GH_TOKEN=$GH_TOKEN"
pr_number=$(jq --raw-output .number < $GITHUB_EVENT_PATH)
gh pr edit $pr_number --add-reviewer "$REVIEWER"
continue-on-error: true
125 changes: 125 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
name: pre-commit
on:
pull_request:
push:
jobs:
pre-commit:
runs-on: ubuntu-latest
env:
RAW_LOG: pre-commit.log
CS_XML: pre-commit.xml
steps:
- name: Install required tools
run: sudo apt-get update && sudo apt-get install cppcheck
if: false

# The next uses the git API because there is no clone yet.
# This is faster for a big repo.
- name: Get all changed php files (if PR)
id: changed-php
uses: tj-actions/changed-files@v42
if: github.event_name == 'pull_request'
with:
files: |
**.php
# Checkout git sources to analyze
- uses: actions/checkout@v4
# Action setup-python needs a requirements.txt or pyproject.toml
# This ensures one of them exists.
- name: Create requirements.txt if no requirements.txt or pyproject.toml
run: |-
[ -r requirements.txt ] || [ -r pyproject.toml ] || touch requirements.txt
# Install python and pre-commit tool
- uses: actions/setup-python@v5
with:
cache: pip
python-version: "3.11"
- run: python -m pip install pre-commit
# Restore previous cache of precommit
- uses: actions/cache/restore@v4
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
# Run all the precommit tools (defined into pre-commit-config.yaml).
# We can force exclusion of some of them here.
- name: Run pre-commit hooks
env:
# SKIP is used by pre-commit to not execute certain hooks
SKIP: no-commit-to-branch,php-cs,php-cbf,trailing-whitespace,end-of-file-fixer,check-json,check-executables-have-shebangs,check-shebang-scripts-are-executable,beautysh,yamllint,shellcheck
run: |
set -o pipefail
pre-commit gc
pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG}
# The next uses git, which is slow for a bit repo.
# - name: Get all changed php files (if PR)
# id: changed-php
# uses: tj-actions/changed-files@v42
# if: github.event_name == 'pull_request'
# with:
# files: |
# **.php

- name: Setup PHPCS
uses: shivammathur/setup-php@v2
# 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
tools: phpcs

- name: Run some pre-commit hooks on selected changed files only
if: steps.changed-php.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-php.outputs.all_changed_files }}
run: |
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/
- name: Convert Raw Log to Annotations
uses: mdeweerd/[email protected]
if: ${{ failure() }}
with:
in: ${{ env.RAW_LOG }}

# 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') }}
# Upload result log files of precommit into the Artifact shared store
- name: Provide log as artifact
uses: actions/upload-artifact@v4
if: ${{ ! cancelled() }}
with:
name: precommit-logs
path: |
${{ env.RAW_LOG }}
${{ env.CS_XML }}
retention-days: 2
19 changes: 19 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
workflow_dispatch:
pull_request:
types: [opened, reopened, synchronize]
branches:
- "18.0"

permissions: write-all

jobs:
testjob:
runs-on: ubuntu-latest
steps:
- name: Log
run: |
echo "variable org: ${{vars.AAA}}"
echo "env prg: ${{env.AAA}}"
echo "secret org: ${{secrets.BBB}}"
echo "variable repository of orga: ${{vars.CCC}}"
5 changes: 0 additions & 5 deletions .idea/php.xml

This file was deleted.

171 changes: 171 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
---
exclude: (?x)^( htdocs/includes/ckeditor/.* )
repos:
# Several miscellaneous checks and fix (on yaml files, end of files fix)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: no-commit-to-branch
args: [--branch, develop, --pattern, \d+.0]
- id: check-yaml
args: [--unsafe]
- id: check-json
- id: mixed-line-ending
exclude: (?x)^(htdocs/includes/tecnickcom/tcpdf/fonts/.*)$
- 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
|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 )$
- id: fix-byte-order-marker
- id: check-case-conflict

# Beautify shell scripts
- repo: https://github.com/lovesegfault/beautysh.git
rev: v6.2.1
hooks:
- id: beautysh
exclude: (?x)^(dev/setup/git/hooks/pre-commit)$
args: [--tab]

# Run local script
#
# For instance to update the license in edited files, you could add to local.sh:
#
# ```shell
# #!/bin/bash
# MYDIR=$(dirname "$0")
# CHANGED_INTERNALS=$(git diff --name-only | grep -v includes)
# "$MYDIR/dev/tools/updatelicense.php" $CHANGED_INTERNALS
# ```
- repo: local
hooks:
- id: local-precommit-script
name: Run local script before commit if it exists
language: system
entry: bash -c '[ ! -x local.sh ] || ./local.sh'
pass_filenames: false

# Check PHP syntax
- repo: https://github.com/mdeweerd/pre-commit-php
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,
--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]
files: \.(php)$

# Prettier (format code, only for non common files)
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier
stages: [manual]
exclude:
(?x)^( .*\.(phar |min\.css |lock) |htdocs/(includes|theme/common)/.*
)$
exclude_types:
- php
- executable
- binary
- shell
- javascript
- markdown
- html
- less
- plain-text
- scss
- css
- yaml

# Check format of yaml files
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.33.0
hooks:
- id: yamllint
args:
- --no-warnings
- -d
- "{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
rev: v2.2.6
hooks:
- id: codespell
# Due to a current limitation of configuration files,
# we can specify two dicts only on the CLI.
# You can update the contents of the exclude-file codespell-lines-ignore with the script
# dev/tools/codespell/addCodespellIgnores.sh
args:
- -D
- "-"
- -D
- dev/tools/codespell/codespell-dict.txt
- -I
- dev/tools/codespell/codespell-ignore.txt
- -x
- dev/tools/codespell/codespell-lines-ignore.txt
- --uri-ignore-words-list
- ned
exclude_types: [image]
exclude: (?x)^(.phan/stubs/.*)$
additional_dependencies: [tomli]
- alias: codespell-lang-en_US
# Only for translations with specialised exceptions
# -D contains predefined conversion dictionaries
# -L is to ignore some words
id: codespell
files: ^htdocs/langs/en_US/.*$
args:
- -D
- "-"
- -D
- dev/tools/codespell/codespell-dict.txt
- -L
- informations,medias,uptodate,reenable,crypted,developpers
- -L
- creat,unitl,alltime,datas,referers
- -I
- dev/tools/codespell/codespell-ignore.txt
- -x
- dev/tools/codespell/codespell-lines-ignore.txt
- --uri-ignore-words-list
- ned

# Check some shell scripts
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.6
hooks:
- id: shellcheck
args: [-W, "100"]
Loading

0 comments on commit 7a50097

Please sign in to comment.