Use shell script to install protobuf

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko 2023-09-16 18:36:04 -07:00
parent 9388ecf699
commit ece06a08be
No known key found for this signature in database
3 changed files with 28 additions and 16 deletions

View File

@ -17,9 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: ./scripts/install-protobuf.sh
- run: cargo check --examples --tests -p containerd-shim -p containerd-shim-protos
- run: rustup toolchain install nightly --component rustfmt
@ -41,9 +39,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: ./scripts/install-protobuf.sh
- name: Tests
run: |
cargo test -p containerd-shim -p containerd-shim-protos

View File

@ -18,9 +18,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: ./scripts/install-protobuf.sh
- run: cargo check --examples --tests --all-targets
- run: cargo check --examples --tests --all-targets --all-features
@ -45,16 +45,13 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: ./scripts/install-protobuf.sh
- env:
# runc::tests::test_exec needs $XDG_RUNTIME_DIR to be set
XDG_RUNTIME_DIR: /tmp/dummy-xdr
run: |
# runc-shim::cgroup::test_add_cgroup needs root permission to set cgroup
mkdir -p /tmp/dummy-xdr
export PROTOC=$(which protoc)
sudo -E $(command -v cargo) test
sudo -E $(command -v cargo) test --all-features
@ -67,9 +64,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: ./scripts/install-protobuf.sh
- run: cargo build --all-features --timings
- uses: actions/upload-artifact@v3
with:

21
scripts/install-protobuf.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
# Helper script for Github Actions to install protobuf on different runners.
if [ "$RUNNER_OS" == 'Linux' ]; then
# Install on Linux
sudo apt-get update
sudo apt-get install -y protobuf-compiler
elif [ "$RUNNER_OS" == 'macOS' ]; then
# Install on macOS
brew install protobuf
elif [ "$RUNNER_OS" == 'Windows' ]; then
# Install on Windows
choco install protoc
else
echo "Unsupported OS: $RUNNER_OS"
exit 1
fi
# Check the installed Protobuf version
protoc --version