-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 add ci lint and extend action
- Loading branch information
1 parent
78244b6
commit 1384f94
Showing
7 changed files
with
219 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: CICD | ||
|
||
|
||
env: | ||
RUST_SRV: "1.78.0" | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- "**" | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
style: | ||
name: Style | ||
runs-on: ubuntu-latest | ||
# runs-on: ${{ matrix.job.os }} | ||
# strategy: | ||
# fail-fast: false | ||
# matrix: | ||
# job: [ { os: ubuntu-latest }, { os: macos-latest }, { os: windows-latest } ] | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Install `rust` toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ env.RUST_SRV }} | ||
override: true | ||
profile: minimal # minimal component installation (ie, no documentation) | ||
components: rustfmt, clippy | ||
- name: "`fmt` testing" | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --all -- --check | ||
- name: "`clippy` testing" | ||
if: success() || failure() # run regardless of prior step ("`fmt` testing") success/failure | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: --tests -- -D warnings | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fmtCheck: | ||
cargo fmt --all -- --check | ||
|
||
clippyCheck: | ||
cargo --tests -- -D warnings | ||
|
||
precheck: fmtCheck clippyCheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
use futures::task::ArcWake; | ||
use roaring::RoaringBitmap; | ||
use std::cell::RefCell; | ||
use std::fmt::{Display, Formatter}; | ||
use std::io; | ||
use std::io::IoSlice; | ||
use std::ops::DerefMut; | ||
use std::pin::Pin; | ||
use std::rc::Rc; | ||
use std::sync::{Arc, Mutex}; | ||
use std::task::{Context, Poll}; | ||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; | ||
use tokio::net::TcpStream; | ||
use tracing::debug; | ||
|
||
pub struct WarpConn(pub Rc<RefCell<TcpStream>>); | ||
|
||
unsafe impl Send for WarpConn {} | ||
|
||
macro_rules! pinc { | ||
($self:ident) => { | ||
Pin::new($self.get_mut().0.borrow_mut().deref_mut()) | ||
}; | ||
} | ||
impl AsyncRead for WarpConn { | ||
fn poll_read( | ||
self: Pin<&mut Self>, | ||
cx: &mut Context<'_>, | ||
buf: &mut ReadBuf<'_>, | ||
) -> Poll<io::Result<()>> { | ||
pinc!(self).poll_read(cx, buf) | ||
} | ||
} | ||
|
||
impl AsyncWrite for WarpConn { | ||
fn poll_write( | ||
self: Pin<&mut Self>, | ||
cx: &mut Context<'_>, | ||
buf: &[u8], | ||
) -> Poll<io::Result<usize>> { | ||
pinc!(self).poll_write(cx, buf) | ||
} | ||
|
||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> { | ||
pinc!(self).poll_flush(cx) | ||
} | ||
|
||
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> { | ||
pinc!(self).poll_shutdown(cx) | ||
} | ||
|
||
fn poll_write_vectored( | ||
self: Pin<&mut Self>, | ||
cx: &mut Context<'_>, | ||
bufs: &[IoSlice<'_>], | ||
) -> Poll<io::Result<usize>> { | ||
pinc!(self).poll_write_vectored(cx, bufs) | ||
} | ||
|
||
fn is_write_vectored(&self) -> bool { | ||
self.0.borrow().is_write_vectored() | ||
} | ||
} | ||
|
||
pub struct Wk { | ||
bitmap: Arc<Mutex<RoaringBitmap>>, | ||
index: u32, | ||
} | ||
|
||
impl Wk { | ||
pub fn new(bitmap: Arc<Mutex<RoaringBitmap>>, index: u32) -> Self { | ||
Self { bitmap, index } | ||
} | ||
} | ||
|
||
impl ArcWake for Wk { | ||
fn wake_by_ref(arc_self: &Arc<Self>) { | ||
debug!("been call wake {}", arc_self.index); | ||
arc_self.bitmap.lock().unwrap().insert(arc_self.index); | ||
} | ||
} | ||
|
||
pub struct Empty; | ||
|
||
impl Display for Empty { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "EMPTY") | ||
} | ||
} |
Oops, something went wrong.