Skip to content

Commit efc576a

Browse files
authored
Merge branch '18.0' into vmaury-patch-getssprodarbo
2 parents d800380 + c263fcc commit efc576a

File tree

250 files changed

+2628
-1054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

250 files changed

+2628
-1054
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Add this tag for any changes for more than 1 line
2+
"Pending analysis of PR (maintenance team)":
3+
min: 1

.github/scripts/get_changed_php.sh

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/bash
2+
# Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
3+
4+
set -euo pipefail
5+
6+
# This script retrieves the list of changed PHP files for a pull request
7+
# using the GitHub API and sets two outputs:
8+
# - any_changed: "true" if at least one PHP file changed, "false" otherwise
9+
# - all_changed_files: space-separated list of changed PHP file paths
10+
#
11+
# Required environment variables:
12+
# GITHUB_TOKEN - GitHub token with repo access
13+
# GITHUB_REPOSITORY - "owner/repo"
14+
# GITHUB_EVENT_PATH - Path to the event JSON payload
15+
16+
# Verify required environment variables are set
17+
if [[ -z "${GITHUB_TOKEN:-}" ]]; then
18+
echo "GITHUB_TOKEN is not set" >&2
19+
exit 1
20+
fi
21+
if [[ -z "${GITHUB_REPOSITORY:-}" ]]; then
22+
echo "GITHUB_REPOSITORY is not set" >&2
23+
exit 1
24+
fi
25+
if [[ -z "${GITHUB_EVENT_PATH:-}" ]]; then
26+
echo "GITHUB_EVENT_PATH is not set" >&2
27+
exit 1
28+
fi
29+
30+
# Extract the pull request number from the event payload
31+
pr_number=$(jq --raw-output '.pull_request.number' "$GITHUB_EVENT_PATH")
32+
if [[ "$pr_number" == "null" ]]; then
33+
echo "Not a pull request event"
34+
exit 0
35+
fi
36+
37+
# Split repository into owner and repo name
38+
# Split repository into owner and repo name using Bash parameter expansion
39+
owner="${GITHUB_REPOSITORY%%/*}" # Extract text before the first '/'
40+
repo="${GITHUB_REPOSITORY##*/}" # Extract text after the last '/'
41+
42+
page=1
43+
per_page=100
44+
changed_php_files=()
45+
46+
# Loop through all pages to gather changed files
47+
while true; do
48+
response=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" \
49+
"https://api.github.com/repos/${owner}/${repo}/pulls/${pr_number}/files?per_page=${per_page}&page=${page}")
50+
51+
# Filter for files ending with .php and add them to the list
52+
mapfile -t files < <(echo "$response" | jq -r '.[] | select(.filename | test("\\.php$")) | .filename')
53+
changed_php_files+=("${files[@]}")
54+
55+
# Check if we have reached the last page (less than per_page results)
56+
count=$(echo "$response" | jq 'length')
57+
if (( count < per_page )); then
58+
break
59+
fi
60+
((page++))
61+
done
62+
63+
64+
# Build a space-separated string of changed PHP files
65+
# This does not cope with files that have spaces.
66+
# But such files do not exist in the project (at least not for the
67+
# files we are filtering).
68+
all_changed_files=$(IFS=" " ; echo "${changed_php_files[*]}")
69+
70+
71+
# Determine changed files flag
72+
if [ -z "$all_changed_files" ]; then
73+
any_changed="false"
74+
else
75+
any_changed="true"
76+
fi
77+
78+
# Set outputs for GitHub Actions if GITHUB_OUTPUT is available
79+
if [ -n "${GITHUB_OUTPUT:-}" ]; then
80+
echo "any_changed=${any_changed}" >> "$GITHUB_OUTPUT"
81+
echo "all_changed_files=${all_changed_files}" >> "$GITHUB_OUTPUT"
82+
else
83+
# Otherwise, print the outputs
84+
echo "any_changed=${any_changed}"
85+
echo "all_changed_files=${all_changed_files}"
86+
fi
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Set label for v18"
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
branches:
6+
- "18.0"
7+
push:
8+
branches:
9+
- "18.0"
10+
11+
jobs:
12+
changed-lines-count-labeler:
13+
runs-on: ubuntu-latest
14+
name: An action for automatically labelling pull requests based on the changed lines count
15+
steps:
16+
- name: Set a label
17+
uses: vkirilichev/changed-lines-count-labeler@v0.2
18+
with:
19+
repo-token: ${{ secrets.GITHUB_TOKEN }}
20+
configuration-path: .github/changed-lines-count-labeler.yml
21+
continue-on-error: true
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Action to prepare the github action
2+
# Go on Dolibarr - Settings - Developer settings - Enter a name + webhook to disable + Permissions (see app test) + Can install by any account
3+
# Click on generate the private keys
4+
# Click on Install application - choose user of the Organization
5+
# Go on Organisation - Secret and variables and create a secret PR18_SECRET_KEY and copy the content of received private key. Choose the repository access to "Repository Dolibarr".
6+
# Go on Organisation - Secret and variables and create a variable PR18_APP_ID and copy the ID of the previously create ID. Choose the repository access to "Repository Dolibarr".
7+
#
8+
9+
name: Set reviewer for v18
10+
on:
11+
pull_request:
12+
types: [opened, synchronize, reopened]
13+
branches:
14+
- "18.0"
15+
push:
16+
branches:
17+
- "18.0"
18+
19+
jobs:
20+
pr18:
21+
runs-on: ubuntu-latest
22+
23+
#env:
24+
# GH_TOKEN: ${{ github.token }}
25+
# GH_TOKENS: ${{ secrets.GITHUB_TOKEN }}
26+
27+
steps:
28+
- name: Generate a token
29+
id: generate-token
30+
uses: actions/create-github-app-token@v2
31+
with:
32+
app-id: ${{ vars.PR18_APP_ID }}
33+
private-key: ${{ secrets.PR18_SECRET_KEY }}
34+
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
38+
- name: Assign reviewer
39+
env:
40+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
41+
url: ${{ github.event.pull_request.html_url }}
42+
run: |
43+
gh pr edit "$url" --add-reviewer rycks
44+
gh pr edit "$url" --add-reviewer lvessiller-opendsi
45+

.github/workflows/pre-commit.yml

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ jobs:
1414
run: sudo apt-get update && sudo apt-get install cppcheck
1515
if: false
1616

17+
# Checkout git sources to analyze
18+
- uses: actions/checkout@v4
19+
1720
# The next uses the git API because there is no clone yet.
1821
# This is faster for a big repo.
1922
- name: Get all changed php files (if PR)
2023
id: changed-php
21-
uses: tj-actions/changed-files@v42
22-
if: github.event_name == 'pull_request'
23-
with:
24-
files: |
25-
**.php
24+
if: env.gh_event == 'pull_request'
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
run: ./.github/scripts/get_changed_php.sh
2628

27-
# Checkout git sources to analyze
28-
- uses: actions/checkout@v4
2929
# Action setup-python needs a requirements.txt or pyproject.toml
3030
# This ensures one of them exists.
3131
- name: Create requirements.txt if no requirements.txt or pyproject.toml
@@ -42,6 +42,21 @@ jobs:
4242
with:
4343
path: ~/.cache/pre-commit/
4444
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
45+
46+
- name: Extract PHP version
47+
id: extract-php-version
48+
run: |
49+
PHP_VERSION=$(sed -n 's/.*\$arrayphpmaxversionwarning\s*=\s*array\s*(\s*\([0-9]\+\)\s*,\s*\([0-9]\+\).*/\1.\2/p' htdocs/install/check.php)
50+
echo "PHP_VERSION=$PHP_VERSION" >> $GITHUB_ENV
51+
52+
- name: Setup PHPCS
53+
uses: shivammathur/setup-php@v2
54+
# Install proper php version, and also install phpcs which may be needed
55+
with:
56+
php-version: ${{ env.PHP_VERSION }} # Version from check.php
57+
coverage: none # disable xdebug, pcov
58+
tools: phpcs
59+
4560
# Run all the precommit tools (defined into pre-commit-config.yaml).
4661
# We can force exclusion of some of them here.
4762
- name: Run pre-commit hooks
@@ -62,24 +77,6 @@ jobs:
6277
# files: |
6378
# **.php
6479

65-
- name: Setup PHPCS
66-
uses: shivammathur/setup-php@v2
67-
# Install when we're going to run phpcs
68-
if: |
69-
steps.changed-php.outputs.any_changed == 'true'
70-
||
71-
(
72-
github.event_name == 'push'
73-
&& (
74-
github.event.ref == 'refs/heads/develop'
75-
|| endsWith(github.event.ref, '.0')
76-
)
77-
)
78-
with:
79-
php-version: 8.1
80-
coverage: none # disable xdebug, pcov
81-
tools: phpcs
82-
8380
- name: Run some pre-commit hooks on selected changed files only
8481
if: steps.changed-php.outputs.any_changed == 'true'
8582
env:

.github/workflows/stale-issues-safe.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
types: [created]
99
workflow_dispatch:
1010

11-
permissions: {} # none
11+
permissions: {} # no restriction by default
1212

1313
jobs:
1414
stale:

.github/workflows/test.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Test github actions
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
push:
7+
8+
env:
9+
ENVGHT: ${{ secrets.GITHUB_TOKEN }}
10+
ENVGHU: ${{ github.token }}
11+
TEST_ACCESS_KEY: ${{ secrets.TEST_ACCESS_KEY }}
12+
TEST_VAR_REPO: ${{ vars.TEST_VAR_REPO }}
13+
ENVLOCAL: "varenvlocal"
14+
15+
jobs:
16+
testjob:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Log
20+
run: |
21+
echo "Run action by ${{ github.actor }}"
22+
echo "github.token=${{ github.token }}"
23+
echo "secrets.GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}"
24+
echo "GITHUB_EVENT_PATH=$GITHUB_EVENT_PATH"
25+
echo "repo-token: ${{secrets.GITHUB_TOKEN}}"
26+
echo "secret repository TEST_ACCESS_KEY: ${{secrets.TEST_ACCESS_KEY}}"
27+
echo "variable repository : ${{vars.TEST_VAR_REPO}}"
28+
echo "ENVLOCAL: ${{env.ENVLOCAL}}"

.pre-commit-config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repos:
66
rev: v4.5.0
77
hooks:
88
- id: no-commit-to-branch
9-
args: [--branch, develop, --pattern, \d+.0]
9+
args: [--branch, develop, --pattern, \d+.0$]
1010
- id: check-yaml
1111
args: [--unsafe]
1212
- id: check-json
@@ -81,6 +81,8 @@ repos:
8181
]
8282
pass_filenames: false # Run on all files
8383
- id: php-lint
84+
exclude:
85+
(?x)^(htdocs/includes/symfony/var-dumper/Tests/.*)$
8486
- id: php-stan
8587
stages: [manual]
8688
files: \.(php)$

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# from Dolibarr GitHub repository.
33
# For syntax, see https://docs.travis-ci.com/user/languages/php/
44

5-
# We use dist: bionic = 18.04, focal = 20.04
5+
# We use dist: focal = 20.04, jammy = 22.04
66
os: linux
7-
dist: focal
7+
dist: jammy
88

99
language: generic
1010

@@ -21,7 +21,7 @@ services:
2121

2222

2323
addons:
24-
mariadb: '10.5'
24+
mariadb: '10.6'
2525

2626

2727
env:
@@ -123,7 +123,8 @@ install:
123123
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
124124
sudo chmod -R a+rwx /usr/local/bin/composer
125125
composer -V
126-
composer -n config -g vendor-dir htdocs/includes
126+
sudo composer -n config -g vendor-dir htdocs/includes
127+
sudo chmod -R a+rwx /home/travis/.config/composer
127128
echo
128129
129130
- |
@@ -193,8 +194,8 @@ before_script:
193194
phpcs -i | head -
194195
# Check PHP Vardump check version
195196
echo "PHP Vardump check version"
196-
which var_dump_check
197-
var_dump_check --version
197+
which var-dump-check
198+
var-dump-check --version
198199
# Check PHPUnit version
199200
echo "PHPUnit version"
200201
which phpunit

0 commit comments

Comments
 (0)