From d2afde1c95355621282d1ac1a9ae73c3b665b395 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 28 Sep 2026 17:37:30 +0900 Subject: internal/workflows: migrate workflows This represents workflow documents via compound literals and removes the ugly and footgun-heavy yaml documents. Signed-off-by: Ophestra --- internal/workflows/test.go | 227 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 internal/workflows/test.go (limited to 'internal/workflows/test.go') diff --git a/internal/workflows/test.go b/internal/workflows/test.go new file mode 100644 index 00000000..1bbb04f9 --- /dev/null +++ b/internal/workflows/test.go @@ -0,0 +1,227 @@ +//go:build workflows + +package main + +var _ = (&Workflow{ + Name: "Test", + On: []any{"push"}, + + Jobs: Map[Job]{ + {K: "hakurei", V: Job{ + Name: "Hakurei", + On: "nix", + + Steps: []Step{ + { + Name: "Checkout", + Uses: "actions/checkout@v4", + }, + + { + Name: "Run NixOS test", + Run: "nix build " + + "--out-link result " + + "--print-out-paths " + + "--print-build-logs " + + "./test#checks.x86_64-linux.hakurei", + }, + + { + Name: "Upload test output", + Uses: "actions/upload-artifact@v3", + + With: Map[any]{ + {K: "name", V: "hakurei-vm-output"}, + {K: "path", V: "result/*"}, + + {K: "retention-days", V: 1}, + }, + }, + }, + }}, + + {K: "race", V: Job{ + Name: "Hakurei (race detector)", + On: "nix", + + Steps: []Step{ + {Name: "Checkout", Uses: "actions/checkout@v4"}, + + { + Name: "Run NixOS test", + Run: "nix build " + + "--out-link result " + + "--print-out-paths " + + "--print-build-logs " + + "./test#checks.x86_64-linux.race", + }, + + { + Name: "Upload test output", + Uses: "actions/upload-artifact@v3", + + With: Map[any]{ + {K: "name", V: "hakurei-race-vm-output"}, + {K: "path", V: "result/*"}, + + {K: "retention-days", V: 1}, + }, + }, + }, + }}, + + {K: "sandbox", V: Job{ + Name: "Sandbox", + On: "nix", + + Steps: []Step{ + {Name: "Checkout", Uses: "actions/checkout@v4"}, + + { + Name: "Run NixOS test", + Run: "nix build " + + "--out-link result " + + "--print-out-paths " + + "--print-build-logs " + + "./test#checks.x86_64-linux.sandbox", + }, + + { + Name: "Upload test output", + Uses: "actions/upload-artifact@v3", + + With: Map[any]{ + {K: "name", V: "sandbox-vm-output"}, + {K: "path", V: "result/*"}, + + {K: "retention-days", V: 1}, + }, + }, + }, + }}, + + {K: "sandbox-race", V: Job{ + Name: "Sandbox (race detector)", + On: "nix", + + Steps: []Step{ + {Name: "Checkout", Uses: "actions/checkout@v4"}, + + { + Name: "Run NixOS test", + Run: "nix build " + + "--out-link result " + + "--print-out-paths " + + "--print-build-logs " + + "./test#checks.x86_64-linux.sandbox-race", + }, + + { + Name: "Upload test output", + Uses: "actions/upload-artifact@v3", + + With: Map[any]{ + {K: "name", V: "sandbox-race-vm-output"}, + {K: "path", V: "result/*"}, + + {K: "retention-days", V: 1}, + }, + }, + }, + }}, + + {K: "sharefs", V: Job{ + Name: "ShareFS", + On: "nix", + + Steps: []Step{ + {Name: "Checkout", Uses: "actions/checkout@v4"}, + + { + Name: "Run NixOS test", + Run: "nix build " + + "--out-link result " + + "--print-out-paths " + + "--print-build-logs " + + "./test#checks.x86_64-linux.sharefs", + }, + + { + Name: "Upload test output", + Uses: "actions/upload-artifact@v3", + + With: Map[any]{ + {K: "name", V: "sharefs-vm-output"}, + {K: "path", V: "result/*"}, + + {K: "retention-days", V: 1}, + }, + }, + }, + }}, + + {K: "check", V: Job{ + Name: "Flake checks", + On: "nix", + + Needs: []string{ + "hakurei", + "race", + "sandbox", + "sandbox-race", + "sharefs", + }, + + Steps: []Step{ + { + Name: "Checkout", + Uses: "actions/checkout@v4", + }, + + { + Name: "Run checks", + Run: "nix " + + "--print-build-logs " + + "--experimental-features 'nix-command flakes' " + + "flake check ./test", + }, + }, + }}, + + {K: "dist", V: Job{ + Name: "Create distribution", + On: "nix", + + Steps: []Step{ + { + Name: "Checkout", + Uses: "actions/checkout@v4", + }, + + { + Name: "Build for test", + ID: "build-test", + Run: "export HAKUREI_REV=\"$(git rev-parse --short HEAD)\" && " + + "sed -i.old " + + "'s/version = /version = \"0.0.0-'$HAKUREI_REV'\"; # version = /' " + + "test/package.nix && " + + "nix build --print-out-paths --print-build-logs ./test#dist && " + + "mv test/{package.nix.old,package.nix} && " + + "echo \"rev=$HAKUREI_REV\" >> $GITHUB_OUTPUT", + }, + + { + Name: "Upload test build", + Uses: "actions/upload-artifact@v3", + + With: Map[any]{ + {K: "name", V: "hakurei-${{ steps.build-test.outputs.rev }}"}, + {K: "path", V: "result/*"}, + + {K: "retention-days", V: 1}, + }, + }, + }, + }}, + }, +}).mustWriteFile("test") -- cgit v1.3.1