repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

chore: simplify mise tasks and stream test output

ab996716460d4e95c876d1b026cab24f09869bd1

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (3)

AGENTS.md

Modified
74 74 ```sh
75 75 mise run link
76 76 mise run clean
77 -mise run setup
80 79 Crypto/hooks:

mise.toml

Modified
22 22 run = 'java ./scripts/dotfiles_integration_test.java "{{usage.hostname}}"'
24 24 [tasks.link]
25 -description = "Bootstrap and link dorkfiles into HOME"
26 -run = "java bootstripper.java bootstrap"
25 +description = "Link dorkfiles into HOME"
26 +run = [
27 + "java bootstripper.java bootstrap",
28 + "java scripts/fix_permissions.java",
28 31 [tasks.clean]
29 32 description = "Remove managed dorkfiles links from HOME"
30 33 run = "java bootstripper.java clean"
32 -[tasks.setup]
33 -description = "Link dorkfiles and fix permissions"
34 -depends = ["link", "fix"]
36 35 [tasks.init]
37 36 description = "Create initial crypto salt"
38 37 hide = true

scripts/dotfiles_integration_test.java

Modified
19 19 var container = "dotfiles-integration-" + LocalDateTime.now() + "-" + ProcessHandle.current().pid();
20 20 container = container.replaceAll("[^A-Za-z0-9_.-]", "-");
21 21 try {
22 + step("start container");
22 23 run(null, "podman", "run", "--name", container, "--rm", "-d", "--hostname", hostname,
23 24 "-e", "PRIMARY_HOSTNAME=" + hostname,
24 25 "-v", root + ":/src:ro", "-v", key + ":/dotfiles-aes.key:ro",
25 26 "registry.fedoraproject.org/fedora:latest", "sleep", "infinity");
27 + ok("container-started");
28 + step("install packages");
26 29 run(null, "podman", "exec", container, "dnf", "-qy", "--setopt=install_weak_deps=False", "install", "git-core", "java-latest-openjdk-devel");
30 + ok("packages-installed");
27 31 run(null, "podman", "exec", container, "git", "config", "--global", "--add", "safe.directory", "/src");
28 32 run(null, "podman", "exec", container, "mkdir", "-p", "/root/work");
33 + step("clone repo");
29 34 run(null, "podman", "exec", container, "git", "clone", "--quiet", "--no-local", "/src", "/root/work/dotfiles");
30 35 run(null, "podman", "exec", container, "install", "-m", "600", "/dotfiles-aes.key", "/root/work/dotfiles/.git/dotfiles-aes.key");
36 + step("compile test");
31 37 run(null, "podman", "exec", "-w", "/root/work/dotfiles", container, "javac", "-d", "/tmp/dotfiles-test-classes", "/src/scripts/dotfiles_integration_test.java");
32 - run(null, "podman", "exec", "-w", "/root/work/dotfiles", container, "java", "-cp", "/tmp/dotfiles-test-classes", "dotfiles_integration_test", "--inside", hostname);
38 + step("run checks");
39 + runInherit(null, "podman", "exec", "-w", "/root/work/dotfiles", container, "java", "-cp", "/tmp/dotfiles-test-classes", "dotfiles_integration_test", "--inside", hostname);
33 40 } finally {
34 41 runAllowFail(null, "podman", "rm", "-f", container);
150 - static void ok(String what) { System.out.println("ok:" + what); }
157 + static void step(String what) { log("step:" + what); }
158 + static void ok(String what) { log("ok:" + what); }
159 + static void log(String message) { System.out.println(message); System.out.flush(); }
151 160 static void fail(String what) { throw new RuntimeException("FAIL:" + what); }
153 162 static String run(Path dir, String... cmd) throws Exception { return run(dir, Map.of(), cmd); }
161 170 if (code != 0) throw new RuntimeException(String.join(" ", cmd) + "\n" + out);
162 171 return out;
173 + static void runInherit(Path dir, String... cmd) throws Exception {
174 + var pb = new ProcessBuilder(cmd);
175 + if (dir != null) pb.directory(dir.toFile());
176 + var code = pb.inheritIO().start().waitFor();
177 + if (code != 0) throw new RuntimeException(String.join(" ", cmd) + " exited " + code);
164 180 static void runAllowFail(Path dir, String... cmd) {
165 181 try { run(dir, cmd); } catch (Exception ignored) {}