chore(tvix): move store golang bindings to tvix/store-go
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>
This commit is contained in:
parent
e38733a955
commit
1b26bf21e3
20 changed files with 95 additions and 10 deletions
|
@ -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 ]}"
|
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 .)
|
(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
|
# Check if any files have changed
|
||||||
if [[ -n "$(git status --porcelain -unormal)" ]]; then
|
if [[ -n "$(git status --porcelain -unormal)" ]]; then
|
||||||
echo "-----------------------------"
|
echo "-----------------------------"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
location = /go-get/tvix/store/protos {
|
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 {
|
location = /go-get/tvix/nar-bridge {
|
||||||
|
|
|
@ -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)
|
(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.
|
# Update `.pb.go` files in tvix/store-go with the generated ones.
|
||||||
store-protos-go = pkgs.buildGoModule {
|
store-go-generate = pkgs.writeShellScriptBin "store-go-protogen" ''
|
||||||
name = "store-golang";
|
(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)
|
||||||
src = depot.third_party.gitignoreSource ./store/protos;
|
'';
|
||||||
vendorHash = "sha256-WAYaIT3h3Cdvo1RB8T7DuoxeKvXfkq8vo/vdkhJQDs0=";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Build the Rust documentation for publishing on docs.tvix.dev.
|
# Build the Rust documentation for publishing on docs.tvix.dev.
|
||||||
rust-docs = pkgs.stdenv.mkDerivation {
|
rust-docs = pkgs.stdenv.mkDerivation {
|
||||||
|
@ -144,7 +142,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
meta.ci.targets = [
|
meta.ci.targets = [
|
||||||
"store-protos-go"
|
|
||||||
"shell"
|
"shell"
|
||||||
"rust-docs"
|
"rust-docs"
|
||||||
];
|
];
|
||||||
|
|
21
tvix/store-go/LICENSE
Normal file
21
tvix/store-go/LICENSE
Normal file
|
@ -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.
|
||||||
|
|
10
tvix/store-go/README.md
Normal file
10
tvix/store-go/README.md
Normal file
|
@ -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.
|
25
tvix/store-go/default.nix
Normal file
25
tvix/store-go/default.nix
Normal file
|
@ -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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
34
tvix/store/protos/default.nix
Normal file
34
tvix/store/protos/default.nix
Normal file
|
@ -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/
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue