Skip to content

WIP: upgrade async-std to 1.6 beta #136

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

Closed
wants to merge 20 commits into from
Closed
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
4 changes: 3 additions & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Benchmark
on:
pull_request:
push:
branches:
- master
Expand All @@ -23,7 +24,8 @@ jobs:
github-token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
alert-threshold: '150%'
comment-on-alert: true
comment-always: true
fail-on-alert: true
alert-comment-cc-users: '@GopherJ'
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI

on:
pull_request:
push:
branches:
- master

jobs:
build:
name: Auto Build CI
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@master

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
override: true

- name: Install Dependencies
run: sudo apt-get install libssl-dev

- name: Cargo Clean
uses: actions-rs/cargo@v1
with:
command: clean

- name: Cargo Build
uses: actions-rs/cargo@v1
with:
command: build

# Todo: https://github.com/rust-lang/cargo/issues/2980
- name: Cargo Test For All Features Using async-std
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features runtime-async-std,cached,glob,ip,watcher,logging

- name: Cargo Test For All Features Using tokio
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features runtime-tokio,cached,glob,ip,watcher,logging

- name: Cargo Check Wasm
uses: actions-rs/cargo@v1
with:
command: check
target: wasm32-unknown-unknown
override: true
args: --no-default-features --features runtime-async-std,cached,glob,ip,watcher,logging

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

- name: Cargo Fmt Check
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
33 changes: 33 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Coverage

on:
pull_request:
push:
branches:
- master

jobs:
cover:
name: Auto Codecov Coverage
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@master

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Run cargo-tarpaulin
uses: actions-rs/[email protected]
with:
args: --out Xml

- name: Upload to codecov.io
uses: codecov/codecov-action@v1
with:
token: ${{secrets.CODECOV_TOKEN}}
49 changes: 0 additions & 49 deletions .travis.yml

This file was deleted.

22 changes: 15 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,35 @@ keywords = ["auth", "authorization", "rbac", "acl", "abac"]
[dependencies]
regex = "1.3.1"
rhai = { version = "0.13.0", default-features = false, features = ["sync", "only_i32", "no_function", "no_float"] }
ip_network = "0.3.4"
ttl_cache = "0.5.1"
ip_network = { version = "0.3.4", optional = true }
ttl_cache = { version = "0.5.1", optional = true }
lazy_static = "1.4.0"
indexmap = "1.3.1"
async-std = { version = "1.5.0", optional = true }
async-std = { git = "https://github.com/async-rs/async-std", optional = true }
async-trait = "0.1.24"
log = { version = "0.4.8", optional = true }
tokio = { version = "0.2.11", optional = true, default-features = false }
globset = "0.4.5"
globset = { version = "0.4.5", optional = true }
thiserror = "1.0.14"

[features]
default = ["runtime-async-std"]

runtime-tokio = ["tokio/fs", "tokio/io-util", "tokio/stream", "tokio/rt-threaded", "tokio/blocking"]
runtime-tokio = ["tokio/fs", "tokio/io-util"]
runtime-async-std = ["async-std"]
logging = ["log"]
ip = ["ip_network"]
glob = ["globset"]
cached = ["ttl_cache"]
watcher = []

[profile.release.build-override]
opt-level = 0

[dev-dependencies]
async-std = { version = "1.5.0", features = [ "attributes" ] }
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3.10"
async-std = { git = "https://github.com/async-rs/async-std", features = [ "attributes" ] }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
tokio = { version = "0.2.11", features = [ "full" ] }
async-std = { git = "https://github.com/async-rs/async-std", features = [ "attributes" ] }
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
[![Crates.io](https://img.shields.io/crates/v/casbin.svg)](https://crates.io/crates/casbin)
[![crates.io](https://img.shields.io/crates/d/casbin)](https://crates.io/crates/casbin)
[![Docs](https://docs.rs/casbin/badge.svg)](https://docs.rs/casbin)
[![Build Status](https://travis-ci.org/casbin/casbin-rs.svg?branch=master)](https://travis-ci.org/casbin/casbin-rs)
[![codecov](https://codecov.io/gh/casbin/casbin-rs/branch/master/graph/badge.svg)](https://codecov.io/gh/casbin/casbin-rs)
[![CI](https://github.com/casbin/casbin-rs/workflows/CI/badge.svg)](https://github.com/casbin/casbin-rs/actions)
[![Codecov](https://codecov.io/gh/casbin/casbin-rs/branch/master/graph/badge.svg)](https://codecov.io/gh/casbin/casbin-rs)

**Casbin-RS** is a powerful and efficient open-source access control library for Rust projects. It provides support for enforcing authorization based on various [access control models](https://en.wikipedia.org/wiki/Computer_security_model).

Expand Down
11 changes: 11 additions & 0 deletions benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ fn b_benchmark_basic_model(b: &mut Bencher) {
});
}

#[cfg(feature = "cached")]
#[bench]
fn b_benmark_cached_basic_model(b: &mut Bencher) {
let mut e = await_future(CachedEnforcer::new(
Expand All @@ -89,6 +90,7 @@ fn b_benchmark_rbac_model(b: &mut Bencher) {
});
}

#[cfg(feature = "cached")]
#[bench]
fn b_benchmark_cached_rbac_model(b: &mut Bencher) {
let mut e = await_future(CachedEnforcer::new(
Expand Down Expand Up @@ -139,6 +141,7 @@ fn b_benchmark_rbac_model_small(b: &mut Bencher) {
b.iter(|| await_future(e.enforce(&["user501", "data9", "read"])).unwrap());
}

#[cfg(feature = "cached")]
#[bench]
fn b_benchmark_cached_rbac_model_small(b: &mut Bencher) {
let mut e = await_future(CachedEnforcer::new("examples/rbac_model.conf", ())).unwrap();
Expand Down Expand Up @@ -213,6 +216,7 @@ fn b_benchmark_rbac_model_medium(b: &mut Bencher) {
b.iter(|| await_future(e.enforce(&["user5001", "data15", "read"])).unwrap());
}

#[cfg(feature = "cached")]
#[bench]
fn b_benchmark_cached_rbac_model_medium(b: &mut Bencher) {
let mut e = await_future(CachedEnforcer::new("examples/rbac_model.conf", ())).unwrap();
Expand Down Expand Up @@ -287,6 +291,7 @@ fn b_benchmark_rbac_model_large(b: &mut Bencher) {
b.iter(|| await_future(e.enforce(&["user50001", "data1500", "read"])).unwrap());
}

#[cfg(feature = "cached")]
#[bench]
fn b_benchmark_cached_rbac_model_large(b: &mut Bencher) {
let mut e = await_future(CachedEnforcer::new("examples/rbac_model.conf", ())).unwrap();
Expand Down Expand Up @@ -335,6 +340,7 @@ fn b_benchmark_rbac_with_resource_roles(b: &mut Bencher) {
b.iter(|| await_future(e.enforce(&["alice", "data1", "read"])).unwrap());
}

#[cfg(feature = "cached")]
#[bench]
fn b_benchmark_cached_rbac_with_resource_roles(b: &mut Bencher) {
let mut e = await_future(CachedEnforcer::new(
Expand All @@ -357,6 +363,7 @@ fn b_benchmark_rbac_model_with_domains(b: &mut Bencher) {
b.iter(|| await_future(e.enforce(&["alice", "domain1", "data1", "read"])).unwrap());
}

#[cfg(feature = "cached")]
#[bench]
fn b_benchmark_cached_rbac_model_with_domains(b: &mut Bencher) {
let mut e = await_future(CachedEnforcer::new(
Expand All @@ -375,6 +382,7 @@ fn b_benchmark_abac_model(b: &mut Bencher) {
b.iter(|| await_future(e.enforce(&["alice", r#"{"Owner": "alice"}"#, "read"])).unwrap());
}

#[cfg(feature = "cached")]
#[bench]
fn b_benchmark_cached_abac_model(b: &mut Bencher) {
let mut e = await_future(CachedEnforcer::new("examples/abac_model.conf", ())).unwrap();
Expand All @@ -393,6 +401,7 @@ fn b_benchmark_key_match(b: &mut Bencher) {
b.iter(|| await_future(e.enforce(&["alice", "/alice_data/resource1", "GET"])).unwrap());
}

#[cfg(feature = "cached")]
#[bench]
fn b_benchmark_cached_key_match(b: &mut Bencher) {
let mut e = await_future(CachedEnforcer::new(
Expand All @@ -415,6 +424,7 @@ fn b_benchmark_rbac_with_deny(b: &mut Bencher) {
b.iter(|| await_future(e.enforce(&["alice", "data1", "read"])).unwrap());
}

#[cfg(feature = "cached")]
#[bench]
fn b_benchmark_cached_rbac_with_deny(b: &mut Bencher) {
let mut e = await_future(CachedEnforcer::new(
Expand All @@ -437,6 +447,7 @@ fn b_benchmark_priority_model(b: &mut Bencher) {
b.iter(|| await_future(e.enforce(&["alice", "data1", "read"])).unwrap());
}

#[cfg(feature = "cached")]
#[bench]
fn b_benchmark_cached_priority_model(b: &mut Bencher) {
let mut e = await_future(CachedEnforcer::new(
Expand Down
2 changes: 2 additions & 0 deletions src/adapter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use async_trait::async_trait;

#[cfg(not(target_arch = "wasm32"))]
pub mod file_adapter;
pub mod memory_adapter;
pub mod null_adapter;

#[cfg(not(target_arch = "wasm32"))]
pub use file_adapter::FileAdapter;
pub use memory_adapter::MemoryAdapter;
pub use null_adapter::NullAdapter;
Expand Down
Loading