Skip to content

An open-source, faster Devin alternative

TypeScript

test(cli): pin managed Flue build contract

Igor Zalutskic39b31560cb7
diff --git a/.github/workflows/flue-managed-build-golden.yml b/.github/workflows/flue-managed-build-golden.yml
new file mode 100644
index 00000000..409a9854
--- /dev/null
+++ b/.github/workflows/flue-managed-build-golden.yml
@@ -0,0 +1,39 @@
+name: Flue managed-build golden
+
+on:
+ push:
+ branches: [main]
+ paths:
+ - 'cmd/oc/**'
+ - 'ci/flue-managed-build-golden.sh'
+ - 'go.mod'
+ - 'go.sum'
+ - '.github/workflows/flue-managed-build-golden.yml'
+ pull_request:
+ paths:
+ - 'cmd/oc/**'
+ - 'ci/flue-managed-build-golden.sh'
+ - 'go.mod'
+ - 'go.sum'
+ - '.github/workflows/flue-managed-build-golden.yml'
+
+permissions:
+ contents: read
+
+jobs:
+ golden:
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-go@v5
+ with:
+ go-version-file: go.mod
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: '22.19'
+
+ - name: Verify current CLI against pinned starter artifact
+ run: ./ci/flue-managed-build-golden.sh
diff --git a/ci/flue-managed-build-golden.sh b/ci/flue-managed-build-golden.sh
new file mode 100755
index 00000000..7041426d
--- /dev/null
+++ b/ci/flue-managed-build-golden.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+# Cross-repository contract fixture for `oc agent build`.
+#
+# The default coordinate is intentionally immutable. To review a fixture
+# update before changing this pin, run for example:
+# STARTER_REF=<commit> ./ci/flue-managed-build-golden.sh
+STARTER_REPO="${STARTER_REPO:-https://github.com/diggerhq/oc-flue-starter.git}"
+STARTER_REF="${STARTER_REF:-5c51d7edbbf2472fbe48386c4f9b192279330c9b}"
+
+ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+TMP="$(mktemp -d)"
+trap 'rm -rf "$TMP"' EXIT
+
+NODE_VERSION="$(node -p 'process.versions.node')"
+if [[ ! "$NODE_VERSION" =~ ^22\.19\. ]]; then
+ echo "managed-build golden requires Node 22.19.x (found $NODE_VERSION)" >&2
+ exit 1
+fi
+
+echo "Building current oc source"
+CGO_ENABLED=0 go build \
+ -ldflags "-s -w -X github.com/opensandbox/opensandbox/cmd/oc/internal/commands.Version=ci-golden" \
+ -o "$TMP/oc" \
+ "$ROOT/cmd/oc"
+
+echo "Checking out managed-build fixture $STARTER_REPO@$STARTER_REF"
+git init -q "$TMP/starter"
+git -C "$TMP/starter" remote add origin "$STARTER_REPO"
+git -C "$TMP/starter" fetch -q --depth=1 origin "$STARTER_REF"
+git -C "$TMP/starter" checkout -q --detach FETCH_HEAD
+test "$(git -C "$TMP/starter" rev-parse HEAD)" = "$STARTER_REF"
+
+(
+ cd "$TMP/starter"
+ npm ci --no-audit --no-fund
+ OC_BIN="$TMP/oc" npm run test:fixtures
+)
diff --git a/cmd/oc/internal/fluebuild/fluebuild.go b/cmd/oc/internal/fluebuild/fluebuild.go
index 3d9b287f..3259c14f 100644
--- a/cmd/oc/internal/fluebuild/fluebuild.go
+++ b/cmd/oc/internal/fluebuild/fluebuild.go
@@ -270,8 +270,8 @@ func ValidateDeployment(deployment Deployment, requireArtifact bool) error {
if deployment.Vars == nil {
return fmt.Errorf("deployment vars must be an object")
}
- if deployment.Runtime.Family != "flue" || deployment.Runtime.Type == "" {
- return fmt.Errorf("deployment runtime must contain family=flue and a type")
+ if deployment.Runtime.Family != "flue" || deployment.Runtime.Type != "default" {
+ return fmt.Errorf("deployment runtime must be family=%q, type=%q", "flue", "default")
}
if !strings.HasPrefix(deployment.Builder.Version, "oc@") || strings.TrimPrefix(deployment.Builder.Version, "oc@") == "" {
return fmt.Errorf("deployment builder.version must use oc@<version>")
@@ -327,6 +327,9 @@ func inspect(ctx context.Context, dir, builderVersion, nodeVersion string) (Depl
if m.Runtime.Type == "" {
m.Runtime.Type = "default"
}
+ if m.Runtime.Type != "default" {
+ return Deployment{}, fmt.Errorf("agent.toml runtime.type %q is unsupported; managed Flue currently requires %q", m.Runtime.Type, "default")
+ }
if m.Vars == nil {
m.Vars = Vars{}
}
diff --git a/cmd/oc/internal/fluebuild/fluebuild_test.go b/cmd/oc/internal/fluebuild/fluebuild_test.go
index ba696e81..13182632 100644
--- a/cmd/oc/internal/fluebuild/fluebuild_test.go
+++ b/cmd/oc/internal/fluebuild/fluebuild_test.go
@@ -151,6 +151,26 @@ func TestCheckOnlyRejectsUnsupportedBuilderNode(t *testing.T) {
}
}
+func TestCheckOnlyRejectsUnsupportedRuntimeType(t *testing.T) {
+ dir := copyFixture(t)
+ manifestPath := filepath.Join(dir, "agent.toml")
+ manifest, err := os.ReadFile(manifestPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ manifest = bytes.Replace(manifest, []byte(`family = "flue"`), []byte("family = \"flue\"\ntype = \"durable\""), 1)
+ if err := os.WriteFile(manifestPath, manifest, 0o644); err != nil {
+ t.Fatal(err)
+ }
+
+ _, err = Build(context.Background(), Options{
+ Dir: dir, CheckOnly: true, BuilderVersion: testBuilderVersion, NodeVersion: testNodeVersion,
+ })
+ if err == nil || !strings.Contains(err.Error(), `runtime.type "durable" is unsupported`) || !strings.Contains(err.Error(), `requires "default"`) {
+ t.Fatalf("expected actionable runtime.type rejection, got %v", err)
+ }
+}
+
func TestParseDeploymentRejectsUnknownFields(t *testing.T) {
raw, err := os.ReadFile(filepath.Join("testdata", "check-only.json"))
if err != nil {
@@ -162,6 +182,17 @@ func TestParseDeploymentRejectsUnknownFields(t *testing.T) {
}
}
+func TestParseDeploymentRejectsUnsupportedRuntimeType(t *testing.T) {
+ raw, err := os.ReadFile(filepath.Join("testdata", "check-only.json"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ raw = bytes.Replace(raw, []byte(`"type": "default"`), []byte(`"type": "durable"`), 1)
+ if _, err := ParseDeployment(raw, false); err == nil || !strings.Contains(err.Error(), `type="default"`) {
+ t.Fatalf("expected frozen runtime type rejection, got %v", err)
+ }
+}
+
func copyFixture(t *testing.T) string {
t.Helper()
src := filepath.Join("testdata", "starter")