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 f247e6839e..90c0ca3cb6 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 6a7e4b2503..b64f8f8cef 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 3365fe7981..28e64d574a 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 0000000000..2034ada6fd
--- /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 0000000000..4cfa55a354
--- /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 0000000000..b559594a27
--- /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 889311efe7..889311efe7 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 6c33bdc901..6c33bdc901 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 d56e2d9bc1..d56e2d9bc1 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 c412d838e2..c412d838e2 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 8c0b94f200..8c0b94f200 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 b8296114f6..b8296114f6 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 9a329f0010..9a329f0010 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 830c6cacc1..830c6cacc1 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 8a3c10a821..8a3c10a821 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 10d8a7ffa4..10d8a7ffa4 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 baba558622..baba558622 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 b8c94932bf..b8c94932bf 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 7990e4ad5b..7990e4ad5b 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 0000000000..5f56eda79b
--- /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/
+    '';
+  };
+}