Refine error handling and Dolibarr detection patterns

Co-authored-by: jmiller-moko <230051081+jmiller-moko@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-04 21:18:23 +00:00
parent 4f88790215
commit 52a7d341ef
3 changed files with 16 additions and 12 deletions

View File

@@ -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##*|}"

View File

@@ -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

View File

@@ -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)