diff options
author | Lars Wirzenius <liw@liw.fi> | 2024-01-26 20:21:49 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2024-01-26 20:21:49 +0200 |
commit | 88eec281b8ae41fdd3074a5b764e5114741eedf4 (patch) | |
tree | 4fb3e9972352856dd5c5446c5346cb0e3caccb71 | |
parent | e05e9f7eb69258b0909625289c4eb599d3cc8b47 (diff) | |
download | ambient-driver-88eec281b8ae41fdd3074a5b764e5114741eedf4.tar.gz |
feat! add a dput post-plan action
Also drop the `publish-artifacts` field from the projects file.
This is a breaking change.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Sponsored-by: author
-rw-r--r-- | src/action.rs | 17 | ||||
-rw-r--r-- | src/project.rs | 5 | ||||
-rw-r--r-- | src/run.rs | 16 |
3 files changed, 17 insertions, 21 deletions
diff --git a/src/action.rs b/src/action.rs index c62a286..7669a2c 100644 --- a/src/action.rs +++ b/src/action.rs @@ -10,7 +10,7 @@ use crate::{ config::RunCommand, project::{Project, State}, qemu, - util::{rsync_server, UtilError}, + util::{changes_file, dput, rsync_server, UtilError}, vdrive::{VirtualDriveBuilder, VirtualDriveError}, }; @@ -47,6 +47,7 @@ pub enum PostAction { Dummy, Pwd, Rsync, + Dput, } impl PostAction { @@ -65,6 +66,7 @@ impl PostAction { Self::Dummy => dummy(), Self::Pwd => pwd(project), Self::Rsync => rsync(state, run), + Self::Dput => dput_action(state, run), } } } @@ -88,6 +90,16 @@ fn rsync(state: &State, run: &RunCommand) -> Result<(), ActionError> { Ok(()) } +fn dput_action(state: &State, run: &RunCommand) -> Result<(), ActionError> { + if let Some(target) = &run.dput_target() { + let changes = changes_file(&state.artifactsdir())?; + dput(target, &changes)?; + } else { + return Err(ActionError::DputTargetMissing); + } + Ok(()) +} + fn cargo_fetch(project: &Project, state: &State) -> Result<(), ActionError> { let cargo_home = state.statedir().join("dependencies"); // FIXME: hardcoded pathname if !cargo_home.exists() { @@ -405,6 +417,9 @@ pub enum ActionError { #[error("for the rsync action you must specify an rsync target (config or command line)")] RsyncTargetMissing, + + #[error("for the dput action you must specify a dput target (config or command line)")] + DputTargetMissing, } #[cfg(test)] diff --git a/src/project.rs b/src/project.rs index 8ffc03d..d7dbdb7 100644 --- a/src/project.rs +++ b/src/project.rs @@ -51,7 +51,6 @@ pub struct Project { pre_plan: Option<Vec<PreAction>>, plan: Option<Vec<Action>>, post_plan: Option<Vec<PostAction>>, - publish_artifacts: Option<bool>, artifact_max_size: Option<u64>, } @@ -92,10 +91,6 @@ impl Project { &self.image } - pub fn publish_artifacts(&self) -> bool { - self.publish_artifacts.unwrap_or(false) - } - pub fn artifact_max_size(&self) -> Option<u64> { self.artifact_max_size } @@ -14,7 +14,7 @@ use crate::{ plan::{Plan, PlanError}, project::{Project, ProjectError, Projects, State}, qemu::{self, Qemu, QemuError}, - util::{changes_file, dput, mkdir, mkdir_child, recreate_dir, UtilError}, + util::{mkdir, mkdir_child, recreate_dir, UtilError}, vdrive::{VirtualDriveBuilder, VirtualDriveError}, }; @@ -43,8 +43,6 @@ fn cmd_run(config: &EffectiveConfig, run: &RunCommand) -> Result<(), RunError> { mkdir(&dependencies)?; } - let mut dput_target = None; - for (name, project) in chosen(run, &projects) { let (do_run, mut state) = should_run(run, statedir, name, project)?; @@ -113,18 +111,6 @@ fn cmd_run(config: &EffectiveConfig, run: &RunCommand) -> Result<(), RunError> { let vdrive = VirtualDriveBuilder::default().filename(&artifact).open()?; vdrive.extract_to(&artifactsdir)?; - if project.publish_artifacts() { - if let Some(target) = run.dput_target() { - dput_target = Some(target); - } - } - - if let Some(target) = dput_target { - debug!("publishing artifacts with dput {}", target); - let changes = changes_file(&artifactsdir)?; - dput(target, &changes)?; - } - debug!("Executing post-plan steps"); for action in project.post_plan() { action.execute(project, &state, run)?; |