diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8efb60e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: CI + +on: + push: + branches: + - main + - 'feat/**' + pull_request: + branches: + - main + - 'feat/**' + schedule: + - cron: '0 0 * * 0' # at midnight of each sunday + workflow_dispatch: + +jobs: + develop: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: taiki-e/install-action@just + - uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt, clippy, miri + - uses: Swatinem/rust-cache@v2 + - run: just ci + + msrv: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + toolchain: + - 1.74.0 # MSRV + - stable + steps: + - uses: actions/checkout@v4 + - uses: taiki-e/install-action@just + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + - uses: Swatinem/rust-cache@v2 + - run: just test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..20c873f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,16 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: taiki-e/install-action@just + - uses: dtolnay/rust-toolchain@nightly + - run: cargo login ${{ secrets.CRATES_IO_API_TOKEN }} + - run: cargo publish --dry-run + - run: cargo publish diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..da5846d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/target + +.vscode +.idea diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..de13382 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "rust-template" +version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..253fe8f --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "rust-template" +version = "0.0.0" +edition = "2021" +description = "Rust library template" +license = "MIT" +repository = "https://github.com/Nugine/rust-template" +readme = "README.md" +documentation = "https://docs.rs/rust-template" +categories = ["rust-patterns"] +keywords = ["template"] +publish = false + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[dependencies] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..69ed5ef --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Nugine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..840eec6 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# rust-template + +[![Latest Version]][crates.io] +[![Documentation]][docs.rs] +![License] + +[crates.io]: https://crates.io/crates/rust-template +[Latest Version]: https://img.shields.io/crates/v/rust-template.svg +[Documentation]: https://docs.rs/rust-template/badge.svg +[docs.rs]: https://docs.rs/rust-template +[License]: https://img.shields.io/crates/l/rust-template.svg + +Documentation: diff --git a/justfile b/justfile new file mode 100644 index 0000000..29e2e6a --- /dev/null +++ b/justfile @@ -0,0 +1,21 @@ +dev: + just fmt + just lint + just test + +fmt *ARGS: + cargo fmt --all {{ARGS}} + +lint *ARGS: + cargo clippy --all-features --tests --benches {{ARGS}} + +test *ARGS: + cargo test --all-features {{ARGS}} + +doc *ARGS: + RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --open --no-deps --all-features {{ARGS}} + +ci: + just fmt --check + just lint -- -D warnings + just test diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..e74699a --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,20 @@ +#![deny(unsafe_code)] +#![deny(clippy::all, clippy::pedantic, clippy::cargo)] +// --- +#![cfg_attr(docsrs, feature(doc_cfg))] + +#[must_use] +pub fn add(left: u64, right: u64) -> u64 { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +}