about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-10-17T12·42+0100
committerflokli <flokli@flokli.de>2023-10-17T19·51+0000
commit1b26bf21e3305232b9bbdc928a063da9be9eaee0 (patch)
treed5ee335a6c76cc54095266ec685e4a8dae515a2e
parente38733a955f6f6fc8962cf0e669d9cf4696bc14d (diff)
chore(tvix): move store golang bindings to tvix/store-go r/6844
Similar to the castore-go CL before, this also updates the store-go
bindings to the new layout.

Change-Id: Id73d7ad43f7d70171ab021728e303300c5db71f0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9788
Tested-by: BuildkiteCI
Reviewed-by: Connor Brewster <cbrewster@hey.com>
-rw-r--r--nix/bufCheck/default.nix2
-rw-r--r--ops/modules/www/code.tvl.fyi.nix2
-rw-r--r--tvix/default.nix11
-rw-r--r--tvix/store-go/LICENSE21
-rw-r--r--tvix/store-go/README.md10
-rw-r--r--tvix/store-go/default.nix25
-rw-r--r--tvix/store-go/export.go (renamed from tvix/store/protos/export.go)0
-rw-r--r--tvix/store-go/export_test.go (renamed from tvix/store/protos/export_test.go)0
-rw-r--r--tvix/store-go/go.mod (renamed from tvix/store/protos/go.mod)0
-rw-r--r--tvix/store-go/go.sum (renamed from tvix/store/protos/go.sum)0
-rw-r--r--tvix/store-go/pathinfo.go (renamed from tvix/store/protos/pathinfo.go)0
-rw-r--r--tvix/store-go/pathinfo.pb.go (renamed from tvix/store/protos/pathinfo.pb.go)0
-rw-r--r--tvix/store-go/pathinfo_test.go (renamed from tvix/store/protos/pathinfo_test.go)0
-rw-r--r--tvix/store-go/pick_next_node_test.go (renamed from tvix/store/protos/pick_next_node_test.go)0
-rw-r--r--tvix/store-go/rpc_pathinfo.pb.go (renamed from tvix/store/protos/rpc_pathinfo.pb.go)0
-rw-r--r--tvix/store-go/rpc_pathinfo_grpc.pb.go (renamed from tvix/store/protos/rpc_pathinfo_grpc.pb.go)0
-rw-r--r--tvix/store-go/testdata/emptydirectory.nar (renamed from tvix/store/protos/testdata/emptydirectory.nar)bin96 -> 96 bytes
-rw-r--r--tvix/store-go/testdata/onebyteregular.nar (renamed from tvix/store/protos/testdata/onebyteregular.nar)bin120 -> 120 bytes
-rw-r--r--tvix/store-go/testdata/symlink.nar (renamed from tvix/store/protos/testdata/symlink.nar)bin136 -> 136 bytes
-rw-r--r--tvix/store/protos/default.nix34
20 files changed, 95 insertions, 10 deletions
diff --git a/nix/bufCheck/default.nix b/nix/bufCheck/default.nix
index f247e6839eee..90c0ca3cb6a2 100644
--- a/nix/bufCheck/default.nix
+++ b/nix/bufCheck/default.nix
@@ -6,8 +6,6 @@ pkgs.writeShellScriptBin "ci-buf-check" ''
   export PATH="$PATH:${pkgs.lib.makeBinPath [ pkgs.buf pkgs.protoc-gen-go pkgs.protoc-gen-go-grpc ]}"
   (cd $(git rev-parse --show-toplevel) && buf lint .)
 
-  # Run buf generate, and bail out if generated files are changed.
-  (cd $(git rev-parse --show-toplevel) && buf generate --path tvix/store/protos)
   # Check if any files have changed
   if [[ -n "$(git status --porcelain -unormal)" ]]; then
       echo "-----------------------------"
diff --git a/ops/modules/www/code.tvl.fyi.nix b/ops/modules/www/code.tvl.fyi.nix
index 6a7e4b25038a..b64f8f8cef7b 100644
--- a/ops/modules/www/code.tvl.fyi.nix
+++ b/ops/modules/www/code.tvl.fyi.nix
@@ -25,7 +25,7 @@
         }
 
         location = /go-get/tvix/store/protos {
-            alias ${pkgs.writeText "go-import-metadata.html" ''<html><meta name="go-import" content="code.tvl.fyi/tvix/store/protos git https://code.tvl.fyi/depot.git:/tvix/store/protos.git"></html>''};
+            alias ${pkgs.writeText "go-import-metadata.html" ''<html><meta name="go-import" content="code.tvl.fyi/tvix/store/protos git https://code.tvl.fyi/depot.git:/tvix/store-go.git"></html>''};
         }
 
         location = /go-get/tvix/nar-bridge {
diff --git a/tvix/default.nix b/tvix/default.nix
index 3365fe79812e..28e64d574a6e 100644
--- a/tvix/default.nix
+++ b/tvix/default.nix
@@ -111,12 +111,10 @@ in
     (cd $(git rev-parse --show-toplevel)/tvix/castore-go && rm *.pb.go && cp ${depot.tvix.castore.protos.go-bindings}/*.pb.go . && chmod +w *.pb.go)
   '';
 
-  # Builds and tests the code in store/protos.
-  store-protos-go = pkgs.buildGoModule {
-    name = "store-golang";
-    src = depot.third_party.gitignoreSource ./store/protos;
-    vendorHash = "sha256-WAYaIT3h3Cdvo1RB8T7DuoxeKvXfkq8vo/vdkhJQDs0=";
-  };
+  # Update `.pb.go` files in tvix/store-go with the generated ones.
+  store-go-generate = pkgs.writeShellScriptBin "store-go-protogen" ''
+    (cd $(git rev-parse --show-toplevel)/tvix/store-go && rm *.pb.go && cp ${depot.tvix.store.protos.go-bindings}/*.pb.go . && chmod +w *.pb.go)
+  '';
 
   # Build the Rust documentation for publishing on docs.tvix.dev.
   rust-docs = pkgs.stdenv.mkDerivation {
@@ -144,7 +142,6 @@ in
   };
 
   meta.ci.targets = [
-    "store-protos-go"
     "shell"
     "rust-docs"
   ];
diff --git a/tvix/store-go/LICENSE b/tvix/store-go/LICENSE
new file mode 100644
index 000000000000..2034ada6fd9a
--- /dev/null
+++ b/tvix/store-go/LICENSE
@@ -0,0 +1,21 @@
+Copyright © The Tvix Authors
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+“Software”), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/tvix/store-go/README.md b/tvix/store-go/README.md
new file mode 100644
index 000000000000..4cfa55a35402
--- /dev/null
+++ b/tvix/store-go/README.md
@@ -0,0 +1,10 @@
+# store-go
+
+This directory contains generated golang bindings, both for the tvix-store data
+models, as well as the gRPC bindings.
+
+They are generated with `mg run //tvix:store-go-generate`.
+These files end with `.pb.go`, and are ensured to be up to date by Ci check.
+
+Additionally, code useful when interacting with these data structures
+(ending just with `.go`) is provided.
\ No newline at end of file
diff --git a/tvix/store-go/default.nix b/tvix/store-go/default.nix
new file mode 100644
index 000000000000..b559594a27f2
--- /dev/null
+++ b/tvix/store-go/default.nix
@@ -0,0 +1,25 @@
+{ depot, pkgs, ... }:
+
+(pkgs.buildGoModule {
+  name = "store-go";
+  src = depot.third_party.gitignoreSource ./.;
+  vendorHash = "sha256-WAYaIT3h3Cdvo1RB8T7DuoxeKvXfkq8vo/vdkhJQDs0=";
+}).overrideAttrs (_: {
+  meta.ci.extraSteps = {
+    check = {
+      label = ":water_buffalo: ensure generated protobuf files match";
+      needsOutput = true;
+      command = pkgs.writeShellScript "pb-go-check" ''
+        ${depot.tvix.store-go-generate}
+        if [[ -n "$(git status --porcelain -unormal)" ]]; then
+            echo "-----------------------------"
+            echo ".pb.go files need to be updated, run //tvix:store-go-generate"
+            echo "-----------------------------"
+            git status -unormal
+            exit 1
+        fi
+      '';
+      alwaysRun = true;
+    };
+  };
+})
diff --git a/tvix/store/protos/export.go b/tvix/store-go/export.go
index 889311efe70b..889311efe70b 100644
--- a/tvix/store/protos/export.go
+++ b/tvix/store-go/export.go
diff --git a/tvix/store/protos/export_test.go b/tvix/store-go/export_test.go
index 6c33bdc90117..6c33bdc90117 100644
--- a/tvix/store/protos/export_test.go
+++ b/tvix/store-go/export_test.go
diff --git a/tvix/store/protos/go.mod b/tvix/store-go/go.mod
index d56e2d9bc1b4..d56e2d9bc1b4 100644
--- a/tvix/store/protos/go.mod
+++ b/tvix/store-go/go.mod
diff --git a/tvix/store/protos/go.sum b/tvix/store-go/go.sum
index c412d838e289..c412d838e289 100644
--- a/tvix/store/protos/go.sum
+++ b/tvix/store-go/go.sum
diff --git a/tvix/store/protos/pathinfo.go b/tvix/store-go/pathinfo.go
index 8c0b94f200c1..8c0b94f200c1 100644
--- a/tvix/store/protos/pathinfo.go
+++ b/tvix/store-go/pathinfo.go
diff --git a/tvix/store/protos/pathinfo.pb.go b/tvix/store-go/pathinfo.pb.go
index b8296114f602..b8296114f602 100644
--- a/tvix/store/protos/pathinfo.pb.go
+++ b/tvix/store-go/pathinfo.pb.go
diff --git a/tvix/store/protos/pathinfo_test.go b/tvix/store-go/pathinfo_test.go
index 9a329f0010fc..9a329f0010fc 100644
--- a/tvix/store/protos/pathinfo_test.go
+++ b/tvix/store-go/pathinfo_test.go
diff --git a/tvix/store/protos/pick_next_node_test.go b/tvix/store-go/pick_next_node_test.go
index 830c6cacc136..830c6cacc136 100644
--- a/tvix/store/protos/pick_next_node_test.go
+++ b/tvix/store-go/pick_next_node_test.go
diff --git a/tvix/store/protos/rpc_pathinfo.pb.go b/tvix/store-go/rpc_pathinfo.pb.go
index 8a3c10a82101..8a3c10a82101 100644
--- a/tvix/store/protos/rpc_pathinfo.pb.go
+++ b/tvix/store-go/rpc_pathinfo.pb.go
diff --git a/tvix/store/protos/rpc_pathinfo_grpc.pb.go b/tvix/store-go/rpc_pathinfo_grpc.pb.go
index 10d8a7ffa49c..10d8a7ffa49c 100644
--- a/tvix/store/protos/rpc_pathinfo_grpc.pb.go
+++ b/tvix/store-go/rpc_pathinfo_grpc.pb.go
diff --git a/tvix/store/protos/testdata/emptydirectory.nar b/tvix/store-go/testdata/emptydirectory.nar
index baba55862255..baba55862255 100644
--- a/tvix/store/protos/testdata/emptydirectory.nar
+++ b/tvix/store-go/testdata/emptydirectory.nar
Binary files differdiff --git a/tvix/store/protos/testdata/onebyteregular.nar b/tvix/store-go/testdata/onebyteregular.nar
index b8c94932bf0c..b8c94932bf0c 100644
--- a/tvix/store/protos/testdata/onebyteregular.nar
+++ b/tvix/store-go/testdata/onebyteregular.nar
Binary files differdiff --git a/tvix/store/protos/testdata/symlink.nar b/tvix/store-go/testdata/symlink.nar
index 7990e4ad5bc2..7990e4ad5bc2 100644
--- a/tvix/store/protos/testdata/symlink.nar
+++ b/tvix/store-go/testdata/symlink.nar
Binary files differdiff --git a/tvix/store/protos/default.nix b/tvix/store/protos/default.nix
new file mode 100644
index 000000000000..5f56eda79b3d
--- /dev/null
+++ b/tvix/store/protos/default.nix
@@ -0,0 +1,34 @@
+{ depot, pkgs, ... }: {
+  # Produces the golang bindings.
+  go-bindings = pkgs.stdenv.mkDerivation {
+    name = "go-bindings";
+
+    src = depot.nix.sparseTree {
+      name = "castore-protos";
+      root = depot.path.origSrc;
+      paths = [
+        # We need to include castore.proto (only), as it's referred.
+        ../../castore/protos/castore.proto
+        ./pathinfo.proto
+        ./rpc_pathinfo.proto
+        ../../../buf.yaml
+        ../../../buf.gen.yaml
+      ];
+    };
+
+    nativeBuildInputs = [
+      pkgs.buf
+      pkgs.protoc-gen-go
+      pkgs.protoc-gen-go-grpc
+    ];
+
+    buildPhase = ''
+      export HOME=$TMPDIR
+      buf lint
+      buf generate
+
+      mkdir -p $out
+      cp tvix/store/protos/*.pb.go $out/
+    '';
+  };
+}