Skip to content

Commit f99df24

Browse files
authored
[nix] Install protobuf codegen binaries in the dev shell (#3829)
1 parent aa2c4b5 commit f99df24

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

.github/workflows/buf-push.yml

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ jobs:
2121
# Breaking changes are managed by the rpcchainvm protocol version.
2222
breaking: false
2323
token: ${{ secrets.BUF_TOKEN }}
24+
# This version should match the version installed in the nix dev shell
2425
version: 1.47.2

.github/workflows/ci.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,17 @@ jobs:
150150
# which is never desirable for this job. The buf-push job is
151151
# responsible for pushes.
152152
push: false
153+
# This version should match the version installed in the nix dev shell
153154
version: 1.47.2
154155
check_generated_protobuf:
155156
name: Up-to-date protobuf
156157
runs-on: ubuntu-latest
157158
steps:
158159
- uses: actions/checkout@v4
159160
- uses: ./.github/actions/setup-go-for-project
160-
- uses: bufbuild/buf-action@1b8e0a0e793562b7850d7e6ff0228b5c0b16111c #v1.1.0
161-
with:
162-
setup_only: true
163-
version: 1.47.2
164-
- shell: bash
161+
# Use the dev shell instead of bufbuild/buf-action to ensure the dev shell provides the expected versions
162+
- uses: ./.github/actions/install-nix
163+
- shell: nix develop --command bash -x {0}
165164
run: scripts/protobuf_codegen.sh
166165
- shell: bash
167166
run: .github/workflows/check-clean-branch.sh

flake.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# Flake inputs
1010
inputs = {
11-
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2405.*.tar.gz";
11+
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2411.*.tar.gz";
1212
};
1313

1414
# Flake outputs
@@ -45,6 +45,11 @@
4545

4646
# Linters
4747
shellcheck
48+
49+
# Protobuf
50+
buf
51+
protoc-gen-go
52+
protoc-gen-go-grpc
4853
] ++ lib.optionals stdenv.isDarwin [
4954
# macOS-specific frameworks
5055
darwin.apple_sdk.frameworks.Security

proto/buf.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ breaking:
99
use:
1010
- FILE
1111
deps:
12-
- buf.build/prometheus/client-model
12+
- buf.build/prometheus/client-model
1313
lint:
1414
use:
15-
- DEFAULT
15+
- STANDARD
1616
except:
1717
- SERVICE_SUFFIX # service requirement of <name>+Service
1818
- RPC_REQUEST_STANDARD_NAME # explicit <rpc>+Request naming
@@ -24,7 +24,7 @@ lint:
2424
- aliasreader/aliasreader.proto
2525
- net/conn/conn.proto
2626
# allows RPC requests or responses to be google.protobuf.Empty messages. This can be set if you
27-
# want to allow messages to be void forever, that is they will never take any parameters.
27+
# want to allow messages to be void forever, that is they will never take any parameters.
2828
rpc_allow_google_protobuf_empty_requests: true
2929
rpc_allow_google_protobuf_empty_responses: true
3030
# allows the same message type to be used for a single RPC's request and response type.

scripts/protobuf_codegen.sh

+4-6
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,25 @@ if ! [[ "$0" =~ scripts/protobuf_codegen.sh ]]; then
77
exit 255
88
fi
99

10+
# the versions here should match those of the binaries installed in the nix dev shell
11+
1012
## ensure the correct version of "buf" is installed
1113
BUF_VERSION='1.47.2'
1214
if [[ $(buf --version | cut -f2 -d' ') != "${BUF_VERSION}" ]]; then
1315
echo "could not find buf ${BUF_VERSION}, is it installed + in PATH?"
1416
exit 255
1517
fi
1618

17-
## install "protoc-gen-go"
19+
## ensure the correct version of "protoc-gen-go" is installed
1820
PROTOC_GEN_GO_VERSION='v1.35.1'
19-
go install -v google.golang.org/protobuf/cmd/protoc-gen-go@${PROTOC_GEN_GO_VERSION}
2021
if [[ $(protoc-gen-go --version | cut -f2 -d' ') != "${PROTOC_GEN_GO_VERSION}" ]]; then
21-
# e.g., protoc-gen-go v1.28.1
2222
echo "could not find protoc-gen-go ${PROTOC_GEN_GO_VERSION}, is it installed + in PATH?"
2323
exit 255
2424
fi
2525

26-
### install "protoc-gen-go-grpc"
26+
## ensure the correct version of "protoc-gen-go-grpc" is installed
2727
PROTOC_GEN_GO_GRPC_VERSION='1.3.0'
28-
go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${PROTOC_GEN_GO_GRPC_VERSION}
2928
if [[ $(protoc-gen-go-grpc --version | cut -f2 -d' ') != "${PROTOC_GEN_GO_GRPC_VERSION}" ]]; then
30-
# e.g., protoc-gen-go-grpc 1.3.0
3129
echo "could not find protoc-gen-go-grpc ${PROTOC_GEN_GO_GRPC_VERSION}, is it installed + in PATH?"
3230
exit 255
3331
fi

0 commit comments

Comments
 (0)