Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up GitHub Actions #1

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 🧪

on:
push:
branches:
- "**"
pull_request:
branches:
- main
merge_group:

jobs:
run-tests-rust:
name: Run Rust tests
runs-on: ubuntu-latest
strategy:
matrix:
rust-version: ["stable"]
feature-flags: ['--features "strict"']
steps:
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
components: rustfmt
- uses: actions/checkout@v3

- name: Run unit tests
run: cargo test ${{ matrix.feature-flags }}
- name: Run unit tests in release mode
run: cargo test --release ${{ matrix.feature-flags }}

check-dependencies:
name: Check dependencies
runs-on: ubuntu-latest
strategy:
matrix:
rust-version: ["stable"]
steps:
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
components: rustfmt
- name: Install cargo-upgrades
run: cargo install cargo-upgrades
- uses: actions/checkout@v3
- name: Check that dependencies are up to date
run:
cargo upgrades
34 changes: 34 additions & 0 deletions .github/workflows/run-weekly-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 🧪📅

on:
schedule:
- cron: "0 7 * * 1"

jobs:
run-tests-rust:
name: Run Rust tests
runs-on: ubuntu-latest
strategy:
matrix:
rust-version: ["stable", "beta", "nightly"]
steps:
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
components: rustfmt
- uses: actions/checkout@v3

- name: Build rust library
run: cargo build --features "strict"
- name: Build rust library in release mode
run: cargo build --release --features "strict"


- name: Run unit tests
run: cargo test --features "strict"
- name: Run unit tests in release mode
run: cargo test --release --features "strict"

- name: Build docs
run: cargo doc --features "strict" --no-deps
32 changes: 32 additions & 0 deletions .github/workflows/style-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: ✨

on:
push:
branches:
- "**"
pull_request:
branches:
- main
merge_group:

jobs:
style-checks:
name: Rust style checks
runs-on: ubuntu-latest
strategy:
matrix:
feature-flags: ['--features "strict"', '']
steps:
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rustfmt,clippy
- uses: actions/checkout@v3

- name: Style checks
run: |
cargo fmt -- --check
cargo clippy ${{ matrix.feature-flags }} -- -D warnings
cargo clippy --tests ${{ matrix.feature-flags }} -- -D warnings
cargo clippy --examples ${{ matrix.feature-flags }} -- -D warnings
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

workspace = { members = ["c-api-tools-macros", "example_project"] }

[features]
Expand All @@ -25,13 +24,9 @@ name = "c_api_tools"
crate-type = ["lib", "cdylib"]

[dependencies]
itertools = "0.13.*"
num = "0.4"
c-api-tools-macros = { path = "./c-api-tools-macros" }

[dev-dependencies]
paste = "1.*"

[build-dependencies]
cbindgen = "0.27.0"

Expand Down
7 changes: 7 additions & 0 deletions c-api-tools-macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! C API tools macros
#![cfg_attr(feature = "strict", deny(warnings), deny(unused_crate_dependencies))]
#![warn(missing_docs)]

mod attribute_c_wrappers;
mod attribute_concretise_types;
mod eval_concrete_type;
Expand All @@ -7,16 +11,19 @@ use attribute_concretise_types::concretise_type_impl;
use eval_concrete_type::eval_with_concrete_type_impl;
use proc_macro::TokenStream;

/// Evaluate iwth concrete type
#[proc_macro]
pub fn eval_with_concrete_type(item: TokenStream) -> TokenStream {
eval_with_concrete_type_impl(item)
}

/// C functions
#[proc_macro_attribute]
pub fn cfuncs(args: TokenStream, item: TokenStream) -> TokenStream {
c_wrapper_impl(args, item)
}

/// Concretise types
#[proc_macro_attribute]
pub fn concretise_types(args: TokenStream, item: TokenStream) -> TokenStream {
concretise_type_impl(args, item)
Expand Down
4 changes: 4 additions & 0 deletions example_project/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! Example project
#![cfg_attr(feature = "strict", deny(warnings), deny(unused_crate_dependencies))]
#![warn(missing_docs)]

use std::fmt::Display;

pub use c_api_tools::cfuncs;
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! C API tools
#![cfg_attr(feature = "strict", deny(warnings), deny(unused_crate_dependencies))]
#![warn(missing_docs)]

mod types;

pub use c_api_tools_macros::cfuncs;
Expand Down
13 changes: 12 additions & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,31 @@
#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(u8)]
pub enum DType {
/// Float 32
F32,
/// Float 64
F64,
/// Complex 32
C32,
/// Complex 64
C64,
/// Unsigned int 8
U8,
/// Unsigned int 32
U32,
/// Unsigned int 64
U64,
/// Int 8
I8,
/// Int 32
I32,
/// Int 64
I64,
}

/// Return runtime numeric type information.
/// Runtime numeric type information.
pub trait DTypeIdentifier {
/// Return runtime numeric type information.
fn dtype() -> DType;
}

Expand Down
Loading