Skip to content

Commit 5b59822

Browse files
committed
fix: guard file-path constants with defined() for CI compatibility
1 parent 8ec8729 commit 5b59822

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

source/compose.manager/include/Defines.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ function locate_compose_root($name)
1818
$compose_root = locate_compose_root($sName);
1919

2020
// Centralised file-path constants — avoid scattering identical literals
21-
define('COMPOSE_UPDATE_STATUS_FILE', '/boot/config/plugins/compose.manager/update-status.json');
22-
define('COMPOSE_STACK_ORDER_FILE', '/boot/config/plugins/compose.manager/stack-order.json');
23-
define('UNRAID_UPDATE_STATUS_FILE', '/var/lib/docker/unraid-update-status.json');
24-
define('PENDING_RECHECK_FILE', '/boot/config/plugins/compose.manager/pending-recheck.json');
25-
define('COMPOSE_TTYD_SOCKET_DIR', '/var/tmp');
21+
// Each constant is guarded with defined() so the test bootstrap can pre-define them
22+
// to writable temp paths (CI environments lack /boot and /var/lib/docker).
23+
defined('COMPOSE_UPDATE_STATUS_FILE') || define('COMPOSE_UPDATE_STATUS_FILE', '/boot/config/plugins/compose.manager/update-status.json');
24+
defined('COMPOSE_STACK_ORDER_FILE') || define('COMPOSE_STACK_ORDER_FILE', '/boot/config/plugins/compose.manager/stack-order.json');
25+
defined('UNRAID_UPDATE_STATUS_FILE') || define('UNRAID_UPDATE_STATUS_FILE', '/var/lib/docker/unraid-update-status.json');
26+
defined('PENDING_RECHECK_FILE') || define('PENDING_RECHECK_FILE', '/boot/config/plugins/compose.manager/pending-recheck.json');
27+
defined('COMPOSE_TTYD_SOCKET_DIR') || define('COMPOSE_TTYD_SOCKET_DIR', '/var/tmp');
2628

2729
/**
2830
* Reserved filename at the compose root level used by the plugin installer

tests/bootstrap.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ function composeLogger($message, $data = null, $type = 'daemon', $level = 'info'
2727
}
2828
}
2929

30+
// Pre-define /boot and /var/lib/docker constants before Defines.php is loaded
31+
// so they resolve to writable temp paths on CI where /boot does not exist.
32+
$_bootConfigTemp = sys_get_temp_dir() . '/compose_manager_boot_config';
33+
if (!is_dir($_bootConfigTemp)) {
34+
mkdir($_bootConfigTemp, 0755, true);
35+
}
36+
define('COMPOSE_UPDATE_STATUS_FILE', $_bootConfigTemp . '/update-status.json');
37+
define('COMPOSE_STACK_ORDER_FILE', $_bootConfigTemp . '/stack-order.json');
38+
define('UNRAID_UPDATE_STATUS_FILE', sys_get_temp_dir() . '/unraid-update-status.json');
39+
define('PENDING_RECHECK_FILE', $_bootConfigTemp . '/pending-recheck.json');
40+
define('COMPOSE_TTYD_SOCKET_DIR', sys_get_temp_dir());
41+
unset($_bootConfigTemp);
42+
3043
// Load the plugin-tests framework
3144
require_once __DIR__ . '/framework/src/php/bootstrap.php';
3245

0 commit comments

Comments
 (0)