refactor: keep recordings on an orphan branch

This commit is contained in:
Willem Vanhulle committed 2026-10-30 19:59:46 +01:00
1 parent d4bd3b4b76
commit daaad6771f
9 files changed
+80 -13

No files matched your search

+6
View File
@@ -1,3 +1,4 @@
mod publish_recordings;
mod record_screencasts;
mod sync_default_config;
mod task_error;
@@ -20,6 +21,10 @@ enum Task {
screenshots to WebP in recordings/"
)]
RecordScreencasts(RecordScreencastsOptions),
#[command(
about = "Replace the recordings branch on origin with a single commit holding recordings/"
)]
PublishRecordings,
#[command(
about = "Rewrite the defaults block in docs/configuration.md from `bootvine defaults`"
)]
@@ -41,6 +46,7 @@ fn main() -> ExitCode {
Task::RecordScreencasts(options) => {
record_screencasts::record_screencasts(&options.vm_check_outputs)
}
Task::PublishRecordings => publish_recordings::publish_recordings(),
Task::SyncDefaultConfig => sync_default_config::sync_default_config(),
};
match outcome {
+38
View File
@@ -0,0 +1,38 @@
use std::path::Path;
use xshell::{Shell, cmd};
use crate::{record_screencasts::RECORDINGS_DIRECTORY, task_error::TaskError};
const RECORDINGS_BRANCH: &str = "refs/heads/recordings";
pub fn publish_recordings() -> Result<(), TaskError> {
if !Path::new(RECORDINGS_DIRECTORY).is_dir() {
return Err(TaskError::RecordingsMissing);
}
let shell = Shell::new()?;
let git_directory = cmd!(shell, "git rev-parse --absolute-git-dir").read()?;
let temporary_directory = shell.create_temp_dir()?;
let _index_override = shell.push_env(
"GIT_INDEX_FILE",
temporary_directory.path().join("recordings-index"),
);
let _git_directory_override = shell.push_env("GIT_DIR", &git_directory);
let _recordings_directory = shell.push_dir(RECORDINGS_DIRECTORY);
cmd!(shell, "git --work-tree=. add --all --force .")
.quiet()
.run()?;
let recordings_tree = cmd!(shell, "git write-tree").read()?;
let recordings_commit = cmd!(
shell,
"git commit-tree {recordings_tree} -m 'chore: sample recordings [skip ci]'"
)
.read()?;
let branch = RECORDINGS_BRANCH;
cmd!(
shell,
"git push --force origin {recordings_commit}:{branch}"
)
.run()?;
Ok(())
}
+7 -2
View File
@@ -13,6 +13,7 @@ const TAPES: [&str; 2] = [
"scripted-demos/tapes/scripted-shutdown.tape",
];
const RECORDING_FRAME_MILLISECONDS: &str = "500";
pub const RECORDINGS_DIRECTORY: &str = "recordings";
fn sorted_entries(directory: &Path) -> Result<Vec<PathBuf>, TaskError> {
let read_failure = |source| TaskError::File {
@@ -106,10 +107,14 @@ fn encode_machine_recording(
}
pub fn record_screencasts(vm_check_outputs: &Path) -> Result<(), TaskError> {
let recordings = Path::new("recordings");
if !recordings.is_dir() {
if !TAPES.iter().all(|tape| Path::new(tape).is_file()) {
return Err(TaskError::NotInRepositoryRoot);
}
let recordings = Path::new(RECORDINGS_DIRECTORY);
fs::create_dir_all(recordings).map_err(|source| TaskError::File {
path: recordings.to_path_buf(),
source,
})?;
let shell = Shell::new()?;
TAPES.iter().try_for_each(|tape| {
let tape_path = Path::new(tape);
+3 -1
View File
@@ -10,8 +10,10 @@ pub enum TaskError {
File { path: PathBuf, source: io::Error },
#[error("{} has no recording frames", .0.display())]
NoRecordingFrames(PathBuf),
#[error("no recordings directory here; run from the repository root")]
#[error("no VHS tapes here; run from the repository root")]
NotInRepositoryRoot,
#[error("no recordings/ directory here; run record-screencasts from the repository root first")]
RecordingsMissing,
#[error("{0} has no ```toml block under its Defaults heading")]
DefaultsBlockMissing(&'static str),
}