Skip to content

Commit 561bb13

Browse files
authored
Install protoc during tests (#388)
* grpcio-tools 1.48 was yanked * Install protoc during tests Previously it was a prereq of the testsuite
1 parent aca524f commit 561bb13

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

.github/workflows/main.yml

-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ jobs:
3030
echo ::set-output name=PROTOBUF_VERSION::$(grep "^protobuf>=" test_requirements.txt | cut -f2 -d=)
3131
echo ::set-output name=PYRIGHT_VERSION::$(grep '"pyright"' .github/package.json | cut -d\" -f4)
3232
id: read_versions
33-
- name: Install Protoc
34-
uses: arduino/setup-protoc@v1
35-
with:
36-
version: "${{ steps.read_versions.outputs.PROTOBUF_VERSION }}"
3733
- name: Cache pyenv
3834
uses: actions/cache@v2
3935
with:

.gitignore

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/go/src/github.com
21
/main
32
.*.swp
43
__pycache__/
@@ -14,6 +13,6 @@ __pycache__/
1413
/dist/
1514
*.egg-info
1615
.idea/
17-
*.DS_Store
18-
*venv*
19-
/runenv
16+
.DS_Store
17+
/venv_*
18+
/protoc_*

run_test.sh

+25-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
RED="\033[0;31m"
44
NC='\033[0m'
5-
PROTOC=${PROTOC:=protoc}
65

76
PY_VER_MYPY_PROTOBUF=${PY_VER_MYPY_PROTOBUF:=3.10.1}
87
PY_VER_MYPY_PROTOBUF_SHORT=$(echo $PY_VER_MYPY_PROTOBUF | cut -d. -f1-2)
@@ -16,6 +15,31 @@ if [ -e $CUSTOM_TYPESHED_DIR ]; then
1615
export MYPYPATH=$CUSTOM_TYPESHED_DIR/stubs/protobuf
1716
fi
1817

18+
# Install protoc
19+
PROTOBUF_VERSION=$(grep "^protobuf>=" test_requirements.txt | cut -f2 -d=)
20+
PROTOC_DIR="protoc_$PROTOBUF_VERSION"
21+
if [[ -z $SKIP_CLEAN ]] || [[ ! -e $PROTOC_DIR ]]; then
22+
if uname -a | grep Darwin; then
23+
# brew install coreutils wget
24+
PLAT=osx
25+
else
26+
PLAT=linux
27+
fi
28+
29+
PROTOC_FILENAME="protoc-${PROTOBUF_VERSION}-${PLAT}-x86_64.zip"
30+
PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/$PROTOC_FILENAME"
31+
32+
rm -rf "$PROTOC_DIR"
33+
wget "$PROTOC_URL" -P "$PROTOC_DIR"
34+
mkdir -p "$PROTOC_DIR/protoc_install"
35+
unzip "$PROTOC_DIR/$PROTOC_FILENAME" -d "$PROTOC_DIR/protoc_install"
36+
fi
37+
PROTOC="$PROTOC_DIR/protoc_install/bin/protoc"
38+
if [[ $($PROTOC --version) != "libprotoc $PROTOBUF_VERSION" ]]; then
39+
echo -e "${RED}Wrong protoc installed?"
40+
exit 1
41+
fi
42+
1943
# Create mypy venv
2044
MYPY_VENV=venv_$PY_VER_MYPY
2145
(
@@ -82,11 +106,6 @@ MYPY_PROTOBUF_VENV=venv_$PY_VER_MYPY_PROTOBUF
82106
# Generate protos
83107
python --version
84108
$PROTOC --version
85-
expected="libprotoc 3.19.4"
86-
if [[ $($PROTOC --version) != $expected ]]; then
87-
echo -e "${RED}For tests - must install protoc version ${expected} ${NC}"
88-
exit 1
89-
fi
90109

91110
# CI Check to make sure generated files are committed
92111
SHA_BEFORE=$(find test/generated -name "*.pyi" | xargs sha1sum)

0 commit comments

Comments
 (0)