From 5a8c1a689d3aa540d8baf66eb34d4c7a99892146 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 11 May 2021 22:00:52 +0900 Subject: [PATCH 1/3] Set up GitHub Actions CI --- .github/workflows/ci.yml | 67 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c46f4fe --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,67 @@ +name: CI + +on: + pull_request: + branches: + - master + push: + branches: + - master + +env: + RUSTFLAGS: -Dwarnings + RUST_BACKTRACE: 1 + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Rust + run: rustup update stable + - run: cargo test --all-features --workspace + + no-std: + strategy: + matrix: + target: + # TODO: Currently, valuable cannot build with targets that do not have atomic CAS. + # We should port https://github.com/rust-lang/futures-rs/pull/2400. + # - thumbv6m-none-eabi + - thumbv7m-none-eabi + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Rust + run: rustup update stable + - run: rustup target add ${{ matrix.target }} + # TODO: Currently, valuable cannot build without `alloc` feature + # because `Debug` impl of `dyn Enumerable` uses `format!` macro. + # - run: cargo build --target ${{ matrix.target }} --no-default-features + # working-directory: valuable + # - run: cargo build --target ${{ matrix.target }} --no-default-features --features derive + # working-directory: valuable + - run: cargo build --target ${{ matrix.target }} --no-default-features --features alloc + working-directory: valuable + - run: cargo build --target ${{ matrix.target }} --no-default-features --features alloc,derive + working-directory: valuable + + # TODO: Currently, valuable cannot build without `alloc` feature + # because `Debug` impl of `dyn Enumerable` uses `format!` macro. + # features: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # - name: Install Rust + # run: rustup update stable + # - name: Install cargo-hack + # run: cargo install cargo-hack + # - run: cargo hack build --workspace --feature-powerset --no-dev-deps + + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Rust + run: rustup update stable + - run: cargo fmt --all -- --check From 04a95eade4ad802310ec4bec9f0895519730dafc Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 11 May 2021 22:53:06 +0900 Subject: [PATCH 2/3] Fix build error of benchmark --- .github/workflows/ci.yml | 1 + valuable/benches/structable.rs | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c46f4fe..a280e82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,7 @@ jobs: - name: Install Rust run: rustup update stable - run: cargo test --all-features --workspace + - run: cargo build --all-features --all-targets --workspace no-std: strategy: diff --git a/valuable/benches/structable.rs b/valuable/benches/structable.rs index 127eece..2eb4be7 100644 --- a/valuable/benches/structable.rs +++ b/valuable/benches/structable.rs @@ -24,15 +24,16 @@ static FIELDS: &[NamedField<'static>] = &[ impl Structable for HelloWorld { fn definition(&self) -> StructDef<'_> { - StructDef { - name: "HelloWorld", - static_fields: FIELDS, - is_dynamic: false, - } + StructDef::new("HelloWorld", Fields::NamedStatic(FIELDS), false) + } +} + +impl Valuable for HelloWorld { + fn as_value(&self) -> Value<'_> { + Value::Structable(self) } fn visit(&self, v: &mut dyn Visit) { - let definition = self.definition(); v.visit_named_fields(&NamedValues::new( FIELDS, &[ @@ -52,7 +53,10 @@ fn criterion_benchmark(c: &mut Criterion) { let hello_world = black_box(HelloWorld::default()); let structable = &hello_world as &dyn Structable; - let f = &structable.definition().static_fields()[5]; + let f = match structable.definition().fields() { + Fields::NamedStatic(fields) => &fields[5], + _ => unreachable!(), + }; struct Sum(usize, &'static NamedField<'static>); From ab07691cfa02f2e297c9ff093285c1626ad115cc Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 11 May 2021 23:39:03 +0900 Subject: [PATCH 3/3] Add cargo doc to CI --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a280e82..a640f38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,3 +66,13 @@ jobs: - name: Install Rust run: rustup update stable - run: cargo fmt --all -- --check + + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Rust + run: rustup update nightly && rustup default nightly + - run: cargo doc --no-deps --all-features + env: + RUSTDOCFLAGS: -Dwarnings