Adding --stale option to mark all artefacts stale
Publish PHP Package / docker (push) Successful in 7s
Details
Publish PHP Package / docker (push) Successful in 7s
Details
This commit is contained in:
parent
19ec09d99a
commit
cfa26d1497
|
@ -9,15 +9,19 @@ class TaskmanArtefact
|
|||
private array $sources_fn = array();
|
||||
private array $sources_spec = array();
|
||||
private iterable $sources = array();
|
||||
//cached array of source indices which affected staleness of this artefact
|
||||
private array $sources_affected = array();
|
||||
//cached array of exact source files affected by incremental file changes
|
||||
private array $sources_changed = array();
|
||||
private array $sources_changed_fn = array();
|
||||
private array $sources_affected = array();
|
||||
private bool $force_stale = false;
|
||||
|
||||
function __construct(\taskman\TaskmanTask $task, string $path, array $sources_spec)
|
||||
function __construct(\taskman\TaskmanTask $task, string $path, array $sources_spec, bool $force_stale = false)
|
||||
{
|
||||
$this->task = $task;
|
||||
$this->path = $path;
|
||||
$this->sources_spec = $sources_spec;
|
||||
$this->force_stale = $force_stale;
|
||||
}
|
||||
|
||||
function getTask() : \taskman\TaskmanTask
|
||||
|
@ -89,13 +93,6 @@ class TaskmanArtefact
|
|||
{
|
||||
if(!isset($this->sources_affected[$idx]))
|
||||
{
|
||||
//NOTE: more conservative implementation which always checks for staleness
|
||||
//$sources = $this->task->getFileChanges() != null ?
|
||||
// //tries to match changed files with sources spec
|
||||
// $this->getChangedSources($idx) :
|
||||
// $this->getSources($idx);
|
||||
//$this->sources_affected[$idx] = is_stale($this->getPath(), $sources);
|
||||
|
||||
//NOTE: if there any file changes we simply check if there are any changed sources,
|
||||
// and if yes then we mark the artefact as affected
|
||||
if($this->task->getFileChanges() != null)
|
||||
|
@ -134,6 +131,9 @@ class TaskmanArtefact
|
|||
|
||||
foreach($all_src_specs as $src_idx => $src_spec)
|
||||
{
|
||||
if($this->force_stale)
|
||||
$this->sources_affected[$src_idx] = true;
|
||||
|
||||
//[[dir1, dir2, ..], [ext1, ext2, ..]]
|
||||
if(is_array($src_spec) && count($src_spec) == 2 &&
|
||||
is_array($src_spec[0]) && is_array($src_spec[1]))
|
||||
|
|
|
@ -23,6 +23,7 @@ function _collect_tasks() : array
|
|||
global $TASKMAN_TASKS;
|
||||
global $TASKMAN_TASK_ALIASES;
|
||||
global $TASKMAN_FILE_CHANGES;
|
||||
global $TASKMAN_STALE_ARTEFACTS;
|
||||
|
||||
$TASKMAN_TASKS = array();
|
||||
$TASKMAN_TASK_ALIASES = array();
|
||||
|
@ -44,7 +45,7 @@ function _collect_tasks() : array
|
|||
else
|
||||
$func = $args[1];
|
||||
|
||||
$task = new \taskman\TaskmanTask($func, $name, $props, $TASKMAN_FILE_CHANGES);
|
||||
$task = new \taskman\TaskmanTask($func, $name, $props, $TASKMAN_FILE_CHANGES, $TASKMAN_STALE_ARTEFACTS);
|
||||
}
|
||||
else
|
||||
throw new Exception("Task '$name' is invalid");
|
||||
|
@ -172,6 +173,7 @@ function _process_argv(array &$argv)
|
|||
global $TASKMAN_NO_DEPS;
|
||||
global $TASKMAN_FILE_CHANGES;
|
||||
global $TASKMAN_SHOW_BENCH;
|
||||
global $TASKMAN_STALE_ARTEFACTS;
|
||||
|
||||
$filtered = array();
|
||||
$process_defs = false;
|
||||
|
@ -214,6 +216,10 @@ function _process_argv(array &$argv)
|
|||
{
|
||||
$TASKMAN_SHOW_BENCH = true;
|
||||
}
|
||||
else if($v == '--stale')
|
||||
{
|
||||
$TASKMAN_STALE_ARTEFACTS = true;
|
||||
}
|
||||
else if($v == '-c')
|
||||
{
|
||||
if(!isset($argv[$i+1]))
|
||||
|
|
|
@ -16,6 +16,7 @@ $GLOBALS['TASKMAN_LOGGER'] = '\taskman\internal\_default_logger';
|
|||
$GLOBALS['TASKMAN_ERROR_HANDLER'] = null;
|
||||
$GLOBALS['TASKMAN_START_TIME'] = 0;
|
||||
$GLOBALS['TASKMAN_FILES_CHANGES'] = null;
|
||||
$GLOBALS['TASKMAN_STALE_ARTEFACTS'] = false;
|
||||
$GLOBALS['TASKMAN_SHOW_BENCH'] = false;
|
||||
|
||||
include_once(__DIR__ . '/internal.inc.php');
|
||||
|
@ -56,8 +57,15 @@ class TaskmanTask
|
|||
|
||||
private ?TaskmanFileChanges $file_changes;
|
||||
|
||||
function __construct(\Closure $func, string $name,
|
||||
array $props = array(), ?TaskmanFileChanges $file_changes = null)
|
||||
private bool $stale_artefacts = false;
|
||||
|
||||
function __construct(
|
||||
\Closure $func,
|
||||
string $name,
|
||||
array $props = array(),
|
||||
?TaskmanFileChanges $file_changes = null,
|
||||
bool $stale_artefacts = false
|
||||
)
|
||||
{
|
||||
$refl = new \ReflectionFunction($func);
|
||||
$this->file = $refl->getFileName();
|
||||
|
@ -68,6 +76,8 @@ class TaskmanTask
|
|||
$this->props = $props;
|
||||
|
||||
$this->file_changes = $file_changes;
|
||||
|
||||
$this->stale_artefacts = $stale_artefacts;
|
||||
}
|
||||
|
||||
function getName() : string
|
||||
|
@ -136,7 +146,7 @@ class TaskmanTask
|
|||
if(is_array($specs))
|
||||
{
|
||||
foreach($specs as $dst => $src_spec)
|
||||
$artefacts[] = new artefact\TaskmanArtefact($this, $dst, $src_spec);
|
||||
$artefacts[] = new artefact\TaskmanArtefact($this, $dst, $src_spec, $this->stale_artefacts);
|
||||
}
|
||||
|
||||
return $artefacts;
|
||||
|
|
Loading…
Reference in New Issue