Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nugine committed Nov 20, 2024
0 parents commit cf814a0
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/target

.vscode
.idea
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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: <https://docs.rs/rust-template>
21 changes: 21 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
dev:
just fmt
just lint
just test

fmt:
cargo fmt

lint:
cargo clippy --all-features

test:
cargo test --all-features

doc:
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --open --no-deps --all-features

ci:
cargo fmt --all --check
cargo clippy --all-features -- -D warnings
just test
20 changes: 20 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit cf814a0

Please sign in to comment.