Merge pull request #42 from DeterminateSystems/hoverbear/ds-427-add-ci-jobs-to-do-install-uninstall

Add new CI jobs that test install/uninstall
This commit is contained in:
Ana Hobden 2022-11-09 13:37:59 -08:00 committed by GitHub
commit 8b3205e944
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 81 additions and 10 deletions

View file

@ -82,6 +82,33 @@ jobs:
path: |
result/bin/harmonic
RunX86Linux:
runs-on: ubuntu-latest
needs: BuildX86Linux
steps:
- uses: actions/download-artifact@v3
with:
name: harmonic-x86_64-linux
- name: Set executable
run: chmod +x ./harmonic
- name: Initial install
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic install linux-multi --no-confirm
- name: Test run
run: |
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
nix run nixpkgs#fortune
- name: Initial uninstall
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm
- name: Repeated install
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic install linux-multi --no-confirm
- name: Repeated test run
run: |
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
nix run nixpkgs#fortune
- name: Repeated uninstall
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm
BuildX86Darwin:
runs-on: macos-latest
steps:
@ -99,3 +126,30 @@ jobs:
name: harmonic-x86_64-darwin
path: |
result/bin/harmonic
RunX86Darwin:
runs-on: macos-latest
needs: BuildX86Darwin
steps:
- uses: actions/download-artifact@v3
with:
name: harmonic-x86_64-darwin
- name: Set executable
run: chmod +x ./harmonic
- name: Initial install
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic install darwin-multi --no-confirm
- name: Test run
run: |
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
nix run nixpkgs#fortune
- name: Initial uninstall
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm
- name: Repeated install
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic install darwin-multi --no-confirm
- name: Repeated test run
run: |
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
nix run nixpkgs#fortune
- name: Repeated uninstall
run: sudo RUST_LOG=harmonic=trace RUST_BACKTRACE=full ./harmonic uninstall --no-confirm

View file

@ -132,6 +132,15 @@ impl Action for ConfigureNixDaemonService {
execute_command(Command::new("systemctl").arg("daemon-reload"))
.await
.map_err(|e| ConfigureNixDaemonServiceError::Command(e).boxed())?;
execute_command(
Command::new("systemctl")
.arg("enable")
.arg("--now")
.arg("nix-daemon.socket"),
)
.await
.map_err(|e| ConfigureNixDaemonServiceError::Command(e).boxed())?;
},
};
@ -181,11 +190,11 @@ impl Action for ConfigureNixDaemonService {
.map_err(|e| ConfigureNixDaemonServiceError::Command(e).boxed())?;
},
_ => {
execute_command(Command::new("systemctl").args(["disable", SOCKET_SRC]))
execute_command(Command::new("systemctl").args(["disable", SOCKET_SRC, "--now"]))
.await
.map_err(|e| ConfigureNixDaemonServiceError::Command(e).boxed())?;
execute_command(Command::new("systemctl").args(["disable", SERVICE_SRC]))
execute_command(Command::new("systemctl").args(["disable", SERVICE_SRC, "--now"]))
.await
.map_err(|e| ConfigureNixDaemonServiceError::Command(e).boxed())?;

View file

@ -90,9 +90,13 @@ impl Action for StartSystemdUnit {
tracing::debug!("Stopping systemd unit");
// TODO(@Hoverbear): Handle proxy vars
execute_command(Command::new("systemctl").arg("stop").arg(format!("{unit}")))
.await
.map_err(|e| StartSystemdUnitError::Command(e).boxed())?;
execute_command(
Command::new("systemctl")
.arg("disable")
.arg(format!("{unit}")),
)
.await
.map_err(|e| StartSystemdUnitError::Command(e).boxed())?;
tracing::trace!("Stopped systemd unit");
*action_state = ActionState::Completed;

View file

@ -60,11 +60,16 @@ impl CommandExecute for Install {
}
if let Err(err) = plan.install().await {
tracing::error!("{:?}", eyre!(err));
if !interaction::confirm(plan.describe_revert(explain)).await? {
interaction::clean_exit_with_message("Okay, didn't do anything! Bye!").await;
let error = eyre!(err).wrap_err("Install failure");
if !no_confirm {
tracing::error!("{:?}", error);
if !interaction::confirm(plan.describe_revert(explain)).await? {
interaction::clean_exit_with_message("Okay, didn't do anything! Bye!").await;
}
plan.revert().await?
} else {
return Err(error);
}
plan.revert().await?
}
Ok(ExitCode::SUCCESS)

View file

@ -31,7 +31,6 @@ impl Planner for LinuxMulti {
Box::new(CreateDirectory::plan("/nix", None, None, 0o0755, true).await?),
Box::new(ProvisionNix::plan(self.settings.clone()).await?),
Box::new(ConfigureNix::plan(self.settings).await?),
Box::new(StartSystemdUnit::plan("nix-daemon.socket".into()).await?),
],
})
}