Skip to content

Commit

Permalink
fix: make protoc-gen-prost work (#3772)
Browse files Browse the repository at this point in the history
1. Redirect stdout to stderr so we don't break the protoc plugin
protocol
2. Use a file lock to avoid multiple concurrent invocations of
protoc-gen-prost running cargo install many times
  • Loading branch information
alecthomas authored Dec 16, 2024
1 parent abe958e commit 68ffe90
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
8 changes: 4 additions & 4 deletions backend/protos/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins:
out: ../../python-runtime/ftl/src/ftl/protos
opt:
- pyi_out=../../python-runtime/ftl/src/ftl/protos
# - plugin: prost
# out: ../../sqlc-gen-ftl/src/protos
# opt:
# - bytes=.
- plugin: prost
out: ../../sqlc-gen-ftl/src/protos
opt:
- bytes=.
17 changes: 14 additions & 3 deletions scripts/protoc-gen-prost
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@
set -euo pipefail

if [ ! "${HERMIT_ENV:-}" ]; then
# shellcheck disable=SC1091
. "$(dirname "$(dirname "$0")")/bin/activate-hermit"
# shellcheck disable=SC1091
. "$(dirname "$(dirname "$0")")/bin/activate-hermit" > /dev/null 2>&1
fi


function flockexec() {
file="$1"
shift
if [ "$(uname)" = "Darwin" ]; then
lockf -t 120 "$file" "$@"
else
flock -w 120 "$file" "$@"
fi
}

# Ensure the binary exists, install if it doesn't
mk "${HERMIT_ENV}/.hermit/rust/bin/protoc-gen-prost" : -- cargo install protoc-gen-prost
flockexec /tmp/protoc-gen-prost.lock mk "${HERMIT_ENV}/.hermit/rust/bin/protoc-gen-prost" : -- cargo install protoc-gen-prost 1>&2

# Execute the binary with any passed arguments
exec "${HERMIT_ENV}/.hermit/rust/bin/protoc-gen-prost" "$@"
7 changes: 4 additions & 3 deletions scripts/update-roadmap-issues
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
set -euo pipefail

label="$1"
issue_number="$2"
label="${1:-}"
issue_number="${2:-}"
if [ -z "$label" ] || [ -z "$issue_number" ]; then
echo "Error: Both label and issue number must be provided."
echo "Usage: $0 <label> <issue_number>"
Expand Down Expand Up @@ -130,7 +131,7 @@ EOF
}

update_issue() {
if test -z "$NOOP"; then
if test -z "${NOOP:-}"; then
gh issue edit -F - "$issue_number"
else
cat
Expand Down

0 comments on commit 68ffe90

Please sign in to comment.