Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Guardiani <[email protected]>
  • Loading branch information
slinkydeveloper committed Jul 7, 2021
1 parent 94c3f12 commit 6d07bcd
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 25 deletions.
48 changes: 30 additions & 18 deletions .github/workflows/rust_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,36 +53,20 @@ jobs:

# If glibc, compile and test all
- uses: actions-rs/cargo@v1
name: "Build"
name: "Build glibc"
if: matrix.target == 'x86_64-unknown-linux-gnu'
with:
command: build
toolchain: ${{ matrix.toolchain }}
args: --target ${{ matrix.target }} --all-features
- uses: actions-rs/cargo@v1
name: "Test"
name: "Test glibc"
if: matrix.target == 'x86_64-unknown-linux-gnu'
with:
command: test
toolchain: ${{ matrix.toolchain }}
args: --target ${{ matrix.target }} --all-features

# If glibc, compile and test only the core module with no_std
- uses: actions-rs/cargo@v1
name: "Build"
if: matrix.target == 'x86_64-unknown-linux-gnu'
with:
command: build
toolchain: ${{ matrix.toolchain }}
args: --target ${{ matrix.target }} --package cloudevents-sdk --workspace --no-default-features
- uses: actions-rs/cargo@v1
name: "Test"
if: matrix.target == 'x86_64-unknown-linux-gnu'
with:
command: test
toolchain: ${{ matrix.toolchain }}
args: --target ${{ matrix.target }} --package cloudevents-sdk --workspace --no-default-features

# If musl, compile and test all
- uses: actions-rs/cargo@v1
name: "Build"
Expand Down Expand Up @@ -145,3 +129,31 @@ jobs:
command: build
toolchain: ${{ matrix.toolchain }}
args: --target ${{ matrix.target }} --manifest-path ./example-projects/warp-example/Cargo.toml

check_no_std:
name: Check no_std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
# Caching stuff
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-no-std-deps-${{ hashFiles('**/Cargo.toml') }}
- uses: actions/cache@v2
with:
path: |
target/
key: ${{ runner.os }}-cargo-no-std-build-${{ hashFiles('**/Cargo.toml') }}
- name: Download cargo-nono
run: curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git hobofan/cargo-nono
- name: Run check
run: ./cargo-nono check
13 changes: 6 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ categories = ["web-programming", "encoding", "data-structures", "no_std"]
name = "cloudevents"

[features]
# Without default features, the package acts as no_std
default = ["std"]

std = ["snafu/std", "url"]

actix = ["actix-web", "async-trait", "lazy_static", "bytes", "futures"]
reqwest = ["reqwest-lib", "async-trait", "lazy_static", "bytes"]
rdkafka = ["rdkafka-lib", "lazy_static", "bytes", "futures"]
Expand All @@ -28,16 +33,10 @@ serde_json = "^1.0"
chrono = { version = "^0.4", features = ["serde"] }
delegate-attr = "^0.2"
base64 = "^0.12"
snafu = { version = "^0.6", default-features = false}
snafu = { version = "^0.6", default-features = false }
bitflags = "^1.2"
url = { version = "^2.1", features = ["serde"], optional = true }

[features]
# Without default features, the package acts as no_std
default = ["std"]

std = ["snafu/std", "url"]

# runtime optional deps
actix-web = { version = "^3", default-features = false, optional = true }
reqwest-lib = { version = "^0.11", default-features = false, features = ["rustls-tls"], optional = true, package = "reqwest" }
Expand Down
15 changes: 15 additions & 0 deletions example-projects/no-std-example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "no-std-example"
version = "0.1.0"
edition = "2018"

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

[dependencies]
cloudevents-sdk = { path = "../..", default-features = false }

[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"
25 changes: 25 additions & 0 deletions example-projects/no-std-example/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#![no_std]
#![no_main]

use core::panic::PanicInfo;

use cloudevents;
use cloudevents::EventBuilder;

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}

#[no_mangle]
pub extern "C" fn _start() -> ! {
loop {
#[allow(dead_code)]
let event = cloudevents::EventBuilderV10::new()
.id("my_id")
.source("my_source")
.subject("some_subject")
.build()
.unwrap();
}
}
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
//! [Responders]: https://actix.rs/docs/handlers/
#![deny(broken_intra_doc_links)]

#![cfg_attr(not(any(feature = "std", test)), no_std)]

#[cfg(feature = "alloc")]
Expand All @@ -62,7 +63,9 @@ extern crate std as alloc;
#[cfg(any(feature = "std", test))]
extern crate std as core;

#[cfg(feature = "std")]
pub mod binding;

pub mod event;
pub mod message;

Expand Down

0 comments on commit 6d07bcd

Please sign in to comment.