From aeb0ac9a329a253baf516be6ecfbdc4a750c6df6 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 3 Oct 2026 15:51:56 +0900 Subject: internal/workflows: cache installed packages This avoids re-downloading packages on every run. Signed-off-by: Ophestra --- internal/workflows/step.go | 34 +++++++++++++++++++++++++++++++--- internal/workflows/test.go | 13 ++----------- 2 files changed, 33 insertions(+), 14 deletions(-) (limited to 'internal/workflows') diff --git a/internal/workflows/step.go b/internal/workflows/step.go index 219ed78b..83d9c5f3 100644 --- a/internal/workflows/step.go +++ b/internal/workflows/step.go @@ -2,6 +2,8 @@ package main +import "strings" + // fixup is a step to work around a Podman regression introduced by a bad // container escape mitigation. var fixup = Step{ @@ -55,9 +57,35 @@ func newCIRequest(display, name, id string) Step { var install = Step{ Name: "Install hakurei", Run: "HAKUREI_VERSION=\"$(cat cmd/dist/VERSION)-${{ steps.dist.outputs.rev }}\" && " + - "tar xf \"result/hakurei-$HAKUREI_VERSION-amd64.tar.gz\" && " + - "\"./hakurei-$HAKUREI_VERSION-amd64/install.sh\" && " + - "sudo -u ubuntu hakurei version", + "tar xf result/hakurei-$HAKUREI_VERSION*-amd64.tar.gz && " + + "./hakurei-$HAKUREI_VERSION*-amd64/install.sh && " + + "sudo -u ubuntu hakurei version && " + + "echo 'Defaults closefrom_override' > " + + "/etc/sudoers.d/closefrom_override && " + + "mkdir /var/empty", +} + +// newTestsuite returns a step for running an integration test suite. +func newTestsuite(name, prefix string) Step { + return Step{ + Name: "Compile and run test suite", + Run: prefix + "rm -rf result && " + + "go run -tags=testsuite ./test/" + name, + } +} + +// newPackages returns a job for installing the specified packages with +// best-effort caching. Package names must not contain spaces. +func newPackages(rev int, packages ...string) Step { + return Step{ + Name: "Install packages", + Uses: "awalsh128/cache-apt-pkgs-action@v1", + With: []KV[any]{ + {"packages", strings.Join(packages, " ")}, + {"version", rev}, + {"execute_install_scripts", true}, + }, + } } // newNixOSTest returns a step for running the named NixOS test. diff --git a/internal/workflows/test.go b/internal/workflows/test.go index d3290f16..40e1a076 100644 --- a/internal/workflows/test.go +++ b/internal/workflows/test.go @@ -59,11 +59,7 @@ var _ = (&Workflow{ fixup, checkout, toolchain, - - { - Name: "install fuse and fs_mark", - Run: "apt-get update && apt-get install -y fuse3 fsmark", - }, + newPackages(0, "fuse3", "fsmark"), newCIRequest("distribution", "dist -o result", "dist"), install, @@ -82,12 +78,7 @@ var _ = (&Workflow{ "setuid=1023,setgid=1023 /sdcard", }, - { - Name: "Compile and run test suite", - Run: "sharefs -V && rm -rf result && " + - "go run -tags=testsuite ./test/sharefs ubuntu", - }, - + newTestsuite("sharefs", "sharefs -V && "), newUploadArtifact("test output", "fs_mark"), }, }}, -- cgit v1.3.1