Skip to content

Commit

Permalink
Try to reduce some ci task for devcamp bugfix contest
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 15, 2024
2 parents 9794bd1 + d9ee8a3 commit 5b42996
Show file tree
Hide file tree
Showing 50 changed files with 504 additions and 321 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/phpstan_baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ env:
jobs:
phpstan:
runs-on: ubuntu-latest
permissions: write-all
# contents: write
# pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -51,7 +54,7 @@ jobs:
phpstan-cache-${{ env.PHP_VERSION }}-
- uses: ruudk/phpstan-baseline-refresh-create-pr-action@main
with:
github_token: ${{ secrets.PAT_GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
phpstan_path: phpstan
configuration_path: phpstan.neon.dist
phpstan_additional_arguments: --memory-limit 7G -a build/phpstan/bootstrap_action.php
Expand Down
102 changes: 0 additions & 102 deletions build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3918,30 +3918,6 @@ parameters:
count: 2
path: ../../htdocs/categories/photos.php

-
message: '#^If condition is always true\.$#'
identifier: if.alwaysTrue
count: 9
path: ../../htdocs/categories/viewcat.php

-
message: '#^Loose comparison using \=\= between ''bank_account'' and ''bank_account'' will always evaluate to true\.$#'
identifier: equal.alwaysTrue
count: 1
path: ../../htdocs/categories/viewcat.php

-
message: '#^Strict comparison using \!\=\= between Account\|Adherent\|Contact\|Product\|Project\|Societe\|Ticket\|User and null will always evaluate to true\.$#'
identifier: notIdentical.alwaysTrue
count: 1
path: ../../htdocs/categories/viewcat.php

-
message: '#^Variable \$elementtype might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/categories/viewcat.php

-
message: '#^Variable \$object might not be defined\.$#'
identifier: variable.undefined
Expand Down Expand Up @@ -4608,12 +4584,6 @@ parameters:
count: 1
path: ../../htdocs/comm/propal/card.php

-
message: '#^Parameter \#4 \$url of function dolGetButtonAction expects array\<int, array\{lang\: string, enabled\: bool, perm\: bool, label\: string, url\: string, urlroot\?\: string, isDropDown\?\: int\<0, 1\>\}\>\|string, array\{0\: array\{lang\: ''orders'', enabled\: bool, perm\: 0\|1, label\: ''AddOrder'', url\: non\-falsy\-string\}, 1\: array\{lang\: ''interventions'', enabled\: bool, perm\: 0\|1, label\: ''AddIntervention'', url\: non\-falsy\-string\}\|array\{lang\: ''orders'', enabled\: bool, perm\: bool, label\: ''AddPurchaseOrder'', url\: non\-falsy\-string\}, 2\: array\{lang\: ''contracts'', enabled\: bool, perm\: 0\|1, label\: ''AddContract'', url\: non\-falsy\-string\}\|array\{lang\: ''interventions'', enabled\: bool, perm\: 0\|1, label\: ''AddIntervention'', url\: non\-falsy\-string\}, 3\?\: array\{lang\: ''contracts'', enabled\: bool, perm\: 0\|1, label\: ''AddContract'', url\: non\-falsy\-string\}\|array\{lang\: ''invoice'', enabled\: bool, perm\: 0\|1, label\: ''CreateBill'', url\: non\-falsy\-string\}, 4\?\: array\{lang\: ''invoice'', enabled\: bool, perm\: 0\|1, label\: ''CreateBill'', url\: non\-falsy\-string\}\} given\.$#'
identifier: argument.type
count: 2
path: ../../htdocs/comm/propal/card.php

-
message: '#^Property CommonObject\:\:\$fk_project \(int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
Expand Down Expand Up @@ -5028,12 +4998,6 @@ parameters:
count: 1
path: ../../htdocs/commande/card.php

-
message: '#^Parameter \#4 \$url of function dolGetButtonAction expects array\<int, array\{lang\: string, enabled\: bool, perm\: bool, label\: string, url\: string, urlroot\?\: string, isDropDown\?\: int\<0, 1\>\}\>\|string, array\{0\: array\{lang\: ''interventions'', enabled\: bool, perm\: 0\|1, label\: ''AddIntervention'', url\: non\-falsy\-string\}, 1\: array\{lang\: ''contracts'', enabled\: bool, perm\: 0\|1, label\: ''AddContract'', url\: non\-falsy\-string\}, 2\: array\{lang\: ''bills'', enabled\: bool, perm\: bool, label\: ''CreateBill'', url\: non\-falsy\-string\}\|array\{lang\: ''sendings'', enabled\: bool, perm\: 0\|1, label\: ''CreateShipment'', url\: non\-falsy\-string\}, 3\?\: array\{lang\: ''bills'', enabled\: bool, perm\: bool, label\: ''CreateBill'', url\: non\-falsy\-string\}\}\|array\{0\: array\{lang\: ''orders'', enabled\: bool, perm\: bool, label\: ''AddPurchaseOrder'', url\: non\-falsy\-string\}, 1\: array\{lang\: ''interventions'', enabled\: bool, perm\: 0\|1, label\: ''AddIntervention'', url\: non\-falsy\-string\}, 2\: array\{lang\: ''contracts'', enabled\: bool, perm\: 0\|1, label\: ''AddContract'', url\: non\-falsy\-string\}, 3\: array\{lang\: ''bills'', enabled\: bool, perm\: bool, label\: ''CreateBill'', url\: non\-falsy\-string\}\|array\{lang\: ''sendings'', enabled\: bool, perm\: 0\|1, label\: ''CreateShipment'', url\: non\-falsy\-string\}, 4\?\: array\{lang\: ''bills'', enabled\: bool, perm\: bool, label\: ''CreateBill'', url\: non\-falsy\-string\}\} given\.$#'
identifier: argument.type
count: 2
path: ../../htdocs/commande/card.php

-
message: '#^Result of && is always false\.$#'
identifier: booleanAnd.alwaysFalse
Expand Down Expand Up @@ -30750,36 +30714,6 @@ parameters:
count: 5
path: ../../htdocs/projet/tasks/time.php

-
message: '#^Parameter \#1 \$hour of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 1
path: ../../htdocs/projet/tasks/time.php

-
message: '#^Parameter \#2 \$minute of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 1
path: ../../htdocs/projet/tasks/time.php

-
message: '#^Parameter \#4 \$month of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 2
path: ../../htdocs/projet/tasks/time.php

-
message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 2
path: ../../htdocs/projet/tasks/time.php

-
message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 2
path: ../../htdocs/projet/tasks/time.php

-
message: '#^Right side of && is always true\.$#'
identifier: booleanAnd.rightAlwaysTrue
Expand Down Expand Up @@ -31884,30 +31818,6 @@ parameters:
count: 1
path: ../../htdocs/public/test/test_arrays.php

-
message: '#^Variable \$conf might not be defined\.$#'
identifier: variable.undefined
count: 3
path: ../../htdocs/public/test/test_badges.php

-
message: '#^Variable \$dolibarr_main_prod might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/public/test/test_badges.php

-
message: '#^Parameter \#7 \$params of function dolGetButtonAction expects array\{confirm\?\: array\{url\?\: string, title\?\: string, content\?\: string, action\-btn\-label\?\: string, cancel\-btn\-label\?\: string, modal\?\: bool\}, attr\?\: array\<string, mixed\>, areDropdownButtons\?\: bool, backtopage\?\: string, lang\?\: string, enabled\?\: bool, perm\?\: int\<0, 1\>, label\?\: string, \.\.\.\}, array\{confirm\: true\} given\.$#'
identifier: argument.type
count: 2
path: ../../htdocs/public/test/test_buttons.php

-
message: '#^Variable \$dolibarr_main_prod might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/public/test/test_buttons.php

-
message: '#^Variable \$dolibarr_main_prod might not be defined\.$#'
identifier: variable.undefined
Expand All @@ -31920,18 +31830,6 @@ parameters:
count: 1
path: ../../htdocs/public/test/test_exec.php

-
message: '#^Variable \$db might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/public/test/test_forms.php

-
message: '#^Variable \$dolibarr_main_prod might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/public/test/test_forms.php

-
message: '#^Variable \$dolibarr_main_prod might not be defined\.$#'
identifier: variable.undefined
Expand Down
86 changes: 66 additions & 20 deletions dev/tools/github_commits_byversion.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,64 @@
#!/bin/bash
# Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>

#
# Count number of commits per user and per version (using date for version detection)
#
#
# Count number of commits per user and per versions (using date for version detection)
#
# shellcheck disable=1113,2002,2006,2086,2164,2219

Releases=("3.9" "4.0" "5.0" "6.0" "7.0" "8.0" "9.0" "10.0" "11.0" "12.0" "13.0" "14.0" "15.0" "16.0" "17.0" "18.0" "19.0" "develop")
let "counter = 0"

echo "Copy script into /tmp/github_commits_byversion.sh"
cp $0 /tmp/github_commits_perversion.sh
cp "$0" /tmp/github_commits_perversion.sh

TEMP_DIR=/tmp/git
DOL_GIT="$TEMP_DIR/dolibarr"
if ! git rev-parse ; then
echo "Delete $TEMP_DIR"
rm -fr "$TEMP_DIR"
echo "Create '$TEMP_DIR' and cd to it"
mkdir "$TEMP_DIR"
cd "$TEMP_DIR" || exit
git clone https://github.com/Dolibarr/dolibarr.git
cd "${DOL_GIT}" || exit
else
if [ -r "${DOL_GIT}" ] ; then
git worktree remove "${DOL_GIT}"
rm -rf "${DOL_GIT}" >& /dev/null
fi
git worktree add --force "${DOL_GIT}" develop
cd "$DOL_GIT" || exit
git pull
fi


# Determine release to check
Releases=("3.9" "4.0" "5.0" "6.0" "7.0" "8.0" "9.0" "10.0" "11.0" "12.0" "13.0" "14.0" "15.0" "16.0" "17.0" "18.0" "19.0" "20.0")
target_version=$(sed -n "s/.*define('DOL_VERSION',[[:space:]]*'\\([0-9]*\\.[0-9]*\\).*/\\1/p" htdocs/filefunc.inc.php)

echo "Delete /tmp/git"
rm -fr /tmp/git
echo "Create and go into /tmp/git"
mkdir /tmp/git
cd /tmp/git
git clone https://github.com/Dolibarr/dolibarr.git
# Default target version in case getting it from filefunc.inc failed
target_version=${target_version:=20.0}

cd /tmp/git/dolibarr
# Setup loop to append required versions
target_major=${target_version%%.*}
last_major=${Releases%%.*}

# Add versions up to target_version
while (( last_major < target_major )); do
((last_major++))
tag="${last_major}.0"
if git rev-parse --verify "origin/$tag" >&/dev/null ; then
Releases+=("$tag")
fi
done

# Always end with develop
Releases+=("develop")


# Now proceed with generating the report for branches in ${Releases[@]}

firstline=1
((counter = 0))
for i in "${Releases[@]}"
do
if [ $firstline -eq 1 ]; then
Expand All @@ -31,21 +70,28 @@ do
echo "=== Version $i (counter $counter):"
echo "Get common commit ID between origin/${Releases[counter]} and origin/${Releases[counter+1]}"
echo "git merge-base origin/${Releases[counter]} origin/${Releases[counter+1]}"
commitidcommon=`git merge-base origin/${Releases[counter]} origin/${Releases[counter+1]}`
commitidcommon=$(git merge-base "origin/${Releases[counter]}" "origin/${Releases[counter+1]}")
echo "Found commitid=$commitidcommon"

echo "Checkout into version $i"
git checkout $i
echo "Checkout version $i"
git checkout --ignore-other-worktrees "$i"
#git shortlog -s -n --after=YYYY-MM-DD --before=YYYY-MM-DD | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion.txt
git shortlog -s -n $commitidcommon.. | iconv -f UTF-8 -t ASCII//TRANSLIT | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion.txt
git shortlog --encoding=utf-8 -s -n "$commitidcommon.." | iconv -f UTF-8 -t ASCII//TRANSLIT | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion.txt
#cat /tmp/github_commits_perversion.txt
echo "Total for version $i:"
echo -n "- Nb of commits: "
git log $commitidcommon.. --pretty=oneline | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion2.txt
cat /tmp/github_commits_perversion2.txt | wc -l
git log "$commitidcommon.." --pretty=oneline | tr '[:lower:]' '[:upper:]' > /tmp/github_commits_perversion2.txt
wc -l < /tmp/github_commits_perversion2.txt
echo -n "- Nb of different authors: "
awk ' { print $2 } ' < /tmp/github_commits_perversion.txt | sort -u | wc -l
echo "======================="
echo
let "counter +=1"
((counter++))
done

# Clean up git directory if it is a worktree
if [ "$(git rev-parse --git-dir)" != "$(git rev-parse --git-common-dir)" ] ; then
cd "$TEMP_DIR" || exit
git -C "$DOL_GIT" worktree remove "$DOL_GIT"
fi
exit
1 change: 1 addition & 0 deletions dev/translation/dynamic_translation_keys.lst
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ Feature
FeatureIsSupportedInInOutModeOnly
Features
FichinterNoContractLinked
FichintersCategoriesArea
FieldNeedSource
FieldTarget
FieldTitle
Expand Down
6 changes: 4 additions & 2 deletions htdocs/admin/tools/ui/components/test_arrays.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*/


// Load Dolibarr environment
Expand Down Expand Up @@ -87,7 +89,7 @@
<div class="wordbreak">
- css (add parameter &amp;theme=newtheme to test another theme or edit css of current theme)<br>
- jmobile (add parameter <a href="<?php echo $_SERVER["PHP_SELF"].'?dol_use_jmobile=1&dol_optimize_smallscreen=1'; ?>">dol_use_jmobile=1&amp;dol_optimize_smallscreen=1</a> and switch to small screen < 570 to enable with emulated jmobile)<br>
- no javascript / usage for bind people (add parameter <a href="<?php echo $_SERVER["PHP_SELF"].'?nojs=1'; ?>">nojs=1</a> to force disable javascript)<br>
- no javascript / usage for blind people (add parameter <a href="<?php echo $_SERVER["PHP_SELF"].'?nojs=1'; ?>">nojs=1</a> to force disable javascript)<br>
- tablednd<br>
</div>

Expand Down Expand Up @@ -379,4 +381,4 @@
</body>
<?php } ?>

</html>
</html>
17 changes: 16 additions & 1 deletion htdocs/admin/tools/ui/components/test_forms.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<?php
/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
//define("NOLOGIN",1); // This means this output page does not require to be logged.
/*if (!defined('NOSESSION')) {
Expand Down Expand Up @@ -26,7 +41,7 @@
This page is a sample of page using Dolibarr HTML widget methods. It is designed to make test with<br>
- css (add parameter &amp;theme=newtheme to test another theme or edit css of current theme)<br>
- jmobile (add parameter <a class="wordbreak" href="<?php echo $_SERVER["PHP_SELF"].'?dol_use_jmobile=1&dol_optimize_smallscreen=1'; ?>">dol_use_jmobile=1&amp;dol_optimize_smallscreen=1</a> and switch to small screen < 570 to enable with emulated jmobile)<br>
- no javascript / usage for bind people (add parameter <a class="wordbreak" href="<?php echo $_SERVER["PHP_SELF"].'?nojs=1'; ?>">nojs=1</a> to force disable javascript)<br>
- no javascript / usage for blind people (add parameter <a class="wordbreak" href="<?php echo $_SERVER["PHP_SELF"].'?nojs=1'; ?>">nojs=1</a> to force disable javascript)<br>
- use with a text browser (add parameter <a class="wordbreak" href="<?php echo $_SERVER["PHP_SELF"].'?textbrowser=1'; ?>">textbrowser=1</a> to force detection of a text browser)<br>
<br><br>

Expand Down
Loading

0 comments on commit 5b42996

Please sign in to comment.