Skip to content

Commit

Permalink
Release of 0.1.0-alpha (#1)
Browse files Browse the repository at this point in the history
* Init project

* Make v1 module as public

* Add check, lint action

* Remove push

* Add recursive submodules to ci

* Small refactor

* Fix dependencies to compile for wasm

* Remove onw macro + add optional transport for client

* Fix transport issue

* Update protobuf

* Update protobufs fix

* Update README.md

* Update .gitmodules

* Update rust.yml

* Update rust.yml
  • Loading branch information
Velnbur authored Mar 31, 2023
1 parent 2fd50d7 commit c9a22f3
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 1 deletion.
84 changes: 84 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
on: [pull_request]

name: Rust

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Install Protoc
uses: arduino/setup-protoc@v1

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check

test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Install Protoc
uses: arduino/setup-protoc@v1

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test

lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- name: Install Protoc
uses: arduino/setup-protoc@v1

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "protobuf"]
path = protobuf
url = git@github.com:coin-shuffle/protobuf.git
branch = v0.1.0-alpha
24 changes: 24 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "coin-shuffle-protos"
version = "0.1.0"
edition = "2021"

[features]
default = ["server", "client", "transport"]
transport = ["tonic/transport", "tonic-build/transport"]
server = ["transport"]
client = []

[dependencies]
prost = "0.11.5"
tonic = { version = "0.8.3", default-features = false, features = [
"prost",
"codegen",
] }


[build-dependencies]
tonic-build = { version = "0.8.4", default-features = false, features = [
"prost",
] }
eyre = "0.6.8"
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# protos
A crate for all `coin-shuffle` proto definitions in rust code

A crate for all `coin-shuffle` proto definitions in rust code.

Uses `protobuf` repo as protos source
27 changes: 27 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use eyre::Context;

fn main() -> eyre::Result<()> {
tonic_build::configure()
.build_client(cfg!(feature = "client"))
.build_server(cfg!(feature = "server"))
.compile(
&[
proto_path("v1", "shuffle_service"),
proto_path("v1", "events"),
proto_path("v1", "types"),
],
&[COIN_SHUFFLE_PROTO],
)
.context("failed to build protos")?;

Ok(())
}

const COIN_SHUFFLE_PROTO: &str = "./protobuf/";

fn proto_path(version: &str, proto_file: &str) -> String {
format!(
"{}/coin_shuffle/{version}/{proto_file}.proto",
COIN_SHUFFLE_PROTO
)
}
1 change: 1 addition & 0 deletions protobuf
Submodule protobuf added at 225610
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod v1;
1 change: 1 addition & 0 deletions src/v1/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tonic::include_proto!("coin_shuffle.v1");

0 comments on commit c9a22f3

Please sign in to comment.