Skip to content

Commit 10abc45

Browse files
Merge pull request #354 from shelter2759/use-buf-lint
multi: Modify buf.yaml for Buf lint and Format with Buf CLI Comamnd("buf format -w")
2 parents 63db0eb + 7aac8f8 commit 10abc45

File tree

7 files changed

+296
-204
lines changed

7 files changed

+296
-204
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,22 @@ env:
1111
SLOW_MACHINE: 1
1212

1313
jobs:
14+
buf:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
# Run `git checkout`
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
# Run the `buf` CLI
22+
- name: Buf Action
23+
uses: bufbuild/buf-action@v1
24+
1425
unit-tests:
1526
runs-on: ubuntu-latest
1627

1728
steps:
18-
- name: Checkout code
29+
- name: Checkout code
1930
uses: actions/checkout@v3
2031

2132
- name: Set up Go

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ PeerSwap enables Lightning Network nodes to balance their channels by facilitati
3333
- [Core Lightning](#core-lightning)
3434
- [LND](#lnd)
3535
- [Development](#development)
36+
- [Development: Buf CLI Description](#development-buf-cli-description)
37+
- [Usage](#usage-1)
38+
- [Using Devcontainer](#using-devcontainer)
3639

3740
## Project Status
3841

@@ -67,8 +70,8 @@ To run Elements for L-BTC swaps, see the [Elements setup guide](./docs/setup_ele
6770

6871
To run LWK for L-BTC swaps, see the [LWK setup guide](./docs/setup_lwk.md).
6972

70-
> **Note**
71-
> Most of the benefits of PeerSwap come from using L-BTC. Swaps using L-BTC are more private, faster, and avoid the mainchain blockchain during high fee environments that can make swaps uneconomical.
73+
> **Note**
74+
> Most of the benefits of PeerSwap come from using L-BTC. Swaps using L-BTC are more private, faster, and avoid the mainchain blockchain during high fee environments that can make swaps uneconomical.
7275
7376
### Usage
7477

@@ -88,7 +91,7 @@ See the [Upgrade guide](./docs/upgrade.md) for instructions to safely upgrade yo
8891
* Lower Cost - PeerSwap is the lowest cost because there is no 3rd party coordinator or intermediary nodes to collect rent.
8992
* More Private - Swaps are entirely between two consenting nodes. Nobody else is able to record details like who swapped.
9093
* What is the difference between [splicing](https://github.com/lightning/bolts/pull/863) and PeerSwap?
91-
* Both PeerSwap and splicing (through Phoenix Wallet) are now usable on mainnet. Splicing is in general better, though PeerSwap can be attractive more for L-BTC swaps that don't touch the mainnet blockchain at all. Splicing and PeerSwap L-BTC swaps are both good for mainnet efficiency.
94+
* Both PeerSwap and splicing (through Phoenix Wallet) are now usable on mainnet. Splicing is in general better, though PeerSwap can be attractive more for L-BTC swaps that don't touch the mainnet blockchain at all. Splicing and PeerSwap L-BTC swaps are both good for mainnet efficiency.
9295
* What is the difference between [liquidity-ads](https://github.com/lightning/bolts/pull/878) and PeerSwap?
9396
* Liquidity Ads is a great way to lease new channels to be opened toward you for the purpose of gaining incoming capacity. New channels add new capacity in a desired direction but only once.
9497
* PeerSwap lets you repeatedly refill your existing channels at a cost lower than opening, closing, and maintaining additional channels.
@@ -111,6 +114,14 @@ For a LND Bitcoin signet / Liquid testnet setup guide see this [guide](./docs/si
111114

112115
PeerSwap uses the [nix](https://nixos.org/download.html) package manager for a simple development environment. In order to start hacking, install nix, [golang](https://golang.org/doc/install) and run `nix-shell`. This will fetch all dependencies (except golang).
113116

117+
#### Development: Buf CLI Description
118+
119+
In this project, we utilize Buf CLI to streamline the development environment for Protocol Buffers (protobuf).Buf is a powerful tool for managing the build, linting, formatting, and validation processes for protobuf files in a consistent and efficient manner.
120+
121+
##### Usage
122+
123+
See the [Usage guide](./docs/usage_buf.md) for instructions on how to use Buf.
124+
114125
#### Using Devcontainer
115126

116127
To use devcontainer for development, follow these steps:

buf.yaml

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,51 @@
22
version: v2
33
modules:
44
- path: peerswaprpc
5-
6-
# lint:
7-
# use:
8-
# - STANDARD
9-
# breaking:
10-
# use:
11-
# - FILE
5+
lint:
6+
use:
7+
- STANDARD
8+
except:
9+
# TODO suport excepted standard rules.
10+
# - COMMENT_ENUM
11+
# - COMMENT_ENUM_VALUE
12+
# - COMMENT_FIELD
13+
# - COMMENT_MESSAGE
14+
# - COMMENT_ONEOF
15+
# - COMMENT_RPC
16+
# - COMMENT_SERVICE
17+
# - DIRECTORY_SAME_PACKAGE
18+
# - ENUM_FIRST_VALUE_ZERO
19+
# - ENUM_NO_ALLOW_ALIAS
20+
# - ENUM_PASCAL_CASE
21+
- ENUM_VALUE_PREFIX
22+
# - ENUM_VALUE_UPPER_SNAKE_CASE
23+
- ENUM_ZERO_VALUE_SUFFIX
24+
# - FIELD_LOWER_SNAKE_CASE
25+
# - FIELD_NOT_REQUIRED
26+
# - FILE_LOWER_SNAKE_CASE
27+
# - IMPORT_NO_PUBLIC
28+
# - IMPORT_NO_WEAK
29+
# - IMPORT_USED
30+
# - MESSAGE_PASCAL_CASE
31+
# - ONEOF_LOWER_SNAKE_CASE
32+
# - PACKAGE_DEFINED
33+
- PACKAGE_DIRECTORY_MATCH
34+
# - PACKAGE_LOWER_SNAKE_CASE
35+
# - PACKAGE_NO_IMPORT_CYCLE
36+
# - PACKAGE_SAME_DIRECTORY
37+
- PACKAGE_VERSION_SUFFIX
38+
# - PROTOVALIDATE
39+
# - RPC_NO_CLIENT_STREAMING
40+
# - RPC_NO_SERVER_STREAMING
41+
# - RPC_PASCAL_CASE
42+
- RPC_REQUEST_STANDARD_NAME
43+
- RPC_RESPONSE_STANDARD_NAME
44+
- RPC_REQUEST_RESPONSE_UNIQUE
45+
# - SERVICE_PASCAL_CASE
46+
- SERVICE_SUFFIX
47+
# - STABLE_PACKAGE_NO_IMPORT_UNSTABLE
48+
# - SYNTAX_SPECIFIED
49+
# - PACKAGE_SAME_GO_PACKAGE
50+
breaking:
51+
use:
52+
- FILE

docs/usage_buf.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Usage Guide
2+
3+
In this project, we utilize Buf CLI to streamline the development environment for Protocol Buffers (protobuf).Buf is a powerful tool for managing the build, linting, formatting, and validation processes for protobuf files in a consistent and efficient manner.
4+
5+
- [Buf](https://buf.build/)
6+
- [Buf Github URL](https://github.com/bufbuild/buf)
7+
8+
## Why We Use Buf
9+
10+
The adoption of Buf provides several advantages:
11+
- Strict Lint Checks: Ensures a consistent code style across the team and helps prevent potential bugs.
12+
- Simplified Build Process: Reduces the complexity of configuring protoc commands with multiple options.
13+
- CI/CD Integration: Easily integrates automatic linting, formatting, and validation into the CI/CD pipeline.
14+
- Module Management: Simplifies dependency management with Buf modules.
15+
16+
## Installation Instructions
17+
18+
Buf CLI setup guide see this [Install the Buf CLI](https://buf.build/docs/cli/installation/):
19+
20+
## Notes on commands
21+
22+
```bash
23+
make buf-lint ## lint
24+
make buf-format ## format -w
25+
```

peerswaprpc/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ARG GRPC_GATEWAY_VERSION
1111
ENV PROTOC_GEN_GO_GRPC_VERSION="v1.1.0"
1212
ENV GOCACHE=/tmp/build/.cache
1313
ENV GOMODCACHE=/tmp/build/.modcache
14+
ENV GOBIN=/usr/local/bin
1415

1516
RUN echo ${PROTOC_GEN_VERSION}
1617

@@ -21,7 +22,7 @@ RUN cd /tmp \
2122
&& go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@${PROTOC_GEN_GO_GRPC_VERSION} \
2223
&& go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@${GRPC_GATEWAY_VERSION} \
2324
&& go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@${GRPC_GATEWAY_VERSION} \
24-
&& GOBIN=/usr/local/bin go install github.com/bufbuild/buf/cmd/[email protected] \
25+
&& go install github.com/bufbuild/buf/cmd/[email protected] \
2526
&& chmod -R 777 /tmp/build/
2627

2728
WORKDIR /build

peerswaprpc/Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ STUBS= \
88

99
all-rpc:
1010
buf generate
11+
.PHONY: all-rpc
12+
13+
buf-lint:
14+
buf lint
15+
.PHONY: all-rpc
16+
17+
buf-format:
18+
buf format -w
19+
.PHONY: all-rpc
1120

1221
clean-rpc:
1322
rm -f ${STUBS}
1423

15-
.PHONY: all-rpc-docker
1624
all-rpc-docker:
1725
./gen_protos_docker.sh
18-
26+
.PHONY: all-rpc-docker

0 commit comments

Comments
 (0)