Compare commits
6
Commits
ci-nu-tasks
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7e33b453a | ||
|
|
f43ece2f72 | ||
|
|
d41120e263 | ||
|
|
f9f68b2a68 | ||
|
|
a81cc849b5 | ||
|
|
89eec1ddaf |
No files matched your search
@@ -10,11 +10,9 @@ variables:
|
||||
accept-flake-config = true
|
||||
- &after_dependency_step
|
||||
- status: [success, failure]
|
||||
- &on_pull_requests
|
||||
- event: pull_request
|
||||
|
||||
steps:
|
||||
- name: build-workspace-dependencies
|
||||
- name: prepare-build-dependencies
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
environment: *nix_config
|
||||
@@ -23,7 +21,7 @@ steps:
|
||||
|
||||
- name: build-and-test-bootvine
|
||||
image: nixos/nix:latest
|
||||
depends_on: [build-workspace-dependencies]
|
||||
depends_on: [prepare-build-dependencies]
|
||||
when: *after_dependency_step
|
||||
environment: *nix_config
|
||||
commands:
|
||||
@@ -32,32 +30,23 @@ steps:
|
||||
|
||||
- name: build-repo-tasks
|
||||
image: nixos/nix:latest
|
||||
depends_on: [build-workspace-dependencies]
|
||||
depends_on: [prepare-build-dependencies]
|
||||
when: *after_dependency_step
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix run --quiet .#import-exported-paths
|
||||
- nix run --quiet .#build-and-export-paths -- .#checks.x86_64-linux.repo-tasks-build
|
||||
|
||||
- name: lint-rust-with-clippy
|
||||
- name: lint-with-clippy
|
||||
image: nixos/nix:latest
|
||||
depends_on: [build-workspace-dependencies]
|
||||
depends_on: [prepare-build-dependencies]
|
||||
when: *after_dependency_step
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix run --quiet .#import-exported-paths
|
||||
- nix build --quiet --print-build-logs .#checks.x86_64-linux.clippy-lints
|
||||
|
||||
- name: check-rust-formatting
|
||||
image: nixos/nix:latest
|
||||
depends_on: [build-workspace-dependencies]
|
||||
when: *after_dependency_step
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix run --quiet .#import-exported-paths
|
||||
- nix build --quiet --print-build-logs .#checks.x86_64-linux.rustfmt-formatting
|
||||
|
||||
- name: upload-build-cache
|
||||
- name: upload-builds-to-cachix
|
||||
image: nixos/nix:latest
|
||||
depends_on: [build-and-test-bootvine, build-repo-tasks]
|
||||
when:
|
||||
@@ -71,6 +60,14 @@ steps:
|
||||
commands:
|
||||
- nix run --quiet .#upload-exported-paths
|
||||
|
||||
- name: run-pre-commit-hooks
|
||||
image: nixos/nix:latest
|
||||
depends_on: [prepare-build-dependencies]
|
||||
when: *after_dependency_step
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix run --quiet .#run-pre-commit-hooks
|
||||
|
||||
- name: evaluate-flake-outputs
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
@@ -78,17 +75,11 @@ steps:
|
||||
commands:
|
||||
- nix flake check --quiet --no-build
|
||||
|
||||
- name: test-ci-tasks
|
||||
- name: check-commit-messages
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
when:
|
||||
- event: pull_request
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix build --quiet --print-build-logs .#checks.x86_64-linux.ci-task-tests
|
||||
|
||||
- name: check-conventional-commit-messages
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
when: *on_pull_requests
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix run --quiet .#check-conventional-commits -- --fetch-target-branch FETCH_HEAD..HEAD
|
||||
- nix run --quiet .#check-commit-messages -- --fetch-target-branch FETCH_HEAD..HEAD
|
||||
@@ -0,0 +1,28 @@
|
||||
when:
|
||||
- repo: wvhulle/bootvine
|
||||
event: cron
|
||||
cron: weekly-dependency-update
|
||||
|
||||
clone:
|
||||
- name: clone-with-history
|
||||
image: woodpeckerci/plugin-git
|
||||
settings:
|
||||
depth: 0
|
||||
partial: false
|
||||
|
||||
steps:
|
||||
- name: open-dependency-update-pr
|
||||
image: nixos/nix:latest
|
||||
environment:
|
||||
NIX_CONFIG: |
|
||||
experimental-features = nix-command flakes
|
||||
build-users-group =
|
||||
accept-flake-config = true
|
||||
GIT_AUTHOR_NAME: wvhulle-bot
|
||||
GIT_AUTHOR_EMAIL: willemvanhulle@protonmail.com
|
||||
GIT_COMMITTER_NAME: wvhulle-bot
|
||||
GIT_COMMITTER_EMAIL: willemvanhulle@protonmail.com
|
||||
CODEBERG_TOKEN:
|
||||
from_secret: bot_token
|
||||
commands:
|
||||
- nix run --quiet .#open-dependency-update-pr -- --cargo-lock --flake-lock
|
||||
+7
-7
@@ -4,10 +4,10 @@ when:
|
||||
branch: main
|
||||
|
||||
depends_on:
|
||||
- rust-and-flake-checks
|
||||
- checks
|
||||
|
||||
clone:
|
||||
- name: clone-with-history-and-tags
|
||||
- name: clone-with-history
|
||||
image: woodpeckerci/plugin-git
|
||||
settings:
|
||||
depth: 0
|
||||
@@ -25,19 +25,19 @@ variables:
|
||||
GIT_COMMITTER_NAME: release-plz
|
||||
GIT_COMMITTER_EMAIL: willemvanhulle@protonmail.com
|
||||
CODEBERG_TOKEN:
|
||||
from_secret: codeberg_token
|
||||
from_secret: bot_token
|
||||
CARGO_REGISTRY_TOKEN:
|
||||
from_secret: cargo_registry_token
|
||||
|
||||
steps:
|
||||
- name: publish-crate-and-tag-release
|
||||
- name: publish-unreleased-crate-version
|
||||
image: nixos/nix:latest
|
||||
environment: *release_env
|
||||
commands:
|
||||
- nix run --quiet .#release-plz-release
|
||||
- nix run --quiet .#publish-unreleased-crate-version
|
||||
|
||||
- name: update-release-pr
|
||||
- name: open-or-update-release-pr
|
||||
image: nixos/nix:latest
|
||||
environment: *release_env
|
||||
commands:
|
||||
- nix run --quiet .#release-plz-release-pr
|
||||
- nix run --quiet .#open-or-update-release-pr
|
||||
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.1.3](https://codeberg.org/wvhulle/bootvine/compare/v0.1.2...v0.1.3) - 2026-11-05
|
||||
|
||||
### Fixed
|
||||
|
||||
- do not report collected systemd jobs as failed
|
||||
- keep systemd status off the display manager until the boot finishes
|
||||
|
||||
## [0.1.2](https://codeberg.org/wvhulle/bootvine/compare/v0.1.1...v0.1.2) - 2026-11-02
|
||||
|
||||
### Added
|
||||
|
||||
Generated
+1
-1
@@ -144,7 +144,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bootvine"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"crossterm 0.29.0",
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ name = "bootvine"
|
||||
readme = "../README.md"
|
||||
repository = "https://codeberg.org/wvhulle/bootvine"
|
||||
rust-version = "1.91"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::{
|
||||
boot_feed::{RootRequest, bus_inputs},
|
||||
link_error::Error,
|
||||
switch_root::INITRD_RELEASE,
|
||||
systemd_bus::{Scope, Session, StatusOutput},
|
||||
systemd_bus::{Scope, Session, StatusRelease, restore_status_after_watch},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -33,16 +33,6 @@ pub struct Settings {
|
||||
|
||||
const FULL_REPAINT_INTERVAL: Duration = Duration::from_secs(5);
|
||||
|
||||
struct ConfiguredStatusOnExit;
|
||||
|
||||
impl Drop for ConfiguredStatusOnExit {
|
||||
fn drop(&mut self) {
|
||||
if let Ok(session) = Session::open(Scope::System) {
|
||||
session.set_show_status(StatusOutput::Configured).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn boot_already_finished(settings: &Settings) -> bool {
|
||||
settings.scope == Scope::System
|
||||
&& !settings.shutdown
|
||||
@@ -73,8 +63,14 @@ pub fn run(settings: &Settings) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
async fn watch_live_boot(settings: &Settings, phase: Phase) -> Result<(), Error> {
|
||||
match settings.scope {
|
||||
Scope::System => restore_status_after_watch(watch_on_console(settings, phase)).await,
|
||||
Scope::User => watch_on_console(settings, phase).await.map(drop),
|
||||
}
|
||||
}
|
||||
|
||||
async fn watch_on_console(settings: &Settings, phase: Phase) -> Result<StatusRelease, Error> {
|
||||
let for_system = settings.scope == Scope::System;
|
||||
let _restores_status = for_system.then_some(ConfiguredStatusOnExit);
|
||||
let requests = RequestWatch::open();
|
||||
let prompt_check: fn() -> ScreenInput = if requests.is_some() {
|
||||
|| ScreenInput::PromptCheck
|
||||
@@ -117,6 +113,7 @@ async fn watch_live_boot(settings: &Settings, phase: Phase) -> Result<(), Error>
|
||||
ratatui::restore();
|
||||
match ending {
|
||||
WatchEnding::Failed(error) => Err(error),
|
||||
WatchEnding::BootCompleted | WatchEnding::ViewerLeft => Ok(()),
|
||||
WatchEnding::BootCompleted => Ok(StatusRelease::AfterBoot),
|
||||
WatchEnding::ViewerLeft => Ok(StatusRelease::Immediately),
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ use crate::{
|
||||
switch_root::Sysroot,
|
||||
systemd_bus::{
|
||||
BusConnection, FetchedUnit, JobListing, Scope, Session, Signal, SignalBatch,
|
||||
StatusOutput,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -327,7 +326,7 @@ impl BootTracker {
|
||||
) -> Result<Vec<BootChange>, Error> {
|
||||
connection.subscribe().await?;
|
||||
if self.scope == Scope::System {
|
||||
connection.set_show_status(StatusOutput::Silent).await.ok();
|
||||
connection.silence_status_output().await.ok();
|
||||
}
|
||||
let shutting_down = self.phase == Phase::Shutdown;
|
||||
let jobs: Vec<JobListing> = connection
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
future::ready,
|
||||
future::{Future, pending, ready},
|
||||
io, iter, mem,
|
||||
os::fd::{AsFd, AsRawFd, BorrowedFd, RawFd},
|
||||
pin::pin,
|
||||
@@ -11,9 +11,13 @@ use dbus::{
|
||||
arg::{AppendAll, PropMap, RefArg, Variant},
|
||||
channel::{BusType, Channel},
|
||||
};
|
||||
use futures::{TryStreamExt, stream};
|
||||
use futures::{Stream, StreamExt, TryStreamExt, future::select, stream};
|
||||
use rustix::event::{PollFd, PollFlags, Timespec, poll};
|
||||
use tokio::{io::unix::AsyncFd, time::timeout};
|
||||
use tokio::{
|
||||
io::unix::AsyncFd,
|
||||
signal::unix::{Signal as OsSignal, SignalKind, signal},
|
||||
time::timeout,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
boot_model::{Activity, JobKind, JobResult, UnitFacts, UnitKind, UnitTimeouts},
|
||||
@@ -40,6 +44,8 @@ const PRIVATE_SOCKET: &str = "unix:path=/run/systemd/private";
|
||||
const SIGNAL_RULE: &str = "type='signal',path_namespace='/org/freedesktop/systemd1'";
|
||||
const CALL_TIMEOUT: Duration = Duration::from_secs(1);
|
||||
const UNLIMITED: Duration = Duration::from_micros(u64::MAX);
|
||||
const STATUS_SILENT_MODE: &str = "no";
|
||||
const STATUS_RESET_MODE: &str = "";
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Scope {
|
||||
@@ -48,18 +54,9 @@ pub enum Scope {
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum StatusOutput {
|
||||
Silent,
|
||||
Configured,
|
||||
}
|
||||
|
||||
impl StatusOutput {
|
||||
fn bus_mode(self) -> &'static str {
|
||||
match self {
|
||||
Self::Silent => "no",
|
||||
Self::Configured => "",
|
||||
}
|
||||
}
|
||||
pub enum StatusRelease {
|
||||
AfterBoot,
|
||||
Immediately,
|
||||
}
|
||||
|
||||
pub enum SignalBatch {
|
||||
@@ -157,6 +154,41 @@ fn read_boot_in_progress(reply: &Message) -> Result<bool, Error> {
|
||||
Ok(finished.0 == 0)
|
||||
}
|
||||
|
||||
async fn boot_finish_or_lost_connection() -> Result<(), Error> {
|
||||
let mut connection = BusConnection::register(Session::open(Scope::System)?)?;
|
||||
connection.subscribe().await?;
|
||||
if connection.boot_in_progress().await? {
|
||||
connection
|
||||
.into_signals()
|
||||
.any(|signal| ready(matches!(signal, Signal::BootFinished)))
|
||||
.await;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn termination_request(listener: io::Result<OsSignal>) {
|
||||
match listener {
|
||||
Ok(mut listener) => {
|
||||
listener.recv().await;
|
||||
}
|
||||
Err(_) => pending().await,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn restore_status_after_watch(
|
||||
watch: impl Future<Output = Result<StatusRelease, Error>>,
|
||||
) -> Result<(), Error> {
|
||||
let terminated = termination_request(signal(SignalKind::terminate()));
|
||||
let watched = watch.await;
|
||||
if !matches!(watched, Ok(StatusRelease::Immediately)) {
|
||||
select(pin!(terminated), pin!(boot_finish_or_lost_connection())).await;
|
||||
}
|
||||
if let Ok(session) = Session::open(Scope::System) {
|
||||
session.restore_configured_status().ok();
|
||||
}
|
||||
watched.map(drop)
|
||||
}
|
||||
|
||||
impl Session {
|
||||
pub fn open(scope: Scope) -> Result<Self, Error> {
|
||||
if scope == Scope::System
|
||||
@@ -193,8 +225,8 @@ impl Session {
|
||||
Ok(self.channel.send_with_reply_and_block(call, CALL_TIMEOUT)?)
|
||||
}
|
||||
|
||||
pub fn set_show_status(&self, output: StatusOutput) -> Result<(), Error> {
|
||||
self.blocking_call(manager_call("SetShowStatus", (output.bus_mode(),))?)?;
|
||||
fn restore_configured_status(&self) -> Result<(), Error> {
|
||||
self.blocking_call(manager_call("SetShowStatus", (STATUS_RESET_MODE,))?)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -297,8 +329,8 @@ impl BusConnection {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn set_show_status(&mut self, output: StatusOutput) -> Result<(), Error> {
|
||||
self.call(manager_call("SetShowStatus", (output.bus_mode(),))?)
|
||||
pub async fn silence_status_output(&mut self) -> Result<(), Error> {
|
||||
self.call(manager_call("SetShowStatus", (STATUS_SILENT_MODE,))?)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -372,6 +404,10 @@ impl BusConnection {
|
||||
if self.early_signals.is_empty() {
|
||||
readable_or_timeout(&self.session, patience).await;
|
||||
}
|
||||
self.take_signals()
|
||||
}
|
||||
|
||||
fn take_signals(&mut self) -> SignalBatch {
|
||||
let still_connected = self.drain_replies().is_ok();
|
||||
let signals = mem::take(&mut self.early_signals);
|
||||
if still_connected {
|
||||
@@ -380,6 +416,29 @@ impl BusConnection {
|
||||
SignalBatch::Closed(signals)
|
||||
}
|
||||
}
|
||||
|
||||
async fn next_signals(&mut self) -> SignalBatch {
|
||||
if self.early_signals.is_empty() {
|
||||
let Ok(mut readiness) = self.session.readable().await else {
|
||||
return SignalBatch::Closed(Vec::new());
|
||||
};
|
||||
readiness.clear_ready();
|
||||
}
|
||||
self.take_signals()
|
||||
}
|
||||
|
||||
fn into_signals(self) -> impl Stream<Item = Signal> {
|
||||
unfold_carrying(self, |mut connection| async move {
|
||||
match connection.next_signals().await {
|
||||
SignalBatch::Open(signals) => Some(CarriedItem {
|
||||
item: signals,
|
||||
state: connection,
|
||||
}),
|
||||
SignalBatch::Closed(_) => None,
|
||||
}
|
||||
})
|
||||
.flat_map(stream::iter)
|
||||
}
|
||||
}
|
||||
|
||||
fn text_property(properties: &PropMap, property: &str) -> Option<String> {
|
||||
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env nu
|
||||
|
||||
const CODEBERG_USER = "wvhulle-bot"
|
||||
const TEA_LOGIN_NAME = "codeberg"
|
||||
const UPDATE_BRANCH = "bot/dependency-updates"
|
||||
const UPDATE_COMMIT_MESSAGE = "chore(deps): update lock files"
|
||||
const PULL_REQUEST_DESCRIPTION = "Opened by the weekly dependency update job. The checks on this pull request are the trial build. Commits pushed to this branch by hand stop further automatic updates until it is merged."
|
||||
|
||||
def open-pull-request-heads []: nothing -> list<string> {
|
||||
^tea pulls list --login $TEA_LOGIN_NAME --repo $env.CI_REPO --state open --fields head --output simple
|
||||
| lines
|
||||
| str trim
|
||||
}
|
||||
|
||||
def remote-update-branch-commits []: nothing -> list<string> {
|
||||
^git ls-remote --heads origin $"refs/heads/($UPDATE_BRANCH)"
|
||||
| parse "{commit_id}\t{ref_name}"
|
||||
| get commit_id
|
||||
}
|
||||
|
||||
def update-branch-has-hand-written-commits []: nothing -> bool {
|
||||
^git fetch --quiet origin $"+refs/heads/($UPDATE_BRANCH):refs/remotes/origin/($UPDATE_BRANCH)"
|
||||
^git log --format=%an $"origin/main..origin/($UPDATE_BRANCH)"
|
||||
| lines
|
||||
| any {|commit_author| $commit_author != $env.GIT_AUTHOR_NAME }
|
||||
}
|
||||
|
||||
def "main open-dependency-update-pr" [
|
||||
--cargo-lock
|
||||
--flake-lock
|
||||
]: nothing -> nothing {
|
||||
^git remote set-url origin $"https://($CODEBERG_USER):($env.CODEBERG_TOKEN)@codeberg.org/($env.CI_REPO).git"
|
||||
^tea login add --name $TEA_LOGIN_NAME --url $env.CI_FORGE_URL --token $env.CODEBERG_TOKEN
|
||||
^git fetch --quiet origin +refs/heads/main:refs/remotes/origin/main
|
||||
let remote_commits = remote-update-branch-commits
|
||||
let remote_commit = $remote_commits | str join
|
||||
let pull_request_is_open = $UPDATE_BRANCH in (open-pull-request-heads)
|
||||
if ($remote_commits | is-not-empty) and $pull_request_is_open and (update-branch-has-hand-written-commits) {
|
||||
print $"Leaving ($UPDATE_BRANCH) alone because it contains hand-written commits"
|
||||
return
|
||||
}
|
||||
^git checkout -B $UPDATE_BRANCH origin/main
|
||||
if $cargo_lock {
|
||||
^cargo update
|
||||
}
|
||||
if $flake_lock {
|
||||
^nix flake update
|
||||
}
|
||||
if (^git diff --name-only | is-empty) {
|
||||
print "Dependencies are up to date"
|
||||
return
|
||||
}
|
||||
^git commit --all --message $UPDATE_COMMIT_MESSAGE
|
||||
^git push $"--force-with-lease=($UPDATE_BRANCH):($remote_commit)" origin $UPDATE_BRANCH
|
||||
if $pull_request_is_open {
|
||||
print $"Updated the open pull request from ($UPDATE_BRANCH)"
|
||||
} else {
|
||||
^tea pulls create --login $TEA_LOGIN_NAME --repo $env.CI_REPO --head $UPDATE_BRANCH --base main --title $UPDATE_COMMIT_MESSAGE --description $PULL_REQUEST_DESCRIPTION
|
||||
}
|
||||
}
|
||||
|
||||
def main []: nothing -> nothing {
|
||||
print "Run a subcommand, for example: open-dependency-update-pr --cargo-lock --flake-lock"
|
||||
}
|
||||
+16
-2
@@ -9,7 +9,7 @@ def export-directory []: nothing -> path {
|
||||
$env.CI_WORKSPACE | path join $EXPORT_DIRECTORY_NAME
|
||||
}
|
||||
|
||||
export def store-paths-from-lines []: string -> list<string> {
|
||||
def store-paths-from-lines []: string -> list<string> {
|
||||
lines | compact --empty
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ def exported-store-paths []: nothing -> list<string> {
|
||||
}
|
||||
}
|
||||
|
||||
export def nix-config-with-hook [existing_config: string, hook_program: string]: nothing -> string {
|
||||
def nix-config-with-hook [existing_config: string, hook_program: string]: nothing -> string {
|
||||
$"($existing_config)\npost-build-hook = ($hook_program)"
|
||||
}
|
||||
|
||||
@@ -74,6 +74,20 @@ def "main upload-exported-paths" []: nothing -> nothing {
|
||||
}
|
||||
}
|
||||
|
||||
def "main copy-build-output" [
|
||||
build_output: path
|
||||
destination: path
|
||||
]: nothing -> nothing {
|
||||
if ($build_output | path expand | path type) == dir {
|
||||
mkdir $destination
|
||||
for output_entry in (ls $build_output | get name) {
|
||||
cp --recursive --preserve [] $output_entry $destination
|
||||
}
|
||||
} else {
|
||||
cp --preserve [] $build_output $destination
|
||||
}
|
||||
}
|
||||
|
||||
def main []: nothing -> nothing {
|
||||
print "Run a subcommand, for example: build-and-export-paths"
|
||||
}
|
||||
+45
-12
@@ -1,27 +1,60 @@
|
||||
#!/usr/bin/env nu
|
||||
|
||||
const CODEBERG_USER = "wvhulle"
|
||||
const RELEASE_BRANCH_NAME = "main"
|
||||
const CODEBERG_USER = "wvhulle-bot"
|
||||
const TEA_LOGIN_NAME = "codeberg"
|
||||
const RELEASE_ARCHIVE_PATTERN = "*.tar.gz"
|
||||
const CHECKSUM_FILE_NAME = "sha256sum.txt"
|
||||
|
||||
export def authenticated-origin-url [repository_slug: string, access_token: string]: nothing -> string {
|
||||
$"https://($CODEBERG_USER):($access_token)@codeberg.org/($repository_slug).git"
|
||||
def checksum-line [archive_digest: string, archive_name: string]: nothing -> string {
|
||||
$"($archive_digest) ($archive_name)\n"
|
||||
}
|
||||
|
||||
def run-release-plz [release_subcommand: string]: nothing -> nothing {
|
||||
^release-plz $release_subcommand --forge gitea --git-token $env.CODEBERG_TOKEN
|
||||
def run-release-plz [subcommand: string]: nothing -> nothing {
|
||||
^release-plz $subcommand --forge gitea --git-token $env.CODEBERG_TOKEN
|
||||
}
|
||||
|
||||
def "main release-plz-release" []: nothing -> nothing {
|
||||
^git remote set-url origin (authenticated-origin-url $env.CI_REPO $env.CODEBERG_TOKEN)
|
||||
^git checkout -B $RELEASE_BRANCH_NAME $env.CI_COMMIT_SHA
|
||||
def "main authenticate-git-origin" []: nothing -> nothing {
|
||||
^git remote set-url origin $"https://($CODEBERG_USER):($env.CODEBERG_TOKEN)@codeberg.org/($env.CI_REPO).git"
|
||||
}
|
||||
|
||||
def "main publish-unreleased-crate-version" []: nothing -> nothing {
|
||||
main authenticate-git-origin
|
||||
^git checkout -B main $env.CI_COMMIT_SHA
|
||||
^git fetch origin main:refs/remotes/origin/main
|
||||
^git branch --set-upstream-to=origin/main main
|
||||
run-release-plz release
|
||||
}
|
||||
|
||||
def "main release-plz-release-pr" []: nothing -> nothing {
|
||||
def "main open-or-update-release-pr" []: nothing -> nothing {
|
||||
run-release-plz release-pr
|
||||
}
|
||||
|
||||
def "main check-conventional-commits" [
|
||||
def "main collect-release-archives" [
|
||||
build_result: path
|
||||
dist_directory: path
|
||||
]: nothing -> nothing {
|
||||
mkdir $dist_directory
|
||||
for archive_path in (glob ($build_result | path join $RELEASE_ARCHIVE_PATTERN)) {
|
||||
cp $archive_path $dist_directory
|
||||
}
|
||||
}
|
||||
|
||||
def "main upload-release-assets" [
|
||||
dist_directory: path
|
||||
]: nothing -> nothing {
|
||||
let archive_paths = glob ($dist_directory | path join $RELEASE_ARCHIVE_PATTERN) | sort
|
||||
let checksum_file = $dist_directory | path join $CHECKSUM_FILE_NAME
|
||||
$archive_paths
|
||||
| each {|archive_path|
|
||||
checksum-line (open --raw $archive_path | hash sha256) ($archive_path | path basename)
|
||||
}
|
||||
| str join
|
||||
| save --force $checksum_file
|
||||
^tea login add --name $TEA_LOGIN_NAME --url $env.CI_FORGE_URL --token $env.CODEBERG_TOKEN
|
||||
^tea releases assets create --login $TEA_LOGIN_NAME --repo $env.CI_REPO $env.CI_COMMIT_TAG ...$archive_paths $checksum_file
|
||||
}
|
||||
|
||||
def "main check-commit-messages" [
|
||||
--fetch-target-branch
|
||||
...revision_ranges: string
|
||||
]: nothing -> nothing {
|
||||
@@ -32,5 +65,5 @@ def "main check-conventional-commits" [
|
||||
}
|
||||
|
||||
def main []: nothing -> nothing {
|
||||
print "Run a subcommand, for example: check-conventional-commits"
|
||||
print "Run a subcommand, for example: check-commit-messages"
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/usr/bin/env nu
|
||||
|
||||
use std/assert
|
||||
use ./nix-built-paths.nu [nix-config-with-hook store-paths-from-lines]
|
||||
use ./release-tasks.nu [authenticated-origin-url]
|
||||
|
||||
def main []: nothing -> nothing {
|
||||
assert equal (nix-config-with-hook "max-jobs = 1" "/nix/store/hook") "max-jobs = 1\npost-build-hook = /nix/store/hook"
|
||||
assert equal (nix-config-with-hook "" "/nix/store/hook") "\npost-build-hook = /nix/store/hook"
|
||||
assert equal ("/nix/store/first\n\n/nix/store/second\n" | store-paths-from-lines) ["/nix/store/first" "/nix/store/second"]
|
||||
assert equal ("" | store-paths-from-lines) []
|
||||
assert equal (authenticated-origin-url "wvhulle/bootvine" "sample-token") "https://wvhulle:sample-token@codeberg.org/wvhulle/bootvine.git"
|
||||
print "CI task tests passed"
|
||||
}
|
||||
@@ -275,8 +275,13 @@ While it runs, bootvine:
|
||||
writes to the console and resets it while it re-executes, and drawing only
|
||||
the cells that changed would leave that on screen.
|
||||
|
||||
It restores the log level and the status output when it hands the console
|
||||
back. Kernel messages from before it starts are already on screen; see
|
||||
It restores the log level when it hands the console back. It keeps running
|
||||
without touching the console until the boot finishes and only then restores the
|
||||
status output, so jobs still running cannot write over a display manager that
|
||||
started before them. This holds for a handover and for an error. Pressing a
|
||||
[quit key](guide.md#leaving-the-tree) or stopping the service restores the
|
||||
output at once, so a stuck boot stays visible; status lines can then reach a
|
||||
display manager that starts before the boot finishes. Kernel messages from before it starts are already on screen; see
|
||||
[early kernel messages](configuration.md#early-kernel-messages).
|
||||
|
||||
### Resuming from hibernation
|
||||
|
||||
+21
-20
@@ -9,7 +9,6 @@
|
||||
| `xtask/` | repository tasks run with `cargo xtask` |
|
||||
| `vm-tests/` | the sample NixOS machines, one folder each with its VM check |
|
||||
| `nix/` | the crane builds and the NixOS module |
|
||||
| `ci/` | the Nushell scripts behind the CI apps in `flake.nix` |
|
||||
| `recordings/` | ignored output of `record-screencasts`: the scripted demo GIFs and the sample machine WebP recordings, published on the `recordings` branch for the README and the [guide](guide.md) |
|
||||
|
||||
`cargo build` and `cargo test` act on every crate. `cargo run` needs the binary:
|
||||
@@ -35,33 +34,26 @@ Commit messages follow [Conventional Commits](https://www.conventionalcommits.or
|
||||
jj does not run git hooks, so check the commits you are about to push with:
|
||||
|
||||
```sh
|
||||
nix run .#check-conventional-commits -- origin/main..HEAD
|
||||
nix run .#check-commit-messages -- origin/main..HEAD
|
||||
```
|
||||
|
||||
Git users can install the same commit-message check and a formatting check as
|
||||
hooks with `prek install` ([prek](https://github.com/j178/prek), from the dev
|
||||
shell) or `pre-commit install` ([pre-commit](https://pre-commit.com)).
|
||||
shell) or `pre-commit install` ([pre-commit](https://pre-commit.com)). CI runs
|
||||
the formatting hook with `nix run .#run-pre-commit-hooks`.
|
||||
|
||||
## Continuous integration
|
||||
|
||||
`.woodpecker/rust-and-flake-checks.yaml` runs on Codeberg's
|
||||
`.woodpecker/checks.yaml` runs on Codeberg's
|
||||
[Woodpecker CI](https://woodpecker-ci.org) for every push and pull request: the bootvine build with its tests, the xtask build, clippy,
|
||||
rustfmt, an evaluation of every flake output, and the commit-message check on
|
||||
pull requests. Every step is a plain `nix` call; the scripting lives in `ci/`
|
||||
and is tested by `nix build .#checks.x86_64-linux.ci-task-tests`.
|
||||
|
||||
Steps do not share `/nix/store`. The first step builds the workspace dependencies
|
||||
unless they are already in the `wvhulle` [Cachix](https://www.cachix.org) cache,
|
||||
which `nixConfig` in `flake.nix` offers as a substituter, and exports what it built
|
||||
to the workspace. The build and lint steps import those paths with
|
||||
`nix run .#import-exported-paths` and run even when an earlier step failed. On
|
||||
`main` a final step, the only one holding the Cachix token, pushes the exported
|
||||
paths with `nix run .#upload-exported-paths`. The two VM checks need KVM, which
|
||||
Codeberg's runners lack, so they only run locally.
|
||||
the pre-commit hooks, an evaluation of every flake output, and the commit-message check on
|
||||
pull requests. The workspace dependencies are built or fetched in a step of their own. Builds on `main` are pushed to the `wvhulle` [Cachix](https://www.cachix.org) cache, which
|
||||
`nixConfig` in `flake.nix` offers as a substituter. CI tasks are Nushell scripts in `ci/`, exposed as flake apps in `nix/ci-tasks.nix`. The two VM checks need KVM,
|
||||
which Codeberg's runners lack, so they only run locally.
|
||||
|
||||
## Releases
|
||||
|
||||
`.woodpecker/release-pr-and-publish.yaml` runs
|
||||
`.woodpecker/publish-release-and-update-pr.yaml` runs
|
||||
[release-plz](https://release-plz.dev) after the checks pass on `main`. It
|
||||
keeps a pull request labelled `release` open on Codeberg that bumps the version
|
||||
in `Cargo.toml` and adds the new commits to `CHANGELOG.md`. Only `feat`, `fix`
|
||||
@@ -70,11 +62,20 @@ minor version while bootvine is below 1.0. Merging that pull request publishes
|
||||
the crate to crates.io, tags the merge `v<version>` and creates a Codeberg
|
||||
release with the changelog. Settings are in `release-plz.toml`.
|
||||
|
||||
The pipeline needs two Woodpecker secrets: `codeberg_token`, a Codeberg access
|
||||
token with repository write access, and `cargo_registry_token`, a crates.io
|
||||
token that may publish new crates and updates. Preview the next release
|
||||
The pipeline needs two Woodpecker secrets: `bot_token`, an access token of the
|
||||
`wvhulle-bot` Codeberg account, which has write access to the repository, and
|
||||
`cargo_registry_token`, a crates.io token that may publish new crates and updates. Preview the next release
|
||||
locally from the dev shell with `release-plz update`.
|
||||
|
||||
## Dependency updates
|
||||
|
||||
The `weekly-dependency-update` cron runs `.woodpecker/dependency-update-pr.yaml`,
|
||||
which updates `Cargo.lock` and `flake.lock` and opens or updates one pull request
|
||||
from the `bot/dependency-updates` branch as `wvhulle-bot`. The checks on that pull
|
||||
request are the trial build. Commits pushed to the branch by hand stop further
|
||||
automatic updates until it is merged. Updates that need changes to `Cargo.toml`
|
||||
stay manual.
|
||||
|
||||
## Testing
|
||||
|
||||
| What | Command |
|
||||
|
||||
+16
-8
@@ -47,10 +47,10 @@ From top to bottom:
|
||||
|
||||
## Booting through the initrd
|
||||
|
||||
<img src="https://codeberg.org/wvhulle/bootvine/raw/branch/recordings/slow-services.webp" width="640" alt="A NixOS machine booting through the initrd into stage 2, handing over to a greetd login, then powering off">
|
||||
<img src="https://codeberg.org/wvhulle/bootvine/raw/branch/recordings/slow-services.webp" width="640" alt="A NixOS machine booting through the initrd into stage 2, handing over to a tuigreet login, then powering off">
|
||||
|
||||
The `slow-services` machine boots with a held hardware probe in the initrd,
|
||||
slow units in stage 2 and one failing unit, hands over to its greetd login
|
||||
slow units in stage 2 and one failing unit, hands over to its tuigreet login
|
||||
and powers off. With a systemd initrd, bootvine starts about a second after
|
||||
the kernel:
|
||||
|
||||
@@ -78,10 +78,9 @@ default target is reached, and the text login on `tty1` comes forward.
|
||||
|
||||
### Without a systemd initrd
|
||||
|
||||
<img src="https://codeberg.org/wvhulle/bootvine/raw/branch/recordings/scripted-initrd.webp" width="640" alt="The same boot with NixOS's scripted initrd: the kernel and initrd lines scroll past before bootvine starts in stage 2">
|
||||
|
||||
The `scripted-initrd` machine uses NixOS's older scripted initrd, which has no
|
||||
systemd. The initrd's lines scroll past as usual, and bootvine starts in
|
||||
An initrd without systemd, such as one built by initramfs-tools, has no units
|
||||
for bootvine to follow. The initrd's lines scroll past as usual, and bootvine
|
||||
starts in
|
||||
stage 2, from `sysinit.target` on.
|
||||
|
||||
## Resuming from hibernation
|
||||
@@ -173,6 +172,16 @@ Failures from the initrd stay in the panel after the switch to the real root.
|
||||
The recording is the `failures` machine, where every kind of failure systemd
|
||||
reports happens one after another.
|
||||
|
||||
## Leaving the tree
|
||||
|
||||
`q`, `Ctrl-C` or `Esc` closes the tree during a boot or shutdown and gives the
|
||||
console back with systemd's status lines, for when bootvine misbehaves or you
|
||||
want to see what a stuck boot is doing. While a passphrase prompt is open, keys
|
||||
go to the prompt instead.
|
||||
|
||||
These keys cannot help if bootvine itself has hung, because it reads them in
|
||||
the same loop that draws the screen.
|
||||
|
||||
## Trying it
|
||||
|
||||
Neither of these touches your system's boot.
|
||||
@@ -202,9 +211,8 @@ shows the shutdown.
|
||||
|
||||
| Run | Shows | Recording |
|
||||
| --- | --- | --- |
|
||||
| `nix run .#sample-vm-slow-services` | slow units in the initrd and stage 2, one failing unit, and the handover to a greetd login | [booting through the initrd](#booting-through-the-initrd) |
|
||||
| `nix run .#sample-vm-slow-services` | slow units in the initrd and stage 2, one failing unit, and the handover to a tuigreet login | [booting through the initrd](#booting-through-the-initrd) |
|
||||
| `nix run .#sample-vm-text-console` | the same units without a display manager, handing over at the default target | [without a display manager](#without-a-display-manager) |
|
||||
| `nix run .#sample-vm-scripted-initrd` | the same units with NixOS's scripted initrd, so bootvine starts in stage 2 only | [without a systemd initrd](#without-a-systemd-initrd) |
|
||||
| `nix run .#sample-vm-encrypted-volume` | a LUKS volume unlocked in the initrd; the passphrase is `sample passphrase` | [passphrase prompts](#passphrase-prompts) |
|
||||
| `nix run .#sample-vm-hibernate-resume` | a swap disk to hibernate to; run `systemctl hibernate`, then start the machine again | [resuming from hibernation](#resuming-from-hibernation) |
|
||||
| `nix run .#sample-vm-failures` | a firmware failure in the initrd, then units that exit with an error, crash, time out, cannot be run, restart too often, report a status, die after starting, and one that fails only through its dependency | [failures](#failures) |
|
||||
|
||||
@@ -60,12 +60,8 @@
|
||||
{ pkgs, builds, ... }:
|
||||
{
|
||||
default = builds.bootvine;
|
||||
inherit (builds)
|
||||
bootvine
|
||||
scripted-demos
|
||||
repo-tasks
|
||||
workspace-dependencies
|
||||
;
|
||||
inherit (builds) bootvine scripted-demos repo-tasks;
|
||||
workspace-dependencies = builds.cargoArtifacts;
|
||||
sample-unit-files = pkgs.callPackage ./vm-tests/slow-services/sample-unit-files.nix {
|
||||
inherit (vmTests) sampleUnits;
|
||||
};
|
||||
@@ -91,6 +87,29 @@
|
||||
...
|
||||
}:
|
||||
let
|
||||
mkApp = drv: {
|
||||
type = "app";
|
||||
program = lib.getExe drv;
|
||||
};
|
||||
|
||||
repoTaskApp =
|
||||
name: description: xtaskArguments: runtimeInputs:
|
||||
mkApp (
|
||||
pkgs.runCommand name
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
|
||||
meta.mainProgram = name;
|
||||
}
|
||||
''
|
||||
makeWrapper ${lib.getExe builds.repo-tasks} $out/bin/${name} \
|
||||
--add-flags ${lib.escapeShellArg xtaskArguments} \
|
||||
--prefix PATH : ${lib.makeBinPath runtimeInputs}
|
||||
''
|
||||
)
|
||||
// {
|
||||
meta.description = description;
|
||||
};
|
||||
|
||||
sampleMachineApps = lib.mapAttrs' (
|
||||
machineName: machineDescription:
|
||||
lib.nameValuePair "sample-vm-${machineName}" {
|
||||
@@ -100,192 +119,52 @@
|
||||
}
|
||||
) vmTests.machineDescriptions;
|
||||
|
||||
wrappedProgramTool =
|
||||
{
|
||||
toolName,
|
||||
wrappedProgram,
|
||||
addedFlags,
|
||||
runtimeInputs ? [ ],
|
||||
wrapperArguments ? [ ],
|
||||
}:
|
||||
pkgs.runCommand toolName
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
|
||||
meta.mainProgram = toolName;
|
||||
}
|
||||
''
|
||||
makeWrapper ${wrappedProgram} $out/bin/${toolName} \
|
||||
${
|
||||
lib.escapeShellArgs (
|
||||
lib.concatMap (addedFlag: [
|
||||
"--add-flags"
|
||||
addedFlag
|
||||
]) addedFlags
|
||||
)
|
||||
} \
|
||||
${lib.optionalString (runtimeInputs != [ ]) "--prefix PATH : ${lib.makeBinPath runtimeInputs}"} \
|
||||
${lib.escapeShellArgs wrapperArguments}
|
||||
'';
|
||||
|
||||
nuScriptTool =
|
||||
{
|
||||
scriptPath,
|
||||
toolName,
|
||||
runtimeInputs ? [ ],
|
||||
wrapperArguments ? [ ],
|
||||
}:
|
||||
wrappedProgramTool {
|
||||
inherit toolName runtimeInputs wrapperArguments;
|
||||
wrappedProgram = lib.getExe pkgs.nushell;
|
||||
addedFlags = [
|
||||
"${scriptPath}"
|
||||
toolName
|
||||
];
|
||||
};
|
||||
|
||||
describedApp = appDescription: appTool: {
|
||||
type = "app";
|
||||
meta.description = appDescription;
|
||||
program = lib.getExe appTool;
|
||||
ciTaskApps = import ./nix/ci-tasks.nix {
|
||||
inherit pkgs mkApp;
|
||||
cargoToolchain = rustToolchain;
|
||||
preCommitInputs = [ rustToolchain ];
|
||||
extraReleaseInputs = [
|
||||
pkgs.pkg-config
|
||||
pkgs.stdenv.cc
|
||||
];
|
||||
releaseWrapperArgs = [
|
||||
"--set"
|
||||
"PKG_CONFIG_PATH"
|
||||
(lib.makeSearchPathOutput "dev" "lib/pkgconfig" builds.bootvine.buildInputs)
|
||||
];
|
||||
};
|
||||
|
||||
nixBuiltPathsTool =
|
||||
toolArguments: nuScriptTool (toolArguments // { scriptPath = ./ci/nix-built-paths.nu; });
|
||||
|
||||
releaseTaskTool =
|
||||
toolArguments: nuScriptTool (toolArguments // { scriptPath = ./ci/release-tasks.nu; });
|
||||
|
||||
exportBuiltPathsHook = nixBuiltPathsTool { toolName = "export-built-paths-hook"; };
|
||||
|
||||
exportingBuildTool =
|
||||
toolArguments:
|
||||
nixBuiltPathsTool (
|
||||
toolArguments
|
||||
// {
|
||||
wrapperArguments = [
|
||||
"--set"
|
||||
"EXPORT_HOOK_PROGRAM"
|
||||
(lib.getExe exportBuiltPathsHook)
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
releasePlzTool =
|
||||
toolName:
|
||||
releaseTaskTool {
|
||||
inherit toolName;
|
||||
runtimeInputs = [
|
||||
pkgs.release-plz
|
||||
pkgs.gitMinimal
|
||||
pkgs.pkg-config
|
||||
pkgs.stdenv.cc
|
||||
rustToolchain
|
||||
];
|
||||
wrapperArguments = [
|
||||
"--set"
|
||||
"PKG_CONFIG_PATH"
|
||||
(lib.makeSearchPathOutput "dev" "lib/pkgconfig" builds.bootvine.buildInputs)
|
||||
];
|
||||
};
|
||||
|
||||
repoTaskTool =
|
||||
toolArguments:
|
||||
wrappedProgramTool (
|
||||
toolArguments
|
||||
// {
|
||||
wrappedProgram = lib.getExe builds.repo-tasks;
|
||||
}
|
||||
);
|
||||
in
|
||||
sampleMachineApps
|
||||
// ciTaskApps
|
||||
// {
|
||||
release-plz-release = describedApp "Publish unpublished versions to crates.io and tag them with a Codeberg release" (
|
||||
releasePlzTool "release-plz-release"
|
||||
);
|
||||
release-plz-release-pr = describedApp "Open or update the Codeberg pull request that bumps the version and changelog" (
|
||||
releasePlzTool "release-plz-release-pr"
|
||||
);
|
||||
|
||||
record-screencasts =
|
||||
describedApp
|
||||
repoTaskApp "record-screencasts"
|
||||
"Re-record the scripted demo animations and the sample machine recordings into recordings/; publish them with publish-recordings"
|
||||
(repoTaskTool {
|
||||
toolName = "record-screencasts";
|
||||
addedFlags = [
|
||||
"record-screencasts"
|
||||
"--vm-check-outputs"
|
||||
"${pkgs.linkFarm "vm-check-outputs" (
|
||||
lib.mapAttrs (machineName: _: self.checks.${system}."vm-${machineName}") vmTests.machines
|
||||
)}"
|
||||
];
|
||||
runtimeInputs = [
|
||||
pkgs.vhs
|
||||
pkgs.libwebp
|
||||
builds.scripted-demos
|
||||
builds.repo-tasks
|
||||
];
|
||||
});
|
||||
"record-screencasts --vm-check-outputs ${
|
||||
pkgs.linkFarm "vm-check-outputs" (
|
||||
lib.mapAttrs (machineName: _: self.checks.${system}."vm-${machineName}") vmTests.machines
|
||||
)
|
||||
}"
|
||||
[
|
||||
pkgs.vhs
|
||||
pkgs.libwebp
|
||||
builds.scripted-demos
|
||||
];
|
||||
|
||||
publish-recordings =
|
||||
describedApp "Replace the recordings branch on origin with a single commit holding recordings/"
|
||||
(repoTaskTool {
|
||||
toolName = "publish-recordings";
|
||||
addedFlags = [ "publish-recordings" ];
|
||||
runtimeInputs = [
|
||||
pkgs.gitMinimal
|
||||
builds.repo-tasks
|
||||
];
|
||||
});
|
||||
|
||||
build-unless-cached =
|
||||
describedApp "Build a flake output and export it to the CI workspace unless it is already in Cachix"
|
||||
(exportingBuildTool {
|
||||
toolName = "build-unless-cached";
|
||||
});
|
||||
|
||||
build-and-export-paths =
|
||||
describedApp "Build flake outputs and export newly built paths to the CI workspace"
|
||||
(exportingBuildTool {
|
||||
toolName = "build-and-export-paths";
|
||||
});
|
||||
|
||||
import-exported-paths =
|
||||
describedApp "Import paths exported to the CI workspace by an earlier step"
|
||||
(nixBuiltPathsTool {
|
||||
toolName = "import-exported-paths";
|
||||
});
|
||||
|
||||
upload-exported-paths =
|
||||
describedApp "Push paths exported to the CI workspace to the wvhulle Cachix cache"
|
||||
(nixBuiltPathsTool {
|
||||
toolName = "upload-exported-paths";
|
||||
runtimeInputs = [ pkgs.cachix ];
|
||||
});
|
||||
|
||||
check-conventional-commits =
|
||||
describedApp "Check that the commit messages in a git revision range are conventional commits"
|
||||
(releaseTaskTool {
|
||||
toolName = "check-conventional-commits";
|
||||
runtimeInputs = [
|
||||
pkgs.convco
|
||||
pkgs.gitMinimal
|
||||
];
|
||||
});
|
||||
repoTaskApp "publish-recordings"
|
||||
"Replace the recordings branch on origin with a single commit holding recordings/"
|
||||
"publish-recordings"
|
||||
[ pkgs.gitMinimal ];
|
||||
}
|
||||
);
|
||||
|
||||
checks = forEachSystem (
|
||||
{ pkgs, builds, ... }:
|
||||
{
|
||||
inherit (builds) rustfmt-formatting clippy-lints;
|
||||
inherit (builds) clippy-lints;
|
||||
bootvine-build = builds.bootvine;
|
||||
repo-tasks-build = builds.repo-tasks;
|
||||
ci-task-tests =
|
||||
pkgs.runCommand "bootvine-ci-task-tests" { nativeBuildInputs = [ pkgs.nushell ]; }
|
||||
''
|
||||
nu ${./ci}/test-ci-tasks.nu
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
// lib.mapAttrs' (machineName: check: lib.nameValuePair "vm-${machineName}" check) (
|
||||
vmTests.checksFor pkgs
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
{
|
||||
pkgs,
|
||||
mkApp,
|
||||
cargoToolchain ? null,
|
||||
preCommitInputs ? [ ],
|
||||
extraReleaseInputs ? [ ],
|
||||
releaseWrapperArgs ? [ ],
|
||||
}:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
|
||||
cargoInputs = lib.optional (cargoToolchain != null) cargoToolchain;
|
||||
|
||||
nuScriptTool =
|
||||
{
|
||||
script,
|
||||
name,
|
||||
runtimeInputs ? [ ],
|
||||
wrapperArgs ? [ ],
|
||||
}:
|
||||
pkgs.runCommand name
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
|
||||
meta.mainProgram = name;
|
||||
}
|
||||
''
|
||||
makeWrapper ${lib.getExe pkgs.nushell} $out/bin/${name} \
|
||||
--add-flags ${script} \
|
||||
--add-flags ${name} \
|
||||
${lib.optionalString (runtimeInputs != [ ]) "--prefix PATH : ${lib.makeBinPath runtimeInputs}"} \
|
||||
${lib.escapeShellArgs wrapperArgs}
|
||||
'';
|
||||
|
||||
nixBuiltPathsTool = toolArgs: nuScriptTool (toolArgs // { script = ../ci/nix-built-paths.nu; });
|
||||
|
||||
exportBuiltPathsHook = nixBuiltPathsTool { name = "export-built-paths-hook"; };
|
||||
|
||||
exportingBuildApp =
|
||||
name:
|
||||
mkApp (nixBuiltPathsTool {
|
||||
inherit name;
|
||||
wrapperArgs = [
|
||||
"--set"
|
||||
"EXPORT_HOOK_PROGRAM"
|
||||
(lib.getExe exportBuiltPathsHook)
|
||||
];
|
||||
});
|
||||
|
||||
releasePlzApp =
|
||||
name:
|
||||
mkApp (nuScriptTool {
|
||||
inherit name;
|
||||
script = ../ci/release-tasks.nu;
|
||||
runtimeInputs =
|
||||
cargoInputs
|
||||
++ [
|
||||
pkgs.release-plz
|
||||
pkgs.gitMinimal
|
||||
]
|
||||
++ extraReleaseInputs;
|
||||
wrapperArgs = releaseWrapperArgs;
|
||||
});
|
||||
|
||||
releaseTaskApps =
|
||||
lib.mapAttrs
|
||||
(
|
||||
name: runtimeInputs:
|
||||
mkApp (nuScriptTool {
|
||||
inherit name runtimeInputs;
|
||||
script = ../ci/release-tasks.nu;
|
||||
})
|
||||
)
|
||||
{
|
||||
authenticate-git-origin = [ pkgs.gitMinimal ];
|
||||
collect-release-archives = [ ];
|
||||
upload-release-assets = [ pkgs.tea ];
|
||||
check-commit-messages = [
|
||||
pkgs.convco
|
||||
pkgs.gitMinimal
|
||||
];
|
||||
};
|
||||
|
||||
preCommitHooksTool =
|
||||
pkgs.runCommand "run-pre-commit-hooks"
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
|
||||
meta.mainProgram = "run-pre-commit-hooks";
|
||||
}
|
||||
''
|
||||
makeWrapper ${lib.getExe pkgs.prek} $out/bin/run-pre-commit-hooks \
|
||||
--add-flags "run --all-files --show-diff-on-failure" \
|
||||
--prefix PATH : ${lib.makeBinPath ([ pkgs.gitMinimal ] ++ preCommitInputs)}
|
||||
'';
|
||||
in
|
||||
releaseTaskApps
|
||||
// {
|
||||
publish-unreleased-crate-version = releasePlzApp "publish-unreleased-crate-version";
|
||||
open-or-update-release-pr = releasePlzApp "open-or-update-release-pr";
|
||||
open-dependency-update-pr = mkApp (nuScriptTool {
|
||||
name = "open-dependency-update-pr";
|
||||
script = ../ci/dependency-updates.nu;
|
||||
runtimeInputs = cargoInputs ++ [
|
||||
pkgs.gitMinimal
|
||||
pkgs.tea
|
||||
];
|
||||
});
|
||||
run-pre-commit-hooks = mkApp preCommitHooksTool;
|
||||
build-and-export-paths = exportingBuildApp "build-and-export-paths";
|
||||
build-unless-cached = exportingBuildApp "build-unless-cached";
|
||||
import-exported-paths = mkApp (nixBuiltPathsTool {
|
||||
name = "import-exported-paths";
|
||||
});
|
||||
copy-build-output = mkApp (nixBuiltPathsTool {
|
||||
name = "copy-build-output";
|
||||
});
|
||||
upload-exported-paths = mkApp (nixBuiltPathsTool {
|
||||
name = "upload-exported-paths";
|
||||
runtimeInputs = [ pkgs.cachix ];
|
||||
});
|
||||
}
|
||||
@@ -30,12 +30,7 @@ let
|
||||
args: craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; } // args);
|
||||
in
|
||||
{
|
||||
workspace-dependencies = cargoArtifacts;
|
||||
|
||||
rustfmt-formatting = craneLib.cargoFmt {
|
||||
inherit (commonArgs) src pname version;
|
||||
cargoExtraArgs = "--all";
|
||||
};
|
||||
inherit cargoArtifacts;
|
||||
|
||||
clippy-lints = craneLib.cargoClippy (
|
||||
commonArgs
|
||||
|
||||
@@ -10,9 +10,8 @@ let
|
||||
};
|
||||
|
||||
machineDescriptions = {
|
||||
slow-services = "slow and failing units, a held initrd probe and a greetd login";
|
||||
slow-services = "slow and failing units, a held initrd probe and a tuigreet login";
|
||||
text-console = "the slow units without a display manager, handing over at the default target";
|
||||
scripted-initrd = "the slow units with the scripted initrd, so bootvine starts in stage 2";
|
||||
encrypted-volume = "a LUKS volume unlocked in the initrd with the passphrase 'sample passphrase'";
|
||||
failures = "units that fail in every way systemd reports, each with journal messages";
|
||||
hibernate-resume = "a swap disk to hibernate to, showing the kernel's image loading progress on resume";
|
||||
|
||||
@@ -5,10 +5,7 @@
|
||||
nodes.machine =
|
||||
{ lib, ... }:
|
||||
{
|
||||
imports = [
|
||||
machine
|
||||
(pkgs.path + "/nixos/tests/common/auto-format-root-device.nix")
|
||||
];
|
||||
imports = [ machine ];
|
||||
|
||||
boot.resumeDevice = "/dev/vdc";
|
||||
swapDevices = lib.mkOverride 0 [
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
{ machine, ... }:
|
||||
{
|
||||
name = "bootvine-scripted-initrd";
|
||||
|
||||
nodes.machine =
|
||||
{ lib, ... }:
|
||||
let
|
||||
waitFor = flag: "/bin/sh -c 'until [ -e /run/${flag} ]; do sleep 0.1; done'";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
machine
|
||||
../shared/recorded-display.nix
|
||||
];
|
||||
systemd.services = {
|
||||
sample-database.serviceConfig.ExecStop = lib.mkForce (waitFor "release-sample-database");
|
||||
backdoor.before = [ "sample-database.service" ];
|
||||
};
|
||||
};
|
||||
|
||||
testScript =
|
||||
builtins.readFile ../shared/console.py
|
||||
+ builtins.readFile ../shared/screen_recording.py
|
||||
+ builtins.readFile ./check.py;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
def unit_state(unit):
|
||||
return machine.succeed(f"systemctl is-active {unit} || true").strip()
|
||||
|
||||
|
||||
recording = ScreenRecording(machine)
|
||||
machine.start()
|
||||
recording.start()
|
||||
|
||||
wait_for_screen("Stage 2", "sample-database")
|
||||
assert_bootvine_in_front()
|
||||
assert_text_visible(font_has_512_glyphs=True)
|
||||
|
||||
machine.wait_for_unit("greetd.service")
|
||||
retry(lambda _: unit_state("bootvine") == "inactive", timeout_seconds=60)
|
||||
journal = bootvine_journal()
|
||||
print(journal)
|
||||
watched = [line for line in journal.splitlines() if line.startswith("bootvine: watching")]
|
||||
assert watched, "bootvine never started"
|
||||
assert not any(" in Initrd " in line for line in watched), "bootvine ran in a scripted initrd"
|
||||
assert "handing the console over" in journal, "never handed the console over"
|
||||
|
||||
machine.succeed("systemctl poweroff --no-block")
|
||||
retry(lambda _: unit_state("sample-database") == "deactivating", timeout_seconds=60)
|
||||
wait_for_screen("Shutdown", "sample-database")
|
||||
assert_bootvine_in_front()
|
||||
machine.succeed("touch /run/release-sample-database")
|
||||
machine.wait_for_shutdown()
|
||||
recording.stop()
|
||||
@@ -1,6 +0,0 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
imports = [ ../slow-services/machine.nix ];
|
||||
|
||||
boot.initrd.systemd.enable = lib.mkForce false;
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
../shared/recorded-display.nix
|
||||
];
|
||||
testing.initrdBackdoor = true;
|
||||
boot.kernelParams = lib.mkAfter [ "console=tty0" ];
|
||||
boot.initrd.systemd.services.initrd-hardware-probe.serviceConfig.ExecStart = lib.mkForce (
|
||||
waitFor "release-initrd-hardware-probe"
|
||||
);
|
||||
|
||||
@@ -6,6 +6,17 @@ def unit_state(unit):
|
||||
return machine.succeed(f"systemctl is-active {unit} || true").strip()
|
||||
|
||||
|
||||
def foreground_console_text():
|
||||
terminal_number = foreground_terminal().removeprefix("tty")
|
||||
return machine.succeed(f"tr -cd '[:print:]' < /dev/vcs{terminal_number}")
|
||||
|
||||
|
||||
def assert_unit_start_stays_off_console(description):
|
||||
machine.succeed(f"systemd-run --wait --description='{description}' /run/current-system/sw/bin/true")
|
||||
console_text = foreground_console_text()
|
||||
assert description not in console_text, f"systemd status reached the login screen:\n{console_text}"
|
||||
|
||||
|
||||
recording = ScreenRecording(machine)
|
||||
machine.start()
|
||||
recording.start()
|
||||
@@ -24,11 +35,17 @@ assert_text_visible(font_has_512_glyphs=True)
|
||||
assert console_level() == "1", f"stage 2 sysctl reopened the kernel console: {console_level()}"
|
||||
|
||||
machine.wait_for_unit("greetd.service")
|
||||
retry(lambda _: unit_state("bootvine") == "inactive", timeout_seconds=60)
|
||||
retry(lambda _: "another program took the console" in bootvine_journal(), timeout_seconds=60)
|
||||
assert unit_state("late-sensor-probe") == "activating", "the boot finished before the display manager took over"
|
||||
assert foreground_terminal() != f"tty{BOOTVINE_TERMINAL}", "bootvine took the console back from the display manager"
|
||||
machine.wait_until_tty_matches("1", "Username:")
|
||||
assert_unit_start_stays_off_console("Mid boot status probe")
|
||||
show_status = machine.succeed("systemctl show -p ShowStatus --value").strip()
|
||||
assert show_status == "no", f"systemd status output came back before the boot finished: {show_status}"
|
||||
assert unit_state("bootvine") == "active", "bootvine left before the boot finished"
|
||||
machine.succeed("touch /run/release-late-sensor-probe")
|
||||
machine.wait_for_unit("graphical.target")
|
||||
retry(lambda _: unit_state("bootvine") == "inactive", timeout_seconds=60)
|
||||
|
||||
journal = bootvine_journal()
|
||||
print(journal)
|
||||
@@ -43,6 +60,13 @@ machine.succeed('test "$(systemctl show -p Result --value bootvine)" = success')
|
||||
assert console_level() != "1", f"kernel console level was not restored: {console_level()}"
|
||||
show_status = machine.succeed("systemctl show -p ShowStatus --value").strip()
|
||||
assert show_status == "yes", f"systemd status output was not restored: {show_status}"
|
||||
assert_unit_start_stays_off_console("Post boot status probe")
|
||||
|
||||
machine.wait_until_tty_matches("1", "Username:")
|
||||
machine.send_chars("sample-user\n")
|
||||
machine.wait_until_tty_matches("1", "Password:")
|
||||
machine.send_chars("sample-user\n")
|
||||
machine.wait_until_succeeds("pgrep -u sample-user bash", timeout=30)
|
||||
|
||||
foreground = foreground_terminal()
|
||||
assert foreground != f"tty{BOOTVINE_TERMINAL}", "bootvine kept the console after handing it over"
|
||||
|
||||
@@ -37,6 +37,6 @@ in
|
||||
|
||||
services.greetd = {
|
||||
enable = true;
|
||||
settings.default_session.command = "${pkgs.greetd}/bin/agreety --cmd ${pkgs.bashInteractive}/bin/bash";
|
||||
settings.default_session.command = "${pkgs.tuigreet}/bin/tuigreet --time --cmd ${pkgs.bashInteractive}/bin/bash";
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user