This GitHub Action package is designed to install and build gRPC C++ dependencies for your project. It compiles, installs, and caches the gRPC environment for you, making it easy to use gRPC in your GitHub workflows.
In addition googletest binaries can be included with the include-google-test
flag.
Check this gRPC C++ Template repository.
Example CI Job
# This workflow will do a clean installation of gRPC dependencies, cache/restore them, build the source code and build/test you project.
name: Build & Test gRPC C++ example
on:
pull_request:
branches:
- "*"
push:
branches:
- "master"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: hindicator/grpc-setup@v1
with:
grpc-version: 1.60.0
- name: Build gRPC C++ example
run: |
cd example
mkdir -p build
cd build
cmake -DCMAKE_PREFIX_PATH="$GRPC_ROOT" ..
make
This action has the following inputs:
grpc-version
: The version of gRPC to setup. Default is1.60.0
.grpc-installation-path
: The installation path of gRPC. Default isgrpc
.token
: Used to pull gRPC distributions from hindicator/grpc-versions. Since there's a default, this is typically not supplied by the user. Default isgithub.token
.
To use this action in your workflow, you can add a step in your workflow file that uses this action:
steps:
- name: Setup gRPC
uses: hindicator/grpc-setup@v1
with:
grpc-version: '1.60.0'
grpc-installation-path: 'grpc'
This will install and build gRPC version 1.60.0
at the path grpc
.
This action works by:
- Restoring the gRPC installation from cache if it exists.
- If the installation is not cached, it sets up the specified gRPC version.
- It then builds gRPC at the specified installation path.
- Finally, it caches the gRPC installation for future runs.
The action uses the cacheGrpcInstallation
and restoreGrpcInstallation
functions from src/utils.ts
to handle caching. The installGrpcVersion
and makeGrpc
functions are used to install and build gRPC.
Unit tests for the action's main functionality are located in __tests__/main.test.ts
. These tests should be run as if the action was called from a workflow. Specifically, the inputs listed in action.yml
should be set as environment variables following the pattern INPUT_<INPUT_NAME>
.
To build this TypeScript project, run the build
script in the package.json
file:
yarn run build
Contributions are welcome! Please submit a pull request or create an issue to contribute to this project.