diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-09-28 17:37:30 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-09-28 17:37:30 +0900 |
| commit | d2afde1c95355621282d1ac1a9ae73c3b665b395 (patch) | |
| tree | 910f2dff6a1e86491840357bf150df5ad685a37e /internal/workflows/test.go | |
| parent | d621c53cc1ad96adb36612e6143691dd0c79362b (diff) | |
internal/workflows: migrate workflows
This represents workflow documents via compound literals and removes
the ugly and footgun-heavy yaml documents.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/workflows/test.go')
| -rw-r--r-- | internal/workflows/test.go | 227 |
1 files changed, 227 insertions, 0 deletions
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") |
