dotfiles
bugabingas dorkfiles
owned by bugabinga
chore: streamline podman integration test
c03c02c8fa6561b4be3b8ef5875cfe35061ceffd
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Changed files (3)
72 71 HOME/system mutating; only run after explicit user request:
18 18 description =
"Run Podman integration test" 20 -arg "[hostname]" default="desktop" 22 -run =
'java ./scripts/dotfiles_integration_test.java "{{usage.hostname}}"' 19 +run =
"java ./scripts/dotfiles_integration_test.java" 25 22 description =
"Link dorkfiles into HOME" scripts/dotfiles_integration_test.java
Modified 10 10 public static void main(
String[] args) throws
Exception {
11 - if (args.length
> 0 && args[
0].equals(
"--inside")) inside(args.length
> 1 ? args[
1]
: "desktop");
12 - else host(args.length
> 0 ? args[
0]
: "desktop");
11 + if (args.length
> 0 && args[
0].equals(
"--inside")) inside();
15 - static void host(
String hostname) throws
Exception {
15 + static void host() throws
Exception {
16 16 root
= Path.of(run(
null,
"git",
"rev-parse",
"--show-toplevel").trim());
17 17 var key
= root.resolve(
".git/dotfiles-aes.key");
18 18 if (
!Files.isReadable(key)) fail(
"missing " + key);
20 20 container
= container.replaceAll(
"[^A-Za-z0-9_.-]",
"-");
22 22 step(
"start container");
23 - run(
null,
"podman",
"run",
"--name", container,
"--rm",
"-d",
"--hostname", hostname,
24 - "-e",
"PRIMARY_HOSTNAME=" + hostname,
23 + run(
null,
"podman",
"run",
"--name", container,
"--rm",
"-d",
"--hostname",
"desktop",
25 24 "-v", root
+ ":/src:ro",
"-v", key
+ ":/dotfiles-aes.key:ro",
26 25 "registry.fedoraproject.org/fedora:latest",
"sleep",
"infinity");
27 26 ok(
"container-started");
33 32 step(
"clone repo");
34 33 run(
null,
"podman",
"exec", container,
"git",
"clone",
"--quiet",
"--no-local",
"/src",
"/root/work/dotfiles");
35 34 run(
null,
"podman",
"exec", container,
"install",
"-m",
"600",
"/dotfiles-aes.key",
"/root/work/dotfiles/.git/dotfiles-aes.key");
36 - step(
"compile test");
37 - run(
null,
"podman",
"exec",
"-w",
"/root/work/dotfiles", container,
"javac",
"-d",
"/tmp/dotfiles-test-classes",
"/src/scripts/dotfiles_integration_test.java");
38 35 step(
"run checks");
39 - runInherit(
null,
"podman",
"exec",
"-w",
"/root/work/dotfiles", container,
"java",
"-cp",
"/tmp/dotfiles-test-classes",
"dotfiles_integration_test",
"--inside", hostname);
36 + runInherit(
null,
"podman",
"exec",
"-w",
"/root/work/dotfiles", container,
"java",
"/src/scripts/dotfiles_integration_test.java",
"--inside");
41 38 runAllowFail(
null,
"podman",
"rm",
"-f", container);
45 - static void inside(
String primaryHostname) throws
Exception {
42 + static void inside() throws
Exception {
46 43 root
= Path.of(
".").toAbsolutePath().normalize();
47 44 System.out.println(
"rootless=" + rootless());
57 54 if (
!run(root,
"git",
"show",
"HEAD:nushell/secrets.nu").startsWith(
"DFAES1")) fail(
"committed-encrypted");
58 55 ok(
"committed-encrypted");
60 - var hosts
= new ArrayList<
String>();
61 - try (
var s
= Files.list(root)) {
62 - s.filter(p
-> p.getFileName().toString().endsWith(
".symlinks"))
63 - .map(p
-> p.getFileName().toString().replaceFirst(
"\\.symlinks$",
""))
64 - .sorted().forEach(hosts::add);
66 - System.out.println(
"primary-manifest=" + primaryHostname
+ ".symlinks");
57 + var hosts
= allHosts();
67 58 System.out.println(
"manifests=" + String.join(
" ", hosts));
68 59 for (
var host
: hosts) runManifest(host);
69 60 ok(
"symlink-manifests:" + hosts.size());
78 69 System.out.println(
"RESULT:ok");
72 + static List<
String> allHosts() throws
IOException {
73 + var hosts
= new ArrayList<
String>();
74 + try (
var s
= Files.list(root)) {
75 + s.filter(p
-> p.getFileName().toString().endsWith(
".symlinks"))
76 + .map(p
-> p.getFileName().toString().replaceFirst(
"\\.symlinks$",
""))
77 + .sorted().forEach(hosts::add);
81 82 static void runManifest(
String host) throws
Exception {
82 83 var manifest
= root.resolve(host
+ ".symlinks");
84 + if (
!Files.exists(manifest)) fail(
"missing-manifest:" + manifest.getFileName());
83 85 var home
= Path.of(
"/tmp/home-" + host);
84 86 System.out.println(
"manifest=" + manifest.getFileName());