Skip to content

Commit 0715f27

Browse files
committed
Add Vss thin client protobuf generation & build/CI setup
1 parent 3494efa commit 0715f27

File tree

7 files changed

+79
-0
lines changed

7 files changed

+79
-0
lines changed

.github/workflows/build.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Continuous Integration Checks
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
matrix:
9+
toolchain: [ stable, beta ]
10+
include:
11+
- toolchain: stable
12+
check-fmt: true
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout source code
16+
uses: actions/checkout@v2
17+
- name: Install Protobuf compiler (protoc)
18+
uses: arduino/setup-protoc@v1
19+
- name: Install Rust ${{ matrix.toolchain }} toolchain
20+
uses: actions-rs/toolchain@v1
21+
with:
22+
toolchain: ${{ matrix.toolchain }}
23+
override: true
24+
profile: minimal
25+
- name: Build on Rust ${{ matrix.toolchain }}
26+
run: cargo build --verbose --color always
27+
- name: Check formatting
28+
if: matrix.check-fmt
29+
run: rustup component add rustfmt && cargo fmt --all -- --check
30+
- name: Test on Rust ${{ matrix.toolchain }}
31+
run: cargo test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
/vss-accessor/src/proto/

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[workspace]
2+
members = [
3+
"vss-accessor",
4+
]

rustfmt.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
hard_tabs = true # use tab characters for indentation, spaces for alignment
2+
use_field_init_shorthand = true
3+
max_width = 120
4+
use_small_heuristics = "Max"
5+
chain_width = 80
6+
fn_args_layout = "Compressed"

vss-accessor/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "vss-accessor"
3+
version = "0.1.0"
4+
edition = "2021"
5+
build = "build.rs"
6+
7+
[dependencies]
8+
9+
[dev-dependencies]
10+
11+
[build-dependencies]
12+
prost-build = { version = "0.11.3" }
13+
reqwest = { version = "0.11.13", features = ["blocking"] }

vss-accessor/build.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
extern crate prost_build;
2+
3+
use std::fs;
4+
use std::fs::File;
5+
use std::path::Path;
6+
7+
fn main() {
8+
download_file(
9+
"https://raw.githubusercontent.com/lightningdevkit/vss-server/main/app/src/main/proto/vss.proto",
10+
"src/proto/vss.proto",
11+
)
12+
.unwrap();
13+
14+
prost_build::compile_protos(&["src/proto/vss.proto"], &["src/"]).unwrap();
15+
}
16+
17+
fn download_file(url: &str, save_to: &str) -> Result<(), Box<dyn std::error::Error>> {
18+
let mut response = reqwest::blocking::get(url)?;
19+
fs::create_dir_all(Path::new(save_to).parent().unwrap())?;
20+
let mut out_file = File::create(save_to)?;
21+
response.copy_to(&mut out_file)?;
22+
Ok(())
23+
}

vss-accessor/src/lib.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)