Skip to content

Commit

Permalink
Updated workflow with caching
Browse files Browse the repository at this point in the history
Signed-off-by: Simone Orru <simone.orru@secomind.com>
  • Loading branch information
sorru94 committed Jan 17, 2025
1 parent 0970a26 commit 80eaf91
Showing 1 changed file with 42 additions and 15 deletions.
57 changes: 42 additions & 15 deletions .github/workflows/cpp-code-generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,54 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install protoc
run: |
curl -LO $PB_REL/download/v$PB_VER/protoc-$PB_VER-linux-x86_64.zip
unzip protoc-$PB_VER-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install gRPC
with:
path: astarte-message-hub-proto
- name: Install gRPC dependencies
run: |
export MY_INSTALL_DIR=$HOME/.local
sudo apt install -y build-essential autoconf libtool pkg-config
git clone --recurse-submodules --depth 1 --shallow-submodules -b v1.66.1 https://github.com/grpc/grpc
cd grpc
mkdir -p cmake/build
cd cmake/build
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR ../..
- name: Check out the gRPC repo
run: git clone --recurse-submodules -b v1.66.1 --depth 1 --shallow-submodules https://github.com/grpc/grpc
- name: Set MY_INSTALL_DIR variable
run: |
MY_INSTALL_DIR=$PWD/grpc-install
echo "MY_INSTALL_DIR=$MY_INSTALL_DIR" >> $GITHUB_ENV
mkdir -p $MY_INSTALL_DIR
echo "$MY_INSTALL_DIR" >> "$GITHUB_PATH"
- name: Restore cached gRPC build directory
id: cache-grpc-cpp-restore
uses: actions/cache/restore@v4
with:
path: |
./grpc/cmake
./grpc-install
key: grpc-cpp-v1.66.1
- name: Compile from source gRPC
if: steps.cache-grpc-cpp-restore.outputs.cache-hit != 'true'
run: |
mkdir ./grpc/cmake/build
pushd ./grpc/cmake/build
cmake -DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \
../..
make -j 4
make install
popd
- name: Cache the gRPC build directory
if: steps.cache-grpc-cpp-restore.outputs.cache-hit != 'true'
id: cache-grpc-cpp-save
uses: actions/cache/save@v4
with:
path: |
./grpc/cmake
./grpc-install
key: ${{ steps.cache-grpc-cpp-restore.outputs.cache-primary-key }}
- name: Remove old code
working-directory: ./cpp
working-directory: ./astarte-message-hub-proto/cpp
run: (! test -d ./astarteplatform) || rm -r ./astarteplatform
- name: Generate code
working-directory: ./cpp
working-directory: ./astarte-message-hub-proto/cpp
run: |
mkdir -p ./cmake/build
cd ./cmake/build
Expand All @@ -63,4 +90,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: cpp-dist
path: ./cpp/astarteplatform
path: ./astarte-message-hub-proto/cpp/astarteplatform

0 comments on commit 80eaf91

Please sign in to comment.