Skip to content

Commit 29dce77

Browse files
committed
guard against CI set COVERAGE env
1 parent fbfdfbf commit 29dce77

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/generate.jl

+7-4
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,17 @@ end
121121
# Defining a local protoc to avoid issues with ProtoBuf.protoc,
122122
# wherein it was using the form `protoc_jll.protoc() do .. end`
123123
# which is now deprecated and is causing errors in code generation.
124-
function grpc_protoc(args=``)
124+
function grpc_protoc(args=``; protoc_path=ProtoBuf.protoc_jll.protoc())
125125
plugin_dir = abspath(joinpath(dirname(pathof(ProtoBuf)), "..", "plugin"))
126126
plugin = joinpath(plugin_dir, Sys.iswindows() ? "protoc-gen-julia_win.bat" : "protoc-gen-julia")
127127

128-
protoc_path = ProtoBuf.protoc_jll.protoc()
129128
ENV= copy(ENV)
130129
ENV′["PATH"] = string(plugin_dir, Sys.iswindows() ? ";" : ":", ENV′["PATH"])
131130
ENV′["JULIA"] = joinpath(Sys.BINDIR, Base.julia_exename())
131+
# protobuf plugin uses COVERAGE env var to pass coverage flag to julia
132+
# we do not want to pass unintended values that sometimes CI environments set
133+
# we also do not intend to trigger coverage in the plugin while running CI in this package
134+
ENV′["COVERAGE"] = ""
132135
run(setenv(`$protoc_path --plugin=protoc-gen-julia=$plugin $args`, ENV′))
133136
end
134137

@@ -141,7 +144,7 @@ Generate a gRPC client from protobuf specification file.
141144
- `outdir`: Directory to write generated code into, created if not present
142145
already. Existing files if any will be overwtitten.
143146
"""
144-
function generate(proto::String; outdir::String=pwd(), includes::Vector{String}=String[])
147+
function generate(proto::String; outdir::String=pwd(), includes::Vector{String}=String[], protoc_path=ProtoBuf.protoc_jll.protoc())
145148
if !isfile(proto)
146149
throw(ArgumentError("No such file - $proto"))
147150
end
@@ -163,7 +166,7 @@ function generate(proto::String; outdir::String=pwd(), includes::Vector{String}=
163166
bindir = Sys.BINDIR
164167
pathenv = string(ENV["PATH"], Sys.iswindows() ? ";" : ":", bindir)
165168
withenv("PATH"=>pathenv) do
166-
grpc_protoc(`$includeflag --julia_out=$outdir $proto`)
169+
grpc_protoc(`$includeflag --julia_out=$outdir $proto`; protoc_path=protoc_path)
167170
end
168171

169172
# include the generated code and detect service method names

0 commit comments

Comments
 (0)