From 52a7d341ef64d72c5b8ce0c3d76bf206e0f68dec Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 4 Jan 2026 21:18:23 +0000 Subject: [PATCH] Refine error handling and Dolibarr detection patterns Co-authored-by: jmiller-moko <230051081+jmiller-moko@users.noreply.github.com> --- .github/workflows/release_pipeline.yml | 9 ++++++--- Makefile | 1 - scripts/lib/extension_utils.py | 18 ++++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release_pipeline.yml b/.github/workflows/release_pipeline.yml index 95cc9a5..5a9d37a 100644 --- a/.github/workflows/release_pipeline.yml +++ b/.github/workflows/release_pipeline.yml @@ -658,13 +658,16 @@ else: mkdir -p "${DIST_DIR}" # Detect platform and extension type using dedicated script - PLATFORM_INFO=$(python3 "${GITHUB_WORKSPACE}/scripts/release/detect_platform.py" "${GITHUB_WORKSPACE}/src") - - if [ $? -ne 0 ] || [ -z "${PLATFORM_INFO}" ]; then + if ! PLATFORM_INFO=$(python3 "${GITHUB_WORKSPACE}/scripts/release/detect_platform.py" "${GITHUB_WORKSPACE}/src"); then echo "ERROR: Could not detect extension platform and type" >> "${GITHUB_STEP_SUMMARY}" exit 1 fi + if [ -z "${PLATFORM_INFO}" ]; then + echo "ERROR: Platform detection returned empty result" >> "${GITHUB_STEP_SUMMARY}" + exit 1 + fi + PLATFORM="${PLATFORM_INFO%%|*}" EXT_TYPE="${PLATFORM_INFO##*|}" diff --git a/Makefile b/Makefile index b3806da..e7fdce2 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,6 @@ install: @command -v composer >/dev/null 2>&1 || { echo "Error: composer not found. Please install composer first."; exit 1; } composer global require "squizlabs/php_codesniffer:^3.0" --with-all-dependencies composer global require "phpstan/phpstan:^1.0" --with-all-dependencies - composer global require "phpstan/extension-installer:^1.0" --with-all-dependencies composer global require "phpcompatibility/php-compatibility:^9.0" --with-all-dependencies composer global require "codeception/codeception" --with-all-dependencies composer global require "vimeo/psalm:^5.0" --with-all-dependencies diff --git a/scripts/lib/extension_utils.py b/scripts/lib/extension_utils.py index 3171676..9945f25 100644 --- a/scripts/lib/extension_utils.py +++ b/scripts/lib/extension_utils.py @@ -134,10 +134,12 @@ def detect_dolibarr_manifest(src_dir: Union[str, Path]) -> Optional[Path]: matches = list(src_path.glob(pattern)) if matches: # Verify it's actually a Dolibarr module descriptor + # Look for extends DolibarrModules pattern for match in matches: try: content = match.read_text(encoding="utf-8") - if "extends DolibarrModules" in content or "class Mod" in content: + # Check for Dolibarr module inheritance pattern + if re.search(r'extends\s+DolibarrModules', content): return match except Exception: continue @@ -218,14 +220,14 @@ def parse_dolibarr_descriptor(descriptor_path: Path) -> Optional[ExtensionInfo]: try: content = descriptor_path.read_text(encoding="utf-8") - # Extract module name from class name (try multiple patterns) - # Pattern 1: class ModMyModule - name_match = re.search(r'class\s+(Mod\w+)', content) - if not name_match: - # Pattern 2: class mod_mymodule (lowercase) - name_match = re.search(r'class\s+(mod_\w+)', content, re.IGNORECASE) + # Extract module name from class that extends DolibarrModules + # Pattern: class ModMyModule extends DolibarrModules + class_match = re.search(r'class\s+(\w+)\s+extends\s+DolibarrModules', content) + if not class_match: + # Fallback: try to find any class definition + class_match = re.search(r'class\s+(\w+)', content) - name = name_match.group(1) if name_match else "unknown" + name = class_match.group(1) if class_match else "unknown" # Extract version version_match = re.search(r'\$this->version\s*=\s*[\'"]([^\'"]+)[\'"]', content)