Skip to content

Commit

Permalink
ci: update ci + add ensure no std
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLucqs committed Jul 27, 2023
1 parent df28685 commit 6591a3c
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 38 deletions.
52 changes: 19 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
on: [push]
on: [push, pull_request]

name: Test

Expand All @@ -7,46 +7,32 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy
- uses: actions/checkout@v3
- name: Install toolchain
run: rustup show

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

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
run: cargo clippy -- -D warnings

- name: Run cargo clippy alloc
run: >
cargo clippy --no-default-features --features alloc -- -D warnings
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
run: cargo test

- name: Run cargo test alloc
run: cargo test --no-default-features --features alloc

no-std-build:
name: Test no_std support
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy
target: thumbv6m-none-eabi

- name: Build stark-felt
uses: actions-rs/cargo@v1
with:
command: build
args: --package stark-felt --target thumbv6m-none-eabi --no-default-features
- uses: actions/checkout@v3
- name: Check wasm compatibility
run: |-
cd ensure_no_std
rustup show
cargo build -r
14 changes: 11 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
[workspace]
members = [
"crates/stark-felt",
"crates/stark-felt",
"crates/starknet-types-core",
"crates/starknet-types-rpc",
]

exclude = ["ensure_no_std"]

[workspace.package]
authors = ["Shahar Papini <@spapinistarkware>", "Abdelhamid Bakhta <@abdelhamidbakhta>", "Dan Brownstein <@dan-starkware>", "Federico Carrone <@unbalancedparentheses>", "Jonathan Lei <@xJonathanLEI>"]
authors = [
"Shahar Papini <@spapinistarkware>",
"Abdelhamid Bakhta <@abdelhamidbakhta>",
"Dan Brownstein <@dan-starkware>",
"Federico Carrone <@unbalancedparentheses>",
"Jonathan Lei <@xJonathanLEI>",
]
edition = "2021"
repository = "https://github.com/starknet-io/types-rs"
repository = "https://github.com/starknet-io/types-rs"
2 changes: 0 additions & 2 deletions crates/stark-felt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ pub type BitArrayStore = [u32; 8];
extern crate alloc;
#[cfg(not(feature = "std"))]
use alloc::string::ToString;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

use lambdaworks_math::{
field::{
Expand Down
2 changes: 2 additions & 0 deletions ensure_no_std/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "wasm32-unknown-unknown"
19 changes: 19 additions & 0 deletions ensure_no_std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "ensure_no_std"
version = "0.1.0"
edition = "2021"

[dependencies]
stark-felt = { path = "../crates/stark-felt", default-features = false, features = [
"alloc",
] }
starknet-types-core = { path = "../crates/starknet-types-core", default-features = false }
starknet-types-rpc = { path = "../crates/starknet-types-rpc", default-features = false }
wee_alloc = "0.4.5"


[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"
5 changes: 5 additions & 0 deletions ensure_no_std/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "nightly-2023-02-26"
components = ["rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]
profile = "minimal"
21 changes: 21 additions & 0 deletions ensure_no_std/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#![no_std]
#![no_main]

use core::panic::PanicInfo;

/// This function is called on panic.
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}

#[no_mangle]
pub extern "C" fn _start() -> ! {
loop {}
}

#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

#[allow(unused_imports)]
use stark_felt;
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "nightly-2023-02-26"
components = ["rustfmt", "clippy"]
profile = "minimal"

0 comments on commit 6591a3c

Please sign in to comment.