Skip to content

Commit

Permalink
Merge pull request #199 from mxpv/protobuf
Browse files Browse the repository at this point in the history
Use shell script to install protobuf
  • Loading branch information
mxpv authored Sep 18, 2023
2 parents a664279 + ece06a0 commit 3ca32d8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions scripts/install-protobuf.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3ca32d8

Please sign in to comment.