Browse Source

multi: remove proto install script

master
Oliver Gugger 3 years ago
parent
commit
9c6e208797
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
  1. 34
      .github/workflows/main.yml
  2. 7
      .travis.yml
  3. 60
      lnrpc/README.md
  4. 75
      scripts/install_travis_proto.sh

34
.github/workflows/main.yml

@ -16,7 +16,6 @@ env:
# go needs absolute directories, using the $HOME variable doesn't work here.
GOCACHE: /home/runner/work/go/pkg/build
GOPATH: /home/runner/work/go
DOWNLOAD_CACHE: /home/runner/work/download_cache
BITCOIN_VERSION: 0.20.1
# If you change this value, please change it in the following files as well:
@ -54,18 +53,6 @@ jobs:
with:
go-version: '~${{ env.GO_VERSION }}'
- name: download cache
uses: actions/cache@v1
with:
path: /home/runner/work/download_cache
key: lnd-${{ runner.os }}-download-${{ hashFiles('**/install_travis_proto.sh') }}
restore-keys: |
lnd-${{ runner.os }}-download-${{ hashFiles('**/install_travis_proto.sh') }}
lnd-${{ runner.os }}-download-
- name: install protoc and protobuf libraries
run: ./scripts/install_travis_proto.sh
- name: run check
run: make rpc-check
@ -195,18 +182,6 @@ jobs:
with:
go-version: '~${{ env.GO_VERSION }}'
- name: download cache
uses: actions/cache@v1
with:
path: /home/runner/work/download_cache
key: lnd-${{ runner.os }}-download-${{ hashFiles('**/install_travis_proto.sh') }}
restore-keys: |
lnd-${{ runner.os }}-download-${{ hashFiles('**/install_travis_proto.sh') }}
lnd-${{ runner.os }}-download-
- name: install protoc and protobuf libraries
run: ./scripts/install_travis_proto.sh
- name: build mobile RPC bindings
run: make mobile-rpc
@ -239,15 +214,6 @@ jobs:
with:
go-version: '~${{ env.GO_VERSION }}'
- name: download cache
uses: actions/cache@v1
with:
path: /home/runner/work/download_cache
key: lnd-${{ runner.os }}-download-${{ hashFiles('**/install_travis_proto.sh') }}
restore-keys: |
lnd-${{ runner.os }}-download-${{ hashFiles('**/install_travis_proto.sh') }}
lnd-${{ runner.os }}-download-
- name: check all command line flags exist in sample-lnd.conf file
run: make sample-conf-check

7
.travis.yml

@ -1,7 +1,6 @@
language: go
cache:
directories:
- $DOWNLOAD_CACHE
- $GOCACHE
- $GOPATH/pkg/mod
- $GOPATH/src/github.com/btcsuite
@ -27,7 +26,6 @@ go:
env:
global:
- GOCACHE=$HOME/.go-build
- DOWNLOAD_CACHE=$HOME/download_cache
- BITCOIN_VERSION=0.20.1
sudo: required
@ -36,11 +34,6 @@ jobs:
include:
- stage: Sanity Check
name: Lint and compile
before_script:
# Install the RPC tools as a before step so Travis collapses the output
# after it's done.
- ./scripts/install_travis_proto.sh
script:
# Step 1: Make sure no diff is produced when compiling with the correct
# version.

60
lnrpc/README.md

@ -153,58 +153,21 @@ description):
## Generate protobuf definitions
### Linux
To compile the `lnrpc/**/*.proto` files and generate the protobuf definitions,
you need to have [Docker](https://docs.docker.com/get-docker/) and `make`
installed.
For linux there is an easy install script that is also used for the Travis CI
build. Just run the following command (requires `sudo` permissions and the tools
`make`, `go`, `wget` and `unzip` to be installed) from the repository's root
folder:
```shell
⛰ ./scripts/install_travis_proto.sh
```
### MacOS / Unix like systems
1. Download [v.3.4.0](https://github.com/google/protobuf/releases/tag/v3.4.0) of
`protoc` for your operating system and add it to your `PATH`.
For example, if using macOS:
```shell
⛰ curl -LO https://github.com/google/protobuf/releases/download/v3.4.0/protoc-3.4.0-osx-x86_64.zip
⛰ unzip protoc-3.4.0-osx-x86_64.zip -d protoc
⛰ export PATH=$PWD/protoc/bin:$PATH
```
2. Install `golang/protobuf` at version `v1.3.2`.
```shell
⛰ git clone https://github.com/golang/protobuf $GOPATH/src/github.com/golang/protobuf
⛰ cd $GOPATH/src/github.com/golang/protobuf
⛰ git reset --hard v1.3.2
⛰ make
```
3. Install 'genproto' at commit `20e1ac93f88cf06d2b1defb90b9e9e126c7dfff6`.
```shell
⛰ go get google.golang.org/genproto
⛰ cd $GOPATH/src/google.golang.org/genproto
⛰ git reset --hard 20e1ac93f88cf06d2b1defb90b9e9e126c7dfff6
```
4. Install `grpc-ecosystem/grpc-gateway` at version `v1.14.3`.
```shell
⛰ git clone https://github.com/grpc-ecosystem/grpc-gateway $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway
⛰ cd $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway
⛰ git reset --hard v1.14.3
⛰ go install ./protoc-gen-grpc-gateway ./protoc-gen-swagger
```
5. Run [`gen_protos.sh`](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/gen_protos.sh)
or `make rpc` to generate new protobuf definitions.
Simply run `make rpc` to start the compilation process.
## Format .proto files
We use `clang-format` to make sure the `.proto` files are formatted correctly.
You can install the formatter on Ubuntu by running `apt install clang-format` or on Mac by running `brew install clang-format`.
When running the `make rpc` command, the `.proto` files are also formatted. To
format the files without also compiling them, you can install the `clang-format`
formatter on Ubuntu by running `apt install clang-format` or on Mac by running
`brew install clang-format`.
The `make format` command should then produce the correct result.
Consult [this page](http://releases.llvm.org/download.html) to find binaries
for other operating systems or distributions.
@ -213,7 +176,8 @@ for other operating systems or distributions.
The following commands are available with `make`:
* `rpc`: Compile `.proto` files (calls `lnrpc/gen_protos.sh`).
* `rpc`: Compile and format all `.proto` files using Docker (calls
`lnrpc/gen_protos_docker.sh`).
* `rpc-format`: Formats all `.proto` files according to our formatting rules.
Requires `clang-format`, see previous chapter.
* `rpc-check`: Runs both previous commands and makes sure the git work tree is

75
scripts/install_travis_proto.sh

@ -1,75 +0,0 @@
#!/usr/bin/env bash
# Abort on error (-e) and print commands (-v).
set -ev
# See README.md in lnrpc why we need these specific versions/commits.
PROTOC_VERSION=3.4.0
PROTOBUF_VERSION="v1.3.2"
GENPROTO_VERSION="20e1ac93f88cf06d2b1defb90b9e9e126c7dfff6"
GRPC_GATEWAY_VERSION="v1.14.3"
# This script is specific to Travis CI so we only need to support linux x64.
PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip"
PROTOC_DL_CACHE_DIR="${DOWNLOAD_CACHE:-/tmp/download_cache}/protoc"
# install_protoc copies the cached protoc binary to the $PATH or downloads it
# if no cached version is found.
install_protoc() {
if [ -f "${PROTOC_DL_CACHE_DIR}/bin/protoc" ]; then
echo "Using cached version of protoc"
else
wget -O /tmp/protoc.zip $PROTOC_URL
mkdir -p "${PROTOC_DL_CACHE_DIR}"
unzip -o /tmp/protoc.zip -d "${PROTOC_DL_CACHE_DIR}"
chmod -R a+rx "${PROTOC_DL_CACHE_DIR}/"
fi
sudo cp "${PROTOC_DL_CACHE_DIR}/bin/protoc" /usr/local/bin
sudo cp -r "${PROTOC_DL_CACHE_DIR}/include" /usr/local
}
# install_protobuf downloads and compiles the Golang protobuf library that
# encodes/decodes all protobuf messages from/to Go structs.
install_protobuf() {
local install_path="$GOPATH/src/github.com/golang/protobuf"
if [ ! -d "$install_path" ]; then
git clone https://github.com/golang/protobuf "$install_path"
fi
pushd "$install_path"
git reset --hard master && git checkout master && git pull
git reset --hard $PROTOBUF_VERSION
make
popd
}
# install_genproto downloads the Golang protobuf generator that converts the
# .proto files into Go interface stubs.
install_genproto() {
local install_path="$GOPATH/src/google.golang.org/genproto"
if [ ! -d "$install_path" ]; then
git clone https://github.com/google/go-genproto "$install_path"
fi
pushd "$install_path"
git reset --hard master && git checkout master && git pull
git reset --hard $GENPROTO_VERSION
popd
}
# install_grpc_gateway downloads and installs the gRPC gateway that converts
# .proto files into REST gateway code.
install_grpc_gateway() {
local install_path="$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway"
if [ ! -d "$install_path" ]; then
git clone https://github.com/grpc-ecosystem/grpc-gateway "$install_path"
fi
pushd "$install_path"
git reset --hard master && git checkout master && git pull
git reset --hard $GRPC_GATEWAY_VERSION
GO111MODULE=on go install ./protoc-gen-grpc-gateway ./protoc-gen-swagger
popd
}
install_protoc
install_protobuf
install_genproto
install_grpc_gateway
Loading…
Cancel
Save