[TikiWiki-commits] [Git][tikiwiki/tiki][master] [ENH] Improve local checks rebase workflow and developer guidance
"ushindi bienvenu \(@usbbush\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a202df01ede5_38194010771ee@gitlab-sidekiq-low-urgency-cpu-bound-v2-9bc94bd84-xpfjs.mail> |
ushindi bienvenu pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
c0943d68 by ushindi bienvenu at 2026-06-03T13:18:22+00:00
[ENH] Improve local checks rebase workflow and developer guidance
---
* [ENH] Improve local checks rebase workflow and developer guidance
* [ENH] Improve local checks rebase workflow and developer guidance
See merge request tikiwiki/tiki!10433
- - - - -
4 changed files:
- .gitlab-ci.yml
- .husky/pre-push
- doc/devtools/get_base_commit.php
- doc/devtools/run_local_checks.php
Changes:
=====================================
.gitlab-ci.yml
=====================================
@@ -161,6 +161,10 @@ composer-ext-check:
stage: tiki-check
needs: []
image: ${DEPENDENCY_PROXY_PREFIX}${BASE_QA_IMAGE}
+ rules:
+ - changes:
+ - "**/composer.json"
+ - "**/composer.lock"
script:
- php doc/devtools/check_composer_extensions.php
@@ -420,6 +424,11 @@ sql-engine:
stage: tiki-check
needs: []
image: ${DEPENDENCY_PROXY_PREFIX}${BASE_QA_IMAGE}
+ rules:
+ - changes:
+ - "**/*.sql"
+ - "installer/**/*"
+ - "db/**/*"
script:
- php -d display_errors=On doc/devtools/check_sql_engine.php
@@ -427,6 +436,11 @@ schema-sql-drop:
stage: tiki-check
needs: []
image: ${DEPENDENCY_PROXY_PREFIX}${BASE_QA_IMAGE}
+ rules:
+ - changes:
+ - "**/*.sql"
+ - "installer/**/*"
+ - "db/**/*"
script:
- php -d display_errors=On doc/devtools/check_schema_sql_drop.php
@@ -434,6 +448,11 @@ schema-naming-convention:
stage: tiki-check
needs: []
image: ${DEPENDENCY_PROXY_PREFIX}${BASE_QA_IMAGE}
+ rules:
+ - changes:
+ - "**/*.sql"
+ - "installer/**/*"
+ - "db/**/*"
script:
- php -d display_errors=On doc/devtools/check_schema_naming_convention.php
@@ -448,8 +467,17 @@ check-security-static:
stage: tiki-check
needs: []
image: ${DEPENDENCY_PROXY_PREFIX}${BASE_QA_IMAGE}
+ rules:
+ - changes:
+ - "**/*.php"
script:
- - php -d display_errors=On doc/devtools/securitycheck.php
+ - *calculate_affected_files
+ - |
+ if [ -n "$PHP_FILES" ]; then
+ printf '%s\n' "$PHP_FILES" | xargs php -d display_errors=On doc/devtools/securitycheck.php
+ else
+ echo "✅ No affected PHP files."
+ fi
translation:
stage: tiki-check
@@ -475,6 +503,10 @@ composer-validates:
stage: tiki-check
needs: []
image: ${DEPENDENCY_PROXY_PREFIX}${BASE_QA_IMAGE}
+ rules:
+ - changes:
+ - "**/composer.json"
+ - "**/composer.lock"
script:
- composer -V | grep "version 2" || composer self-update --2
- composer validate -d vendor_bundled --no-check-all
@@ -488,7 +520,10 @@ composer-could-update-lock:
needs:
- composer
image: ${DEPENDENCY_PROXY_PREFIX}${BASE_QA_IMAGE}
-
+ rules:
+ - changes:
+ - "**/composer.json"
+ - "**/composer.lock"
script:
- composer -V | grep "version 2" || composer self-update --2
- composer update -d vendor_bundled --dry-run
@@ -502,6 +537,10 @@ composer-could-update-lock:
needs:
- composer
image: ${DEPENDENCY_PROXY_PREFIX}${BASE_QA_IMAGE}
+ rules:
+ - changes:
+ - "**/composer.json"
+ - "**/composer.lock"
script:
- cp $(command -v composer) temp/composer.phar
- php temp/composer.phar -V | grep "version 2" || php temp/composer.phar self-update --2
@@ -529,6 +568,11 @@ composer-could-update-lock:
- composer
- composer-dbdiff
image: ${DEPENDENCY_PROXY_PREFIX}${BASE_QA_IMAGE}
+ rules:
+ - changes:
+ - "**/*.php"
+ - "**/composer.lock"
+ - "**/*.sql"
services:
- name: ${DEPENDENCY_PROXY_PREFIX}$IMAGE
alias: mysql,
@@ -622,6 +666,11 @@ sql-engine-conversion:
- composer
- composer-dbdiff
image: ${DEPENDENCY_PROXY_PREFIX}${BASE_QA_IMAGE}
+ rules:
+ - changes:
+ - "**/*.sql"
+ - "installer/**/*"
+ - "**/composer.lock"
services:
- name: ${DEPENDENCY_PROXY_PREFIX}${MYSQL_IMAGE_NEWEST_SUPPORTED}
alias: mysql
@@ -932,27 +981,18 @@ composer-operator-check:
script:
- php doc/devtools/check_caret_operator.php
rules:
- - if: $CI_PIPELINE_SOURCE == "merge_request_event"
- when: always
- - if: $CI_PIPELINE_SOURCE == "push"
- when: always
- changes:
- - "**/composer.json"
- allow_failure: false
+ - "**/composer.json"
check-alphabetical-list:
stage: unit-tests
image: ${DEPENDENCY_PROXY_PREFIX}${BASE_QA_IMAGE}
needs:
- composer
- script:
- - php doc/devtools/check_alphabetical_list.php
rules:
- - if: $CI_PIPELINE_SOURCE == "merge_request_event"
- when: always
- - if: $CI_PIPELINE_SOURCE == "push"
- when: always
- changes:
- "**/composer.json"
- "**/package.json"
+ script:
+ - php doc/devtools/check_alphabetical_list.php
allow_failure: false
=====================================
.husky/pre-push
=====================================
@@ -6,7 +6,13 @@ REPO_ROOT=$(git rev-parse --show-toplevel)
php "$REPO_ROOT/doc/devtools/run_local_checks.php" ${TIKI_LOCAL_CHECKS_ARGS:-} || {
echo "❌ Pre-push checks failed. Push cancelled."
- echo "To skip specific checks, run:"
- echo 'TIKI_LOCAL_CHECKS_ARGS="--skip=2,5,9,..." git push'
+ echo
+ echo "Examples:"
+ echo ' TIKI_LOCAL_CHECKS_ARGS="--skip=1,2,5,9" git push'
+ echo ' TIKI_LOCAL_CHECKS_ARGS="--skip-rebase" git push'
+ echo ' TIKI_LOCAL_CHECKS_ARGS="--skip=2,5 --skip-rebase" git push'
+ echo
+ echo "Use --skip to bypass specific checks."
+ echo "Use --skip-rebase to skip the automatic rebase against the detected target branch."
exit 1
}
\ No newline at end of file
=====================================
doc/devtools/get_base_commit.php
=====================================
@@ -1,12 +1,12 @@
<?php
-/**
- * Automatically detects the central TikiWiki remote, performs a safety rebase,
- * handles conflicts, and returns the target base commit hash/name for diffing.
- *
- * @return string The base commit to diff against (e.g., 'origin/master')
- */
-function getBaseCommitOrAbort(bool $skipRebase = false): string
+// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
+//
+// All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+
+
+function getTikiTargetRemote(): string
{
exec('git remote -v', $remoteLines);
@@ -24,35 +24,71 @@ function getBaseCommitOrAbort(bool $skipRebase = false): string
}
}
}
- if (! $skipRebase) {
- echo "🔄 Target tracking remote identified as: '$targetRemote'" . PHP_EOL;
- echo "🔄 Attempting to fetch and rebase master..." . PHP_EOL;
- exec("git pull --rebase $targetRemote master 2>&1", $rebaseOutput, $rebaseCode);
+ return $targetRemote;
+}
+
+function getTikiTargetBranch(): string
+{
+ require_once __DIR__ . '/../../lib/setup/twversion.class.php';
+
+ $twVersion = new TWVersion();
+
+ if ($twVersion->branch === 'trunk') {
+ return 'master';
+ }
+
+ if ($twVersion->branch === 'stable') {
+ return preg_replace('/^(\d+)\..*$/', '$1.x', $twVersion->version);
+ }
+
+ return 'master';
+}
+
+function hasLocalChanges(): bool
+{
+ exec('git status --porcelain', $statusOutput);
+
+ return ! empty($statusOutput);
+}
+/**
+ * Automatically detects the central TikiWiki remote, performs a safety rebase,
+ * handles conflicts, and returns the target base commit hash/name for diffing.
+ *
+ * @return string The base commit to diff against (e.g., 'origin/master')
+ */
+function getBaseCommitOrAbort(bool $skipRebase = false): string
+{
+
+ $targetRemote = getTikiTargetRemote();
+ $targetBranch = getTikiTargetBranch();
+
+ echo "🔄 Target tracking remote identified as: '$targetRemote/$targetBranch'" . PHP_EOL;
+
+ if ($skipRebase) {
+ echo "⏭️ Skipping automatic rebase." . PHP_EOL;
+ exec("git fetch $targetRemote $targetBranch");
+ } elseif (hasLocalChanges()) {
+ echo PHP_EOL . "⚠️ Pending changes detected. Skipped Automatic rebase." . PHP_EOL;
+ exec("git fetch $targetRemote $targetBranch");
+ } else {
+ echo "🔄 Attempting to fetch and rebase $targetBranch..." . PHP_EOL;
+
+ exec("git pull --rebase $targetRemote $targetBranch 2>&1", $rebaseOutput, $rebaseCode);
+
if ($rebaseCode !== 0) {
echo PHP_EOL . "❌ Automatic rebase failed." . PHP_EOL;
- echo "The branch could not be rebased onto '$targetRemote/master'." . PHP_EOL;
- echo PHP_EOL;
- echo "Common causes include:" . PHP_EOL;
- echo " - Merge conflicts" . PHP_EOL;
- echo " - Uncommitted local changes" . PHP_EOL;
- echo " - Authentication or network issues" . PHP_EOL;
- echo " - Remote repository access problems" . PHP_EOL;
+ echo "The branch could not be rebased onto '$targetRemote/$targetBranch'." . PHP_EOL;
+ echo "Resolve the issue and try again." . PHP_EOL;
+ echo 'To continue without rebasing: TIKI_LOCAL_CHECKS_ARGS="--skip-rebase" git push' . PHP_EOL;
echo PHP_EOL;
- echo "If you do not want to rebase at this time, you can rerun the checks with:" . PHP_EOL;
- echo 'TIKI_LOCAL_CHECKS_ARGS="--skip-rebase" git push' . PHP_EOL;
- echo PHP_EOL;
- echo "Otherwise, resolve the issue above and try again." . PHP_EOL;
exit(1);
}
- echo "✅ Successfully rebased with $targetRemote/master. Proceeding with checks..." . PHP_EOL . PHP_EOL;
- } else {
- echo "⏭️ Skipping automatic rebase." . PHP_EOL;
- exec("git fetch $targetRemote master");
- }
+ echo "✅ Successfully rebased with $targetRemote/$targetBranch. Proceeding with checks..." . PHP_EOL . PHP_EOL;
+ }
// Robust Merge-Base Resolution to get the clean fork point
- exec("git merge-base $targetRemote/master HEAD 2>&1", $mergeBaseOut, $mergeBaseCode);
+ exec("git merge-base $targetRemote/$targetBranch HEAD 2>&1", $mergeBaseOut, $mergeBaseCode);
- return ($mergeBaseCode === 0 && ! empty($mergeBaseOut[0])) ? $mergeBaseOut[0] : "$targetRemote/master";
+ return ($mergeBaseCode === 0 && ! empty($mergeBaseOut[0])) ? $mergeBaseOut[0] : "$targetRemote/$targetBranch";
}
=====================================
doc/devtools/run_local_checks.php
=====================================
@@ -1,5 +1,10 @@
<?php
+// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
+//
+// All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+
$options = getopt('h', ['help', 'skip:', 'skip-rebase']);
if (isset($options['h']) || isset($options['help'])) {
@@ -136,6 +141,20 @@ $steps[] = ['Check packages alphabetical list', 'php doc/devtools/check_alphabet
$failedChecks = [];
+$checkDevDep = true;
+if (! file_exists('./vendor_bundled/vendor/squizlabs/php_codesniffer/bin/phpcs')) {
+ echo "⚠️ Composer development dependencies are not installed." . PHP_EOL;
+ echo "The following checks will be skipped:" . PHP_EOL;
+ echo " - SmartyLint" . PHP_EOL;
+ echo " - PHPLint" . PHP_EOL;
+ echo " - PHPCS" . PHP_EOL;
+ echo PHP_EOL;
+ echo "To enable all local checks, run:" . PHP_EOL;
+ echo " composer -d vendor_bundled install" . PHP_EOL;
+ echo PHP_EOL;
+ $checkDevDep = false;
+}
+
foreach ($steps as $index => [$label, $cmd]) {
$stepNumber = $index + 1;
@@ -144,9 +163,14 @@ foreach ($steps as $index => [$label, $cmd]) {
continue;
}
- echo "▶️ Step $stepNumber: $label" . PHP_EOL;
+ echo "Step $stepNumber: $label" . PHP_EOL;
echo " $cmd" . PHP_EOL;
+ if (str_contains($cmd, 'vendor_bundled/vendor/') && ! $checkDevDep) {
+ echo "⏭️ Skipped: Composer development dependencies are not installed." . PHP_EOL;
+ echo " Run 'composer -d vendor_bundled install' to enable this check." . PHP_EOL;
+ continue;
+ }
$output = [];
exec($cmd . ' 2>&1', $output, $code);
@@ -161,7 +185,7 @@ foreach ($steps as $index => [$label, $cmd]) {
echo "❌ Push blocked due to failure at step $stepNumber ($label)." . PHP_EOL;
echo "Please fix the failing check above and try pushing again." . PHP_EOL;
- // ⚡ FAIL FAST: Exit immediately so the user doesn't waste time waiting
+ //Exit immediately so the user doesn't waste time waiting
exit(1);
}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/c0943d68786d5e2400708a03ab5838e432cb163e
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/c0943d68786d5e2400708a03ab5838e432cb163e
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs