aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-10-07 00:29:47 +0900
committerOphestra <cat@gensokyo.uk>2026-10-07 00:49:55 +0900
commit2f70bd20d13ca699bf61cf2bb37881f029851275 (patch)
tree093d5e5348116d02efb61b6c3280204ca94fb042
parenta6334d4ff69ce0c02128256f2032617096882ee5 (diff)
internal/workflows: fetch distribution artifactHEADmasterdevelop
This is cleaner than contacting the cmd/mbf CI service on every run, although also slightly slower in some cases. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--.gitea/workflows/test.yml2
-rw-r--r--internal/workflows/main.go2
-rw-r--r--internal/workflows/step.go26
-rw-r--r--internal/workflows/test.go36
4 files changed, 59 insertions, 7 deletions
diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml
index 6349f281..db7b3955 100644
--- a/.gitea/workflows/test.yml
+++ b/.gitea/workflows/test.yml
@@ -1 +1 @@
-{"name":"Test","on":["push"],"jobs":{"hakurei-legacy":{"name":"Hakurei (legacy)","runs-on":"nix","steps":[{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Run NixOS test","run":"nix build --out-link result --print-out-paths --print-build-logs ./cmd/hakurei/testsuite#checks.x86_64-linux.hakurei"},{"name":"Upload test output","uses":"actions/upload-artifact@v3","with":{"name":"hakurei-vm-output","path":"result/*","retention-days":1}}]},"hakurei-race-legacy":{"name":"Hakurei (legacy with race instrument)","runs-on":"nix","steps":[{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Run NixOS test","run":"nix build --out-link result --print-out-paths --print-build-logs ./cmd/hakurei/testsuite#checks.x86_64-linux.race"},{"name":"Upload test output","uses":"actions/upload-artifact@v3","with":{"name":"hakurei-race-vm-output","path":"result/*","retention-days":1}}]},"sandbox":{"name":"Sandbox","runs-on":"rosa","steps":[{"name":"Fix container filesystem","run":"rm /var/run \u0026\u0026 ln -sf ../run /var"},{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Set up Go toolchain","uses":"actions/setup-go@v6","with":{"go-version-file":"go.mod"}},{"name":"Install packages","uses":"awalsh128/cache-apt-pkgs-action@v1","with":{"add-repository":"ppa:savoury1/pipewire","packages":"libmount-dev sway xwayland xdg-dbus-proxy pipewire","version":0,"execute_install_scripts":true}},{"name":"Request distribution","id":"dist","run":"HAKUREI_REV=\"$(git rev-parse --short HEAD)\" \u0026\u0026 /rosa/bin/mbf ci dist -o result . \"$(cat cmd/dist/VERSION)-$HAKUREI_REV\" \u0026\u0026 echo \"rev=$HAKUREI_REV\" \u003e\u003e \"$GITHUB_OUTPUT\""},{"name":"Install hakurei","run":"HAKUREI_VERSION=\"$(cat cmd/dist/VERSION)-${{ steps.dist.outputs.rev }}\" \u0026\u0026 tar xf result/hakurei-$HAKUREI_VERSION*-amd64.tar.gz \u0026\u0026 ./hakurei-$HAKUREI_VERSION*-amd64/install.sh \u0026\u0026 sudo -u ubuntu hakurei version \u0026\u0026 mkdir /var/empty"},{"name":"Compile and run test suite","run":"rm -rf result \u0026\u0026 go run -tags=testsuite ./cmd/hakurei/testsuite/sandbox"}]},"sandbox-race":{"name":"Sandbox (with race instrument)","runs-on":"rosa","steps":[{"name":"Fix container filesystem","run":"rm /var/run \u0026\u0026 ln -sf ../run /var"},{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Set up Go toolchain","uses":"actions/setup-go@v6","with":{"go-version-file":"go.mod"}},{"name":"Install packages","uses":"awalsh128/cache-apt-pkgs-action@v1","with":{"add-repository":"ppa:savoury1/pipewire","packages":"libmount-dev sway xwayland xdg-dbus-proxy pipewire","version":0,"execute_install_scripts":true}},{"name":"Request distribution","id":"dist","run":"HAKUREI_REV=\"$(git rev-parse --short HEAD)\" \u0026\u0026 /rosa/bin/mbf ci race -o result . \"$(cat cmd/dist/VERSION)-$HAKUREI_REV\" \u0026\u0026 echo \"rev=$HAKUREI_REV\" \u003e\u003e \"$GITHUB_OUTPUT\""},{"name":"Install hakurei","run":"HAKUREI_VERSION=\"$(cat cmd/dist/VERSION)-${{ steps.dist.outputs.rev }}\" \u0026\u0026 tar xf result/hakurei-$HAKUREI_VERSION*-amd64.tar.gz \u0026\u0026 ./hakurei-$HAKUREI_VERSION*-amd64/install.sh \u0026\u0026 sudo -u ubuntu hakurei version \u0026\u0026 mkdir /var/empty"},{"name":"Compile and run test suite","run":"rm -rf result \u0026\u0026 go run -tags=testsuite ./cmd/hakurei/testsuite/sandbox"}]},"sharefs":{"name":"ShareFS","runs-on":"rosa","steps":[{"name":"Fix container filesystem","run":"rm /var/run \u0026\u0026 ln -sf ../run /var"},{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Set up Go toolchain","uses":"actions/setup-go@v6","with":{"go-version-file":"go.mod"}},{"name":"Install packages","uses":"awalsh128/cache-apt-pkgs-action@v1","with":{"add-repository":"","packages":"fuse3 fsmark","version":0,"execute_install_scripts":true}},{"name":"Request distribution","id":"dist","run":"HAKUREI_REV=\"$(git rev-parse --short HEAD)\" \u0026\u0026 /rosa/bin/mbf ci dist -o result . \"$(cat cmd/dist/VERSION)-$HAKUREI_REV\" \u0026\u0026 echo \"rev=$HAKUREI_REV\" \u003e\u003e \"$GITHUB_OUTPUT\""},{"name":"Install hakurei","run":"HAKUREI_VERSION=\"$(cat cmd/dist/VERSION)-${{ steps.dist.outputs.rev }}\" \u0026\u0026 tar xf result/hakurei-$HAKUREI_VERSION*-amd64.tar.gz \u0026\u0026 ./hakurei-$HAKUREI_VERSION*-amd64/install.sh \u0026\u0026 sudo -u ubuntu hakurei version \u0026\u0026 mkdir /var/empty"},{"name":"Mount sharefs","run":"useradd -ru 1023 -md /var/lib/sdcard -k /var/empty -s /sbin/nologin media_rw \u0026\u0026 install -dm0 /sdcard \u0026\u0026 sharefs -o rw,noexec,nosuid,nodev,noatime,allow_other,mkdir,source=/var/lib/sdcard,setuid=1023,setgid=1023 /sdcard"},{"name":"Compile and run test suite","run":"sharefs -V \u0026\u0026 rm -rf result \u0026\u0026 go run -tags=testsuite ./cmd/sharefs/testsuite"},{"name":"Upload test output","uses":"actions/upload-artifact@v3","with":{"name":"fs_mark","path":"result/*","retention-days":1}}]},"dist":{"name":"Create distribution","runs-on":"rosa","steps":[{"name":"Fix container filesystem","run":"rm /var/run \u0026\u0026 ln -sf ../run /var"},{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Request distribution","id":"dist-test","run":"HAKUREI_REV=\"$(git rev-parse --short HEAD)\" \u0026\u0026 /rosa/bin/mbf ci dist -o result . \"$(cat cmd/dist/VERSION)-$HAKUREI_REV\" \u0026\u0026 echo \"rev=$HAKUREI_REV\" \u003e\u003e \"$GITHUB_OUTPUT\""},{"name":"Upload distribution","uses":"actions/upload-artifact@v3","with":{"name":"dist-${{ steps.dist-test.outputs.rev }}","path":"result/*","retention-days":1}}]}}}
+{"name":"Test","on":["push"],"jobs":{"hakurei-legacy":{"name":"Hakurei (legacy)","runs-on":"nix","steps":[{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Run NixOS test","run":"nix build --out-link result --print-out-paths --print-build-logs ./cmd/hakurei/testsuite#checks.x86_64-linux.hakurei"},{"name":"Upload test output","uses":"actions/upload-artifact@v3","with":{"name":"hakurei-vm-output","path":"result/*","retention-days":1}}]},"hakurei-race-legacy":{"name":"Hakurei (legacy with race instrument)","runs-on":"nix","steps":[{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Run NixOS test","run":"nix build --out-link result --print-out-paths --print-build-logs ./cmd/hakurei/testsuite#checks.x86_64-linux.race"},{"name":"Upload test output","uses":"actions/upload-artifact@v3","with":{"name":"hakurei-race-vm-output","path":"result/*","retention-days":1}}]},"sandbox":{"name":"Sandbox","needs":["dist"],"runs-on":"rosa","steps":[{"name":"Fix container filesystem","run":"rm /var/run \u0026\u0026 ln -sf ../run /var"},{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Set up Go toolchain","uses":"actions/setup-go@v6","with":{"go-version-file":"go.mod"}},{"name":"Install packages","uses":"awalsh128/cache-apt-pkgs-action@v1","with":{"add-repository":"ppa:savoury1/pipewire","packages":"libmount-dev sway xwayland xdg-dbus-proxy pipewire","version":0,"execute_install_scripts":true}},{"name":"Download hakurei distribution","uses":"actions/download-artifact@v3","id":"download","with":{"name":"dist-${{ needs.dist.outputs.rev }}","path":"result"}},{"name":"Install hakurei","run":"HAKUREI_VERSION=\"$(cat cmd/dist/VERSION)\" \u0026\u0026 tar xf result/hakurei-$HAKUREI_VERSION*-amd64.tar.gz \u0026\u0026 ./hakurei-$HAKUREI_VERSION*-amd64/install.sh \u0026\u0026 sudo -u ubuntu hakurei version \u0026\u0026 mkdir /var/empty"},{"name":"Compile and run test suite","run":"rm -rf result \u0026\u0026 go run -tags=testsuite ./cmd/hakurei/testsuite/sandbox"}]},"sandbox-race":{"name":"Sandbox (with race instrument)","needs":["dist-race"],"runs-on":"rosa","steps":[{"name":"Fix container filesystem","run":"rm /var/run \u0026\u0026 ln -sf ../run /var"},{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Set up Go toolchain","uses":"actions/setup-go@v6","with":{"go-version-file":"go.mod"}},{"name":"Install packages","uses":"awalsh128/cache-apt-pkgs-action@v1","with":{"add-repository":"ppa:savoury1/pipewire","packages":"libmount-dev sway xwayland xdg-dbus-proxy pipewire","version":0,"execute_install_scripts":true}},{"name":"Download hakurei distribution","uses":"actions/download-artifact@v3","id":"download","with":{"name":"dist-${{ needs.dist-race.outputs.rev }}-race","path":"result"}},{"name":"Install hakurei","run":"HAKUREI_VERSION=\"$(cat cmd/dist/VERSION)\" \u0026\u0026 tar xf result/hakurei-$HAKUREI_VERSION*-amd64.tar.gz \u0026\u0026 ./hakurei-$HAKUREI_VERSION*-amd64/install.sh \u0026\u0026 sudo -u ubuntu hakurei version \u0026\u0026 mkdir /var/empty"},{"name":"Compile and run test suite","run":"rm -rf result \u0026\u0026 go run -tags=testsuite ./cmd/hakurei/testsuite/sandbox"}]},"sharefs":{"name":"ShareFS","needs":["dist"],"runs-on":"rosa","steps":[{"name":"Fix container filesystem","run":"rm /var/run \u0026\u0026 ln -sf ../run /var"},{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Set up Go toolchain","uses":"actions/setup-go@v6","with":{"go-version-file":"go.mod"}},{"name":"Install packages","uses":"awalsh128/cache-apt-pkgs-action@v1","with":{"add-repository":"","packages":"fuse3 fsmark","version":0,"execute_install_scripts":true}},{"name":"Download hakurei distribution","uses":"actions/download-artifact@v3","id":"download","with":{"name":"dist-${{ needs.dist.outputs.rev }}","path":"result"}},{"name":"Install hakurei","run":"HAKUREI_VERSION=\"$(cat cmd/dist/VERSION)\" \u0026\u0026 tar xf result/hakurei-$HAKUREI_VERSION*-amd64.tar.gz \u0026\u0026 ./hakurei-$HAKUREI_VERSION*-amd64/install.sh \u0026\u0026 sudo -u ubuntu hakurei version \u0026\u0026 mkdir /var/empty"},{"name":"Mount sharefs","run":"useradd -ru 1023 -md /var/lib/sdcard -k /var/empty -s /sbin/nologin media_rw \u0026\u0026 install -dm0 /sdcard \u0026\u0026 sharefs -o rw,noexec,nosuid,nodev,noatime,allow_other,mkdir,source=/var/lib/sdcard,setuid=1023,setgid=1023 /sdcard"},{"name":"Compile and run test suite","run":"sharefs -V \u0026\u0026 rm -rf result \u0026\u0026 go run -tags=testsuite ./cmd/sharefs/testsuite"},{"name":"Upload test output","uses":"actions/upload-artifact@v3","with":{"name":"fs_mark","path":"result/*","retention-days":1}}]},"dist":{"name":"Create distribution","runs-on":"rosa","outputs":{"rev":"${{ steps.dist.outputs.rev }}"},"steps":[{"name":"Fix container filesystem","run":"rm /var/run \u0026\u0026 ln -sf ../run /var"},{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Request distribution","id":"dist","run":"HAKUREI_REV=\"$(git rev-parse --short HEAD)\" \u0026\u0026 /rosa/bin/mbf ci dist -o result . \"$(cat cmd/dist/VERSION)-$HAKUREI_REV\" \u0026\u0026 echo \"rev=$HAKUREI_REV\" \u003e\u003e \"$GITHUB_OUTPUT\""},{"name":"Upload distribution","uses":"actions/upload-artifact@v3","with":{"name":"dist-${{ steps.dist.outputs.rev }}","path":"result/*","retention-days":1}}]},"dist-race":{"name":"Create distribution (with race instrument)","runs-on":"rosa","outputs":{"rev":"${{ steps.dist.outputs.rev }}"},"steps":[{"name":"Fix container filesystem","run":"rm /var/run \u0026\u0026 ln -sf ../run /var"},{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Request distribution","id":"dist","run":"HAKUREI_REV=\"$(git rev-parse --short HEAD)\" \u0026\u0026 /rosa/bin/mbf ci race -o result . \"$(cat cmd/dist/VERSION)-$HAKUREI_REV\" \u0026\u0026 echo \"rev=$HAKUREI_REV\" \u003e\u003e \"$GITHUB_OUTPUT\""},{"name":"Upload distribution","uses":"actions/upload-artifact@v3","with":{"name":"dist-${{ steps.dist.outputs.rev }}-race","path":"result/*","retention-days":1}}]}}}
diff --git a/internal/workflows/main.go b/internal/workflows/main.go
index dca480a5..81b14a12 100644
--- a/internal/workflows/main.go
+++ b/internal/workflows/main.go
@@ -79,6 +79,8 @@ type Job struct {
Needs []string `json:"needs,omitempty"`
// Define the type of machine to run the job on.
On string `json:"runs-on,omitempty"`
+ // Create a map of outputs for a job.
+ Outputs Map[string] `json:"outputs,omitempty"`
// A sequence of tasks.
Steps []Step `json:"steps,omitempty"`
}
diff --git a/internal/workflows/step.go b/internal/workflows/step.go
index 17ca25e1..fc95fd69 100644
--- a/internal/workflows/step.go
+++ b/internal/workflows/step.go
@@ -52,11 +52,35 @@ func newCIRequest(display, name, id string) Step {
}
}
+// download is a step to obtain a hakurei distribution.
+var download = Step{
+ Name: "Download hakurei distribution",
+ ID: "download",
+ Uses: "actions/download-artifact@v3",
+
+ With: []KV[any]{
+ {"name", "dist-${{ needs.dist.outputs.rev }}"},
+ {"path", "result"},
+ },
+}
+
+// _download is like download, but with race instrument.
+var _download = Step{
+ Name: "Download hakurei distribution",
+ ID: "download",
+ Uses: "actions/download-artifact@v3",
+
+ With: []KV[any]{
+ {"name", "dist-${{ needs.dist-race.outputs.rev }}-race"},
+ {"path", "result"},
+ },
+}
+
// install is a step to unpack and deploy a hakurei distribution created by a
// step with identifier dist.
var install = Step{
Name: "Install hakurei",
- Run: "HAKUREI_VERSION=\"$(cat cmd/dist/VERSION)-${{ steps.dist.outputs.rev }}\" && " +
+ Run: "HAKUREI_VERSION=\"$(cat cmd/dist/VERSION)\" && " +
"tar xf result/hakurei-$HAKUREI_VERSION*-amd64.tar.gz && " +
"./hakurei-$HAKUREI_VERSION*-amd64/install.sh && " +
"sudo -u ubuntu hakurei version && " +
diff --git a/internal/workflows/test.go b/internal/workflows/test.go
index 41ed05c5..1f9bba58 100644
--- a/internal/workflows/test.go
+++ b/internal/workflows/test.go
@@ -33,6 +33,7 @@ var _ = (&Workflow{
Name: "Sandbox",
On: "rosa",
+ Needs: []string{"dist"},
Steps: []Step{
fixup,
checkout,
@@ -45,7 +46,7 @@ var _ = (&Workflow{
"pipewire",
),
- newCIRequest("distribution", "dist -o result", "dist"),
+ download,
install,
newTestsuite("hakurei/testsuite/sandbox", ""),
},
@@ -55,6 +56,7 @@ var _ = (&Workflow{
Name: "Sandbox (with race instrument)",
On: "rosa",
+ Needs: []string{"dist-race"},
Steps: []Step{
fixup,
checkout,
@@ -68,7 +70,7 @@ var _ = (&Workflow{
"pipewire",
),
- newCIRequest("distribution", "race -o result", "dist"),
+ _download,
install,
newTestsuite("hakurei/testsuite/sandbox", ""),
},
@@ -78,13 +80,14 @@ var _ = (&Workflow{
Name: "ShareFS",
On: "rosa",
+ Needs: []string{"dist"},
Steps: []Step{
fixup,
checkout,
toolchain,
newPackages(0, nil, "fuse3", "fsmark"),
- newCIRequest("distribution", "dist -o result", "dist"),
+ download,
install,
{
@@ -110,13 +113,36 @@ var _ = (&Workflow{
Name: "Create distribution",
On: "rosa",
+ Outputs: []KV[string]{
+ {"rev", "${{ steps.dist.outputs.rev }}"},
+ },
+
+ Steps: []Step{
+ fixup,
+ checkout,
+ newCIRequest("distribution", "dist -o result", "dist"),
+ newUploadArtifact(
+ "distribution",
+ "dist-${{ steps.dist.outputs.rev }}",
+ ),
+ },
+ }},
+
+ {"dist-race", Job{
+ Name: "Create distribution (with race instrument)",
+ On: "rosa",
+
+ Outputs: []KV[string]{
+ {"rev", "${{ steps.dist.outputs.rev }}"},
+ },
+
Steps: []Step{
fixup,
checkout,
- newCIRequest("distribution", "dist -o result", "dist-test"),
+ newCIRequest("distribution", "race -o result", "dist"),
newUploadArtifact(
"distribution",
- "dist-${{ steps.dist-test.outputs.rev }}",
+ "dist-${{ steps.dist.outputs.rev }}-race",
),
},
}},