Skip to content

Commit

Permalink
Initial async commit
Browse files Browse the repository at this point in the history
  • Loading branch information
obraunsdorf committed Sep 25, 2023
0 parents commit 9aab0bf
Show file tree
Hide file tree
Showing 32 changed files with 4,818 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/rust/.devcontainer/base.Dockerfile

FROM mcr.microsoft.com/vscode/devcontainers/rust:0-1

# [Optional] Uncomment this section to install additional packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
protobuf-compiler
40 changes: 40 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/rust
{
"name": "Rust",
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"lldb.executable": "/usr/bin/lldb",
// VS Code don't watch files under ./target
"files.watcherExclude": {
"**/target/**": true
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"rust-lang.rust",
"bungcip.better-toml",
"vadimcn.vscode-lldb",
"mutantdino.resourcemonitor"
],

"mounts": [
"source=${localEnv:HOME}/.cargo/registry,target=/home/vscode/.cargo/registry,type=bind,consistency=cached"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
6 changes: 6 additions & 0 deletions .github/actions-rs/grcov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ignore-not-existing: true
llvm: true
output-type: lcov
output-path: ./lcov.info
ignore-dir:
ignore:
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
branches: [ master, jacobsen/fsm_allow_one_side_attested ]
pull_request:
branches: [ master ]
schedule:
- cron: '0 0 1 * *' # trigger monthly

env:
CARGO_TERM_COLOR: always

jobs:
Build_and_Test:
runs-on: self-hosted
strategy:
matrix:
# Run on latest ubuntu and macos using latest stable and nightly toolchain
os: [ubuntu-latest] #, macos-latest]
rust:
- stable
- nightly
- beta
- 1.63.0 # Minimum supported rust version
steps:
- uses: actions/checkout@v2

- name: Install Linux Dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update -yq && sudo apt-get install -y protobuf-compiler && protoc --version

- name: Install macOS Dependencies
if: matrix.os == 'macos-latest'
run: brew update && brew install protobuf && protoc --version

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: clippy, rustfmt

- uses: actions-rs/cargo@v1
with:
command: build
args: --all-features --verbose

- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --verbose

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

- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --all-features # -- -D warnings # TODO use "-D warnings" again when clippy issue is fixed: https://github.com/rust-lang/rust-clippy/issues/11179

49 changes: 49 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on: [push, pull_request]

name: Code Coverage

jobs:
grcov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- name: Install Linux Dependencies
run: sudo apt-get update -yq && sudo apt-get install -y protobuf-compiler && protoc --version

- name: Run Tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --no-fail-fast
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'

- name: Gather Coverage Data
id: coverage
uses: actions-rs/[email protected]

- name: Coveralls Upload
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
path-to-lcov: lcov.info

grcov_finalize:
runs-on: ubuntu-latest
needs: grcov
steps:
- name: Coveralls finalization
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
14 changes: 14 additions & 0 deletions .github/workflows/dependency-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Dependency audit
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/target
Cargo.lock
.idea/workspace.xml
idea/
18 changes: 18 additions & 0 deletions .idea/async-idscp2.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'async-idscp2'",
"cargo": {
"args": [
"test",
],
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[workspace]
members = [
"idscp2_core",
]

[profile.bench]
debug = true
2 changes: 2 additions & 0 deletions Notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Für FSM: evtl match guards verwenden für nicht-statische werte in Match Expressions: https://doc.rust-lang.org/rust-by-example/flow_control/match/guard.html
API design: an Rust Guidelines halten: https://rust-lang.github.io/api-guidelines/checklist.html
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

![Tests](https://github.com/obraunsdorf/async-idscp2/actions/workflows/ci.yml/badge.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/obraunsdorf/async-idscp2/badge.svg?branch=master)](https://coveralls.io/github/obraunsdorf/async-idscp2?branch=master)

# Async-Idscp2

The asynchronous implementation of the IDSCP2 protocol in Rust.

# Notes
Make sure the APIs follow the Rust Guidelines: https://rust-lang.github.io/api-guidelines/checklist.html
35 changes: 35 additions & 0 deletions idscp2_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "idscp2_core"
version = "0.1.0"
authors = [
"Oliver Braunsdorf <[email protected]>",
"Leon Beckmann <[email protected]>"
]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tinyvec = "1.6"
thiserror = "1.0"
log = "0.4"
protobuf = { version = "2.27.1", features = ["with-bytes"] }
bytes = "1.1"
futures = "0.3"
async-trait = "0.1.57"
tokio = {version = "1.17", features = ["full"] }
openssl = "0.10.41"

[build-dependencies]
protoc-rust = "2.27.1"

[dev-dependencies]
env_logger = "0.10.0"
tokio-test = "0.4.2"
rand = "^0.8.5"
criterion = "=0.4.0"
lazy_static = "1.4.0"

[[bench]]
name = "tokio_idscp_connection"
harness = false
Loading

0 comments on commit 9aab0bf

Please sign in to comment.