Skip to content

Commit

Permalink
Finish basic implementation for sync and async
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n authored Jan 24, 2024
2 parents 6b1852d + 0dcdaac commit b7d9ff1
Show file tree
Hide file tree
Showing 22 changed files with 2,206 additions and 311 deletions.
177 changes: 1 addition & 176 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,59 +63,7 @@ jobs:
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Apply clippy lints
run: cargo hack clippy --each-feature

# Run tests on some extra platforms
cross:
name: cross
strategy:
matrix:
target:
- aarch64-unknown-linux-gnu
- aarch64-linux-android
- aarch64-unknown-linux-musl
- i686-linux-android
- x86_64-linux-android
- i686-pc-windows-gnu
- x86_64-pc-windows-gnu
- i686-unknown-linux-gnu
- powerpc64-unknown-linux-gnu
# - mips64-unknown-linux-gnuabi64
- riscv64gc-unknown-linux-gnu
- wasm32-unknown-unknown
- wasm32-unknown-emscripten
- wasm32-wasi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache cargo build and registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cross-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cross-
- name: Install Rust
run: rustup update stable && rustup default stable
- name: cross build --target ${{ matrix.target }}
run: |
cargo install cross
cross build --target ${{ matrix.target }}
if: matrix.target != 'wasm32-unknown-unknown'
# # WASM support
# - name: cargo build --target ${{ matrix.target }}
# run: |
# rustup target add ${{ matrix.target }}
# cargo build --features js --target ${{ matrix.target }}
# if: matrix.target == 'wasm32-unknown-unknown'
# - name: cargo build --target ${{ matrix.target }}
# run: |
# rustup target add ${{ matrix.target }}
# cargo +nightly build --no-default-features --features alloc --target ${{ matrix.target }} -Z build-std=core,alloc
# if: matrix.target == 'mips64-unknown-linux-gnuabi64'
run: cargo hack clippy --each-feature

build:
name: build
Expand Down Expand Up @@ -184,125 +132,6 @@ jobs:
key: ${{ runner.os }}-coverage-dotcargo
- name: Run test
run: cargo hack test --feature-powerset

sanitizer:
name: sanitizer
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Cache cargo build and registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-sanitizer-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-sanitizer-
- name: Install Rust
run: rustup update $nightly && rustup default $nightly
- name: Install rust-src
run: rustup component add rust-src
- name: Install cargo-hack
run: cargo install cargo-hack
- name: ASAN / LSAN / TSAN
run: ci/sanitizer.sh

miri:
name: miri
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Cache cargo build and registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-miri-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-miri-
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Miri
run: ci/miri.sh
loom:
name: loom
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Cache cargo build and registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-loom-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-loom-
- name: Install Rust
run: rustup update $nightly && rustup default $nightly
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Loom tests
run: RUSTFLAGS="--cfg loom -Dwarnings" cargo hack test --test loom

# valgrind
valgrind:
name: valgrind
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache cargo build and registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ubuntu-latest-valgrind-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
ubuntu-latest-valgrind-
- name: Install Rust ${{ env.stable }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.stable }}
override: true
- name: Install Valgrind
run: |
sudo apt-get update -y
sudo apt-get install -y valgrind
# Compile tests
# - name: cargo build foo
# run: cargo build --bin foo
# working-directory: integration

# Run with valgrind
# - name: Run valgrind foo
# run: valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./target/debug/foo
# working-directory: integration

docs:
name: docs
Expand Down Expand Up @@ -336,11 +165,7 @@ jobs:
- rustfmt
- clippy
- build
- cross
- test
- sanitizer
- miri
- loom
- docs
steps:
- uses: actions/checkout@v3
Expand Down
45 changes: 21 additions & 24 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
[package]
name = "template-rs"
version = "0.1.6"
name = "peekable"
version = "0.0.0"
edition = "2021"
repository = "https://github.com/al8n/template-rs"
homepage = "https://github.com/al8n/template-rs"
documentation = "https://docs.rs/template-rs"
description = "A template for creating Rust open-source repo on GitHub"
repository = "https://github.com/al8n/peekable"
homepage = "https://github.com/al8n/peekable"
documentation = "https://docs.rs/peekable"
description = "Peakable reader and async reader"
license = "MIT/Apache-2.0"
rust-version = "1.73"

[[bench]]
path = "benches/foo.rs"
name = "foo"
harness = false
rust-version = "1.56"

[features]
default = []
future = ["futures-util", "pin-project-lite"]
tokio = ["dep:tokio", "pin-project-lite", "bytes"]

[dependencies]
smallvec = { version = "1", optional = true }

[dev-dependencies]
criterion = "0.5"
tempfile = "3"
# futures-io = { version = "0.3", optional = true }
futures-util = { version = "=0.3.29", optional = true, features = ["io"] }
pin-project-lite = { version = "0.2", optional = true }

tokio = { version = "1", default-features = false, optional = true, features = ["io-util"] }
bytes = { version = "1", optional = true }

[profile.bench]
opt-level = 3
debug = false
codegen-units = 1
lto = 'thin'
incremental = false
debug-assertions = false
overflow-checks = false
rpath = false

[dev-dependencies]
futures = { version = "0.3", features = ["executor"] }
tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.7", features = ["compat"] }

[package.metadata.docs.rs]
all-features = true
Expand Down
50 changes: 0 additions & 50 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,50 +0,0 @@
<div align="center">
<h1>template-rs</h1>
</div>
<div align="center">

开源Rust代码库GitHub模版

[<img alt="github" src="https://img.shields.io/badge/github-Template--rs-8da0cb?style=for-the-badge&logo=Github" height="22">][Github-url]
[<img alt="Build" src="https://img.shields.io/github/workflow/status/al8n/template-rs/template/main?logo=Github-Actions&style=for-the-badge" height="22">][CI-url]
[<img alt="codecov" src="https://img.shields.io/codecov/c/gh/al8n/template-rs?style=for-the-badge&token=6R3QFWRWHL&logo=codecov" height="22">][codecov-url]

[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-template--rs-66c2a5?style=for-the-badge&labelColor=555555&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20">][doc-url]
[<img alt="crates.io" src="https://img.shields.io/crates/v/template-rs?style=for-the-badge&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pg0KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgdmlld0JveD0iMCAwIDUxMiA1MTIiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPGc+DQoJPGc+DQoJCTxwYXRoIGQ9Ik0yNTYsMEwzMS41MjgsMTEyLjIzNnYyODcuNTI4TDI1Niw1MTJsMjI0LjQ3Mi0xMTIuMjM2VjExMi4yMzZMMjU2LDB6IE0yMzQuMjc3LDQ1Mi41NjRMNzQuOTc0LDM3Mi45MTNWMTYwLjgxDQoJCQlsMTU5LjMwMyw3OS42NTFWNDUyLjU2NHogTTEwMS44MjYsMTI1LjY2MkwyNTYsNDguNTc2bDE1NC4xNzQsNzcuMDg3TDI1NiwyMDIuNzQ5TDEwMS44MjYsMTI1LjY2MnogTTQzNy4wMjYsMzcyLjkxMw0KCQkJbC0xNTkuMzAzLDc5LjY1MVYyNDAuNDYxbDE1OS4zMDMtNzkuNjUxVjM3Mi45MTN6IiBmaWxsPSIjRkZGIi8+DQoJPC9nPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPC9zdmc+DQo=" height="22">][crates-url]
[<img alt="rustc" src="https://img.shields.io/badge/MSRV-1.56.0-fc8d62.svg?style=for-the-badge&logo=Rust" height="22">][rustc-url]

[<img alt="license-apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge&logo=Apache" height="22">][license-apache-url]
[<img alt="license-mit" src="https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge&fontColor=white&logoColor=f5c076&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMzZweCIgdmlld0JveD0iMCAwIDI0IDI0IiB3aWR0aD0iMzZweCIgZmlsbD0iI2Y1YzA3NiI+PHBhdGggZD0iTTAgMGgyNHYyNEgwVjB6IiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTEwLjA4IDEwLjg2Yy4wNS0uMzMuMTYtLjYyLjMtLjg3cy4zNC0uNDYuNTktLjYyYy4yNC0uMTUuNTQtLjIyLjkxLS4yMy4yMy4wMS40NC4wNS42My4xMy4yLjA5LjM4LjIxLjUyLjM2cy4yNS4zMy4zNC41My4xMy40Mi4xNC42NGgxLjc5Yy0uMDItLjQ3LS4xMS0uOS0uMjgtMS4yOXMtLjQtLjczLS43LTEuMDEtLjY2LS41LTEuMDgtLjY2LS44OC0uMjMtMS4zOS0uMjNjLS42NSAwLTEuMjIuMTEtMS43LjM0cy0uODguNTMtMS4yLjkyLS41Ni44NC0uNzEgMS4zNlM4IDExLjI5IDggMTEuODd2LjI3YzAgLjU4LjA4IDEuMTIuMjMgMS42NHMuMzkuOTcuNzEgMS4zNS43Mi42OSAxLjIuOTFjLjQ4LjIyIDEuMDUuMzQgMS43LjM0LjQ3IDAgLjkxLS4wOCAxLjMyLS4yM3MuNzctLjM2IDEuMDgtLjYzLjU2LS41OC43NC0uOTQuMjktLjc0LjMtMS4xNWgtMS43OWMtLjAxLjIxLS4wNi40LS4xNS41OHMtLjIxLjMzLS4zNi40Ni0uMzIuMjMtLjUyLjNjLS4xOS4wNy0uMzkuMDktLjYuMS0uMzYtLjAxLS42Ni0uMDgtLjg5LS4yMy0uMjUtLjE2LS40NS0uMzctLjU5LS42MnMtLjI1LS41NS0uMy0uODgtLjA4LS42Ny0uMDgtMXYtLjI3YzAtLjM1LjAzLS42OC4wOC0xLjAxek0xMiAyQzYuNDggMiAyIDYuNDggMiAxMnM0LjQ4IDEwIDEwIDEwIDEwLTQuNDggMTAtMTBTMTcuNTIgMiAxMiAyem0wIDE4Yy00LjQxIDAtOC0zLjU5LTgtOHMzLjU5LTggOC04IDggMy41OSA4IDgtMy41OSA4LTggOHoiLz48L3N2Zz4=" height="22">][license-mit-url]

[English][en-url] | 简体中文

</div>

## Installation
```toml
[dependencies]
template_rs = "0.1"
```

## Features
- [x] 更快的创建GitHub开源Rust代码库

#### License

`Template-rs` is under the terms of both the MIT license and the
Apache License (Version 2.0).

See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT) for details.

Copyright (c) 2021 Al Liu.

[Github-url]: https://github.com/al8n/template-rs/
[CI-url]: https://github.com/al8n/template/actions/workflows/template.yml
[doc-url]: https://docs.rs/template-rs
[crates-url]: https://crates.io/crates/template-rs
[codecov-url]: https://app.codecov.io/gh/al8n/template-rs/
[license-url]: https://opensource.org/licenses/Apache-2.0
[rustc-url]: https://github.com/rust-lang/rust/blob/master/RELEASES.md
[license-apache-url]: https://opensource.org/licenses/Apache-2.0
[license-mit-url]: https://opensource.org/licenses/MIT
[en-url]: https://github.com/al8n/template-rs/tree/main/README.md
Loading

0 comments on commit b7d9ff1

Please sign in to comment.