summaryrefslogtreecommitdiffstats
path: root/src/executor.rs
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2021-09-29 00:14:20 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2021-09-29 20:52:52 +0200
commitbbc122d8b9b0d77fafaab1bc286cd42cdda0be5f (patch)
treeea4f91528b7a5048d0762412c533867b58dcef2c /src/executor.rs
parenta60ff18853cb00c12501d9c564f872a61d415eac (diff)
downloadrebel-bbc122d8b9b0d77fafaab1bc286cd42cdda0be5f.tar
rebel-bbc122d8b9b0d77fafaab1bc286cd42cdda0be5f.zip
executor: evalute fetch filename using template engine
Diffstat (limited to 'src/executor.rs')
-rw-r--r--src/executor.rs39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/executor.rs b/src/executor.rs
index 8e87fe1..69e869d 100644
--- a/src/executor.rs
+++ b/src/executor.rs
@@ -100,22 +100,33 @@ impl<'ctx> Executor<'ctx> {
.all(|dep| self.tasks_done.contains_key(&dep))
}
- fn task_deps(&self, task: &TaskRef<'ctx>) -> HashMap<DependencyHash, Dependency> {
+ fn fetch_deps(&self, task: &TaskRef<'ctx>) -> Result<Vec<Dependency>> {
let task_def = &self.ctx[task.id];
task_def
.fetch
.iter()
- .map(|Fetch { name, sha256 }| Dependency::Fetch {
- name: name.clone(),
- sha256: *sha256,
+ .map(|Fetch { name, sha256 }| {
+ Ok(Dependency::Fetch {
+ name: self.tpl.eval_raw(name, &task.args).with_context(|| {
+ format!("Failed to evaluate fetch filename for task {}", task)
+ })?,
+ sha256: *sha256,
+ })
})
+ .collect()
+ }
+
+ fn task_deps(&self, task: &TaskRef<'ctx>) -> Result<HashMap<DependencyHash, Dependency>> {
+ let fetch_deps = self.fetch_deps(task)?;
+
+ Ok(fetch_deps
+ .into_iter()
.chain(
resolve::runtime_depends(
self.ctx,
self.ctx
.get_build_depends(task)
- .with_context(|| format!("invalid build depends for {}", task))
- .unwrap(),
+ .with_context(|| format!("invalid build depends for {}", task))?,
)
.expect("invalid runtime depends of build_depends")
.iter()
@@ -130,8 +141,7 @@ impl<'ctx> Executor<'ctx> {
self.ctx,
self.ctx
.get_host_depends(task)
- .with_context(|| format!("invalid depends for {}", task))
- .unwrap(),
+ .with_context(|| format!("invalid depends for {}", task))?,
)
.expect("invalid runtime depends of host_depends")
.iter()
@@ -142,12 +152,12 @@ impl<'ctx> Executor<'ctx> {
}),
)
.map(|dep| (dep.dependency_hash(), dep))
- .collect()
+ .collect())
}
fn run_one(&self, task_ref: &TaskRef<'ctx>, runner: &impl runner::Runner) -> Result<TaskMeta> {
let task_def = &self.ctx[task_ref.id];
- let task_deps = self.task_deps(task_ref);
+ let task_deps = self.task_deps(task_ref)?;
let task_output = task_def
.output
.iter()
@@ -169,9 +179,12 @@ impl<'ctx> Executor<'ctx> {
})
.unwrap_or_default();
- let command = self.tpl.eval(&task_def, &task_ref.args).with_context(|| {
- format!("Failed to evaluate command template for task {}", task_ref)
- })?;
+ let command = self
+ .tpl
+ .eval(&task_def.action.run, &task_ref.args)
+ .with_context(|| {
+ format!("Failed to evaluate command template for task {}", task_ref)
+ })?;
let input = runner::TaskInput {
command,