diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index 79e5c73..0000000 --- a/.cargo/config +++ /dev/null @@ -1,49 +0,0 @@ -[alias] -# Collection of project wide clippy lints. This is done via an alias because -# clippy doesn't currently allow for specifiying project-wide lints in a -# configuration file. This is a similar workaround to the ones presented here: -# -xclippy = [ - "clippy", "--workspace", "--all-targets", "--", - "-Wclippy::all", - "-Wclippy::cast_lossless", - "-Wclippy::checked_conversions", - "-Wclippy::dbg_macro", - "-Wclippy::disallowed_methods", - "-Wclippy::derive_partial_eq_without_eq", - "-Wclippy::enum_glob_use", - "-Wclippy::filter_map_next", - "-Wclippy::flat_map_option", - "-Wclippy::from_iter_instead_of_collect", - "-Wclippy::implicit_clone", - "-Wclippy::inefficient_to_string", - "-Wclippy::large_stack_arrays", - "-Wclippy::large_types_passed_by_value", - "-Wclippy::macro_use_imports", - "-Wclippy::manual_assert", - "-Wclippy::manual_ok_or", - "-Wclippy::map_err_ignore", - "-Wclippy::map_flatten", - "-Wclippy::map_unwrap_or", - "-Wclippy::match_same_arms", - "-Wclippy::match_wild_err_arm", - "-Wclippy::needless_borrow", - "-Wclippy::needless_continue", - "-Wclippy::needless_for_each", - "-Wclippy::needless_pass_by_value", - "-Wclippy::option_option", - "-Wclippy::same_functions_in_if_condition", - "-Wclippy::single_match_else", - "-Wclippy::trait_duplication_in_bounds", - "-Wclippy::unnecessary_mut_passed", - "-Wclippy::unnecessary_wraps", - "-Wclippy::unnested_or_patterns", - "-Wclippy::use_self", - "-Wmissing_debug_implementations", - "-Wnonstandard_style", - "-Wrust_2018_idioms", - "-Wtrivial_numeric_casts", - "-Wunused_lifetimes", - "-Wunused_qualifications", - "-Wunreachable_pub" -] diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6dfcab7..1f5ea60 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,17 +6,29 @@ updates: separator: "-" schedule: interval: weekly + # Create separate pull requests for major vs minor/patch version updates, as major bumps will likely introduce breaking changes groups: - rust-dependencies: + rust-minor: patterns: - "*" update-types: - "minor" - "patch" - + rust-major: + patterns: + - "*" + update-types: + - "major" + allow: + # Update both direct and indirect dependencies + - dependency-type: "all" open-pull-requests-limit: 5 - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" + groups: + actions: + patterns: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 427adc4..d0e1509 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,9 +3,9 @@ name: Build and Test on: merge_group: pull_request: - types: [opened, synchronize, reopened, ready_for_review] branches: - main + - dev - 'feat/**' - release-candidate workflow_dispatch: @@ -16,16 +16,14 @@ concurrency: jobs: linux-test: - # Change to buildjet-16vcpu-ubuntu-2204 for a more powerful runner (GitHub App must be enabled) + # Change to warp-ubuntu-latest-x64-16x for a more powerful runner (GitHub App must be enabled for this repo) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: - repository: lurk-lab/ci-workflows + repository: argumentcomputer/ci-workflows - uses: ./.github/actions/ci-env - uses: actions/checkout@v4 - with: - submodules: recursive - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@nextest - uses: Swatinem/rust-cache@v2 @@ -33,16 +31,29 @@ jobs: run: | cargo nextest run --profile ci --cargo-profile dev-ci --workspace - # Wasm build, rustfmt, clippy, doctests, and MSRV - code-quality: - uses: lurk-lab/ci-workflows/.github/workflows/lints.yml@main - - # Check documentation links aren't broken - link-checker: - uses: lurk-lab/ci-workflows/.github/workflows/links-check.yml@main - with: - fail-fast: true - - # Lint dependencies for licensing and auditing issues as per `deny.toml` - licenses-audits: - uses: lurk-lab/ci-workflows/.github/workflows/licenses-audits.yml@main + lints: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: argumentcomputer/ci-workflows + - uses: ./.github/actions/ci-env + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - name: Check Rustfmt code style + run: cargo fmt --all --check + - name: Check *everything* compiles + run: cargo check --all-targets --all-features --workspace + - name: Check clippy lints + run: cargo clippy --workspace --all-targets -- -D warnings + - name: Doctests + run: cargo test --doc --workspace + - name: Get Rust version + run: | + echo "RUST_VERSION=$(awk -F '"' '/^channel/ {print $2}' rust-toolchain.toml)" | tee -a $GITHUB_ENV + # Lint dependencies for licensing and auditing issues as per `deny.toml` + - name: Cargo-deny + uses: EmbarkStudios/cargo-deny-action@v2 + with: + rust-version: ${{ env.RUST_VERSION }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 93505fb..e25e54a 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -12,4 +12,4 @@ on: jobs: docs: - uses: lurk-lab/ci-workflows/.github/workflows/docs.yml@main + uses: argumentcomputer/ci-workflows/.github/workflows/docs.yml@main diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index fd8983c..69c328d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -12,10 +12,10 @@ env: jobs: unused-dependencies: - uses: lurk-lab/ci-workflows/.github/workflows/unused-deps.yml@main + uses: argumentcomputer/ci-workflows/.github/workflows/unused-deps.yml@main rust-version-check: - uses: lurk-lab/ci-workflows/.github/workflows/rust-version-check.yml@main + uses: argumentcomputer/ci-workflows/.github/workflows/rust-version-check.yml@main typos: - uses: lurk-lab/ci-workflows/.github/workflows/typos.yml@main + uses: argumentcomputer/ci-workflows/.github/workflows/typos.yml@main diff --git a/.gitignore b/.gitignore index 6985cf1..73fab07 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,6 @@ debug/ target/ -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - # These are backup files generated by rustfmt **/*.rs.bk diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 7479331..5215ad5 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -60,7 +60,7 @@ representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at community@lurk-lab.com. +reported to the community leaders responsible for enforcement at community@argument.xyz. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..92ee501 --- /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 = "template" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index d53fa3a..6871834 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "template" version = "0.1.0" -edition = "2021" -authors = ["Lurk Lab Engineering "] +edition = "2024" +authors = ["Argument Engineering "] license = "MIT OR Apache-2.0" # EDIT AS NEEDED -rust-version = "1.70" +rust-version = "1.88" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -22,3 +22,47 @@ opt-level = 3 lto = "thin" incremental = false codegen-units = 16 + +[lints.clippy] +cast_lossless = "warn" +cast_possible_truncation = "warn" +cast_precision_loss = "warn" +cast_sign_loss = "warn" +cast_possible_wrap = "warn" +ptr_as_ptr = "warn" +checked_conversions = "warn" +dbg_macro = "warn" +derive_partial_eq_without_eq = "warn" +enum_glob_use = "warn" +explicit_into_iter_loop = "warn" +fallible_impl_from = "warn" +filter_map_next = "warn" +flat_map_option = "warn" +from_iter_instead_of_collect = "warn" +implicit_clone = "warn" +inefficient_to_string = "warn" +large_stack_arrays = "warn" +large_types_passed_by_value = "warn" +macro_use_imports = "warn" +manual_assert = "warn" +map_err_ignore = "warn" +map_unwrap_or = "warn" +match_same_arms = "warn" +match_wild_err_arm = "warn" +needless_continue = "warn" +needless_for_each = "warn" +needless_pass_by_value = "warn" +option_option = "warn" +same_functions_in_if_condition = "warn" +trait_duplication_in_bounds = "warn" +unnecessary_wraps = "warn" +unnested_or_patterns = "warn" +use_self = "warn" + +[lints.rust] +nonstandard_style = "warn" +rust_2024_compatibility = "warn" +trivial_numeric_casts = "warn" +unused_lifetimes = "warn" +unused_qualifications = "warn" +unreachable_pub = "warn" diff --git a/LICENSE-MIT b/LICENSE-MIT index 5170f30..784df0a 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Lurk Lab +Copyright (c) 2025 Argument Computer Corporation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index f2688a3..3e3d0c5 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ # template-rust-lib -Base template for a Rust library crate with CI, config files, and branch protection + +Base template for a Rust library with CI, config files, and branch protection ## Usage - Generate a new repo via the green "Use this template" button - Run the following to remove template language: ``` # Replace all occurrences with the desired library name -$ grep -ir template . --exclude-dir .git --exclude deny.toml -# Replace all occurrences as needed -$ grep -r "EDIT AS NEEDED" . +$ rg -i template --glob '!deny.toml' +# Update Rust toolchain if desired +$ rg "EDIT AS NEEDED" # Then rewrite this `README` ``` - Create a branch protection rule for `main` and enable the following as needed: @@ -17,10 +18,9 @@ $ grep -r "EDIT AS NEEDED" . - Dismiss stale pull request approvals when new commits are pushed - Require approval of the most recent reviewable push - Require status checks to pass before merging (optional, after CI has been triggered) - - E.g. `linux-test`, `msrv`, and `lints` + - E.g. `linux-test` and `lints` - Require a merge queue using `squash and merge` (optional, only allowed if repo is public) - Allow force pushes if needed to bypass above restrictions when necessary -- Enable full write access for Lurk Lab members by adding the `lurk-dev` team in `Settings->Collaborators and teams` - Edit licenses and `deny.toml` as needed ## License diff --git a/deny.toml b/deny.toml index 280fb62..bc88cc8 100644 --- a/deny.toml +++ b/deny.toml @@ -11,6 +11,9 @@ # Root options +# The graph table configures how the dependency graph is constructed and thus +# which crates the checks are performed against +[graph] # If 1 or more target triples (and optionally, target_features) are specified, # only the specified targets will be checked when running `cargo deny check`. # This means, if a particular package is only ever used as a target specific @@ -22,7 +25,7 @@ targets = [ # The triple can be any string, but only the target triples built in to # rustc (as of 1.40) can be checked against actual config expressions - #{ triple = "x86_64-unknown-linux-musl" }, + #"x86_64-unknown-linux-musl", # You can also specify which target_features you promise are enabled for a # particular target. target_features are currently not validated against # the actual valid features supported by the target architecture. @@ -46,6 +49,9 @@ no-default-features = false # If set, these feature will be enabled when collecting metadata. If `--features` # is specified on the cmd line they will take precedence over this option. #features = [] + +# The output table provides options for how/if diagnostics are outputted +[output] # When outputting inclusion graphs in diagnostics that include features, this # option can be used to specify the depth at which feature edges will be added. # This option is included since the graphs can be quite large and the addition @@ -57,35 +63,18 @@ feature-depth = 1 # More documentation for the advisories section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html [advisories] -# The path where the advisory database is cloned/fetched into -db-path = "~/.cargo/advisory-db" +# The path where the advisory databases are cloned/fetched into +#db-path = "$CARGO_HOME/advisory-dbs" # The url(s) of the advisory databases to use -db-urls = ["https://github.com/rustsec/advisory-db"] -# The lint level for security vulnerabilities -vulnerability = "deny" -# The lint level for unmaintained crates -unmaintained = "warn" -# The lint level for crates that have been yanked from their source registry -yanked = "warn" -# The lint level for crates with security notices. Note that as of -# 2019-12-17 there are no security notice advisories in -# https://github.com/rustsec/advisory-db -notice = "warn" +#db-urls = ["https://github.com/rustsec/advisory-db"] # A list of advisory IDs to ignore. Note that ignored advisories will still # output a note when they are encountered. ignore = [ #"RUSTSEC-0000-0000", + #{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" }, + #"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish + #{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" }, ] -# Threshold for security vulnerabilities, any vulnerability with a CVSS score -# lower than the range specified will be ignored. Note that ignored advisories -# will still output a note when they are encountered. -# * None - CVSS Score 0.0 -# * Low - CVSS Score 0.1 - 3.9 -# * Medium - CVSS Score 4.0 - 6.9 -# * High - CVSS Score 7.0 - 8.9 -# * Critical - CVSS Score 9.0 - 10.0 -#severity-threshold = - # If this is true, then cargo deny will use the git executable to fetch advisory database. # If this is false, then it uses a built-in git library. # Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support. @@ -96,43 +85,14 @@ ignore = [ # More documentation for the licenses section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html [licenses] -# The lint level for crates which do not have a detectable license -unlicensed = "deny" # List of explicitly allowed licenses # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. allow = [ "MIT", - "BSL-1.0", - "0BSD", - "BSD-2-Clause", - "BSD-3-Clause", - "CC0-1.0", "Apache-2.0", - "Apache-2.0 WITH LLVM-exception", - "Unicode-DFS-2016", - "ISC", -] -# List of explicitly disallowed licenses -# See https://spdx.org/licenses/ for list of possible licenses -# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. -deny = [ - #"Nokia", + #"Apache-2.0 WITH LLVM-exception", ] -# Lint level for licenses considered copyleft -copyleft = "deny" -# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses -# * both - The license will be approved if it is both OSI-approved *AND* FSF -# * either - The license will be approved if it is either OSI-approved *OR* FSF -# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF -# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved -# * neither - This predicate is ignored and the default lint level is used -allow-osi-fsf-free = "neither" -# Lint level used when no other predicates are matched -# 1. License isn't in the allow or deny lists -# 2. License isn't copyleft -# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither" -default = "deny" # The confidence threshold for detecting a license from license text. # The higher the value, the more closely the license text must be to the # canonical license text of a valid SPDX license file. @@ -143,18 +103,15 @@ confidence-threshold = 0.8 exceptions = [ # Each entry is the crate and version constraint, and its specific allow # list - # inferno is only imported under the flamegraph feature - { allow = ["CDDL-1.0"], name = "inferno" }, + #{ allow = ["Zlib"], crate = "adler32" }, ] # Some crates don't have (easily) machine readable licensing information, # adding a clarification entry for it allows you to manually specify the # licensing information #[[licenses.clarify]] -# The name of the crate the clarification applies to -#name = "ring" -# The optional version constraint for the crate -#version = "*" +# The package spec the clarification applies to +#crate = "ring" # The SPDX expression for the license requirements of the crate #expression = "MIT AND ISC AND OpenSSL" # One or more files in the crate's source used as the "source of truth" for @@ -163,8 +120,8 @@ exceptions = [ # and the crate will be checked normally, which may produce warnings or errors # depending on the rest of your configuration #license-files = [ - # Each entry is a crate relative path, and the (opaque) hash of its contents - #{ path = "LICENSE", hash = 0xbd0eed23 } +# Each entry is a crate relative path, and the (opaque) hash of its contents +#{ path = "LICENSE", hash = 0xbd0eed23 } #] [licenses.private] @@ -204,24 +161,23 @@ workspace-default-features = "allow" external-default-features = "allow" # List of crates that are allowed. Use with care! allow = [ - #{ name = "ansi_term", version = "=0.11.0" }, + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is allowed" }, ] # List of crates to deny deny = [ - # Each entry the name of a crate and a version range. If version is - # not specified, all versions will be matched. - #{ name = "ansi_term", version = "=0.11.0" }, - # + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is banned" }, # Wrapper crates can optionally be specified to allow the crate when it # is a direct dependency of the otherwise banned crate - #{ name = "ansi_term", version = "=0.11.0", wrappers = [] }, + #{ crate = "ansi_term@0.11.0", wrappers = ["this-crate-directly-depends-on-ansi_term"] }, ] # List of features to allow/deny # Each entry the name of a crate and a version range. If version is # not specified, all versions will be matched. #[[bans.features]] -#name = "reqwest" +#crate = "reqwest" # Features to not allow #deny = ["json"] # Features to allow @@ -242,14 +198,16 @@ deny = [ # Certain crates/versions that will be skipped when doing duplicate detection. skip = [ - #{ name = "ansi_term", version = "=0.11.0" }, + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason why it can't be updated/removed" }, ] # Similarly to `skip` allows you to skip certain crates during duplicate # detection. Unlike skip, it also includes the entire tree of transitive # dependencies starting at the specified crate, up to a certain depth, which is # by default infinite. skip-tree = [ - #{ name = "ansi_term", version = "=0.11.0", depth = 20 }, + #"ansi_term@0.11.0", # will be skipped along with _all_ of its direct and transitive dependencies + #{ crate = "ansi_term@0.11.0", depth = 20 }, ] # This section is considered when running `cargo deny check sources`. @@ -261,7 +219,7 @@ skip-tree = [ unknown-registry = "warn" # Lint level for what to happen when a crate from a git repository that is not # in the allow list is encountered -unknown-git = "deny" +unknown-git = "warn" # List of URLs for allowed crate registries. Defaults to the crates.io index # if not specified. If it is specified but empty, no registries are allowed. allow-registry = ["https://github.com/rust-lang/crates.io-index"] @@ -269,9 +227,10 @@ allow-registry = ["https://github.com/rust-lang/crates.io-index"] allow-git = [] [sources.allow-org] -# 1 or more github.com organizations to allow git sources for -github = ["lurk-lab"] -# 1 or more gitlab.com organizations to allow git sources for -# gitlab = [""] -# 1 or more bitbucket.org organizations to allow git sources for -# bitbucket = [""] +# github.com organizations to allow git sources for +#github = ["argumentcomputer"] +github = [] +# gitlab.com organizations to allow git sources for +gitlab = [] +# bitbucket.org organizations to allow git sources for +bitbucket = [] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 0257e37..f8a91b9 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] # The default profile includes rustc, rust-std, cargo, rust-docs, rustfmt and clippy. profile = "default" -channel = "1.76" -targets = [ "wasm32-unknown-unknown" ] +# EDIT AS NEEDED +channel = "1.88"