diff --git a/.github/actions/build_setup/action.yaml b/.github/actions/build_setup/action.yaml new file mode 100644 index 0000000..54e477a --- /dev/null +++ b/.github/actions/build_setup/action.yaml @@ -0,0 +1,14 @@ +name: Build Setup +description: Install build dependencies and levarage caching. +runs: + using: composite + steps: + - name: Leverage caching + uses: Swatinem/rust-cache@v2 + with: + key: x86_64-unknown-linux-gnu + - name: Install toolchain - nightly + uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly + components: rustfmt, clippy, rust-docs diff --git a/.github/codecov.yaml b/.github/codecov.yaml new file mode 100644 index 0000000..f80b64c --- /dev/null +++ b/.github/codecov.yaml @@ -0,0 +1,8 @@ +coverage: + status: + project: + default: + threshold: 1% + patch: + default: + threshold: 75% diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..c255393 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,11 @@ +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml new file mode 100644 index 0000000..e63270e --- /dev/null +++ b/.github/workflows/audit.yaml @@ -0,0 +1,13 @@ +# Taken from: https://github.com/LukeMathWalker/zero-to-production/blob/main/.github/workflows/audit.yml +name: Security audit +on: + schedule: + - cron: '0 0 * * *' +jobs: + security_audit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: taiki-e/install-action@cargo-deny + - name: Scan for vulnerabilities + run: cargo deny check advisories diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..2cccd9b --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,134 @@ +name: CI +on: + push: + branches: [main] + pull_request: + branches: [main] +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: full +jobs: + cargo_fmt: + name: Cargo format + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Build setup + uses: ./.github/actions/build_setup + - name: cargo fmt + run: cargo fmt --all -- --check + spelling: + name: Spell checking + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: typos + uses: crate-ci/typos@master + taplo_checks: + name: Toml validation + runs-on: ubuntu-latest + container: + image: tamasfe/taplo:0.8.0 + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: taplo lint + run: taplo lint + - name: taplo fmt + run: taplo fmt --check --diff + cargo_test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Build setup + uses: ./.github/actions/build_setup + - name: Run tests + run: cargo test --all-features -- --include-ignored --nocapture + clippy: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Build setup + uses: ./.github/actions/build_setup + - name: Run clippy + run: cargo clippy --all-features --tests -- -D warnings + mdbook_validation: + name: mdBook validation + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Build setup + uses: ./.github/actions/build_setup + - name: mdBook setup + uses: peaceiris/actions-mdbook@v1 + with: + mdbook-version: 'latest' + - name: Run mdbook test + run: mdbook test + docs_validation: + name: Docs validation + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Build setup + uses: ./.github/actions/build_setup + - name: Run cargo doc + env: + RUSTDOCFLAGS: "-D warnings" + run: cargo doc --no-deps --all-features + audit: + name: Audit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: taiki-e/install-action@cargo-deny + - name: Vulnerability scanning + run: cargo deny check advisories + unused: + name: Unused + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Build setup + uses: ./.github/actions/build_setup + - name: Run cargo-udeps + uses: aig787/cargo-udeps-action@v1 + with: + args: --all-features + lychee_links: + name: Links + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Run lychee + uses: lycheeverse/lychee-action@v1.9.3 + with: + fail: true + coverage: + name: Coverage + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Build setup + uses: ./.github/actions/build_setup + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Generate code coverage + run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: lcov.info + fail_ci_if_error: true diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..f4f38da --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,41 @@ +name: Release + +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + +jobs: + publish_book: + name: Publish mdBook + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Build setup + uses: ./.github/actions/build_setup + - name: mdBook setup + uses: peaceiris/actions-mdbook@v1 + with: + mdbook-version: 'latest' + - name: Build book + run: mdbook build + - name: Deploy to GitHub pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: target/book + git-config-email: <> + publish_crates: + name: Publish to crates.io + runs-on: ubuntu-latest + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Build setup + uses: ./.github/actions/build_setup + - name: Publish the respective crates + run: cargo publish diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6af6b32 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +# Changelog + +The format is based on the latest version of [Keep a Changelog](https://keepachangelog.com/en), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..c84d1d5 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,130 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +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 gabrielhansson00@gmail.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private or public written warning from community leaders. Often with an explanation as to why such behavior was deemed inappropriate. Respective leaders may also ask the person in question why their behavior felt warranted. And may, from there, choose to request a public apology. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..96ccc4c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,71 @@ +# Contributing Guidelines + +There are some things that should be kept in mind when contributing to this project. +- Each commit is expected to pass CI on its own, (even if it's not automatically enforced by the CI pipeline). +- Bug fixes and feature additions should be accompanied by tests. +- Commit messages should at the very least give some explanation of what has changed, writing "Fix." does not count. Gold star to you if the message also includes a motivation. +- Each pull request should add their changes to the [CHANGELOG.md](CHANGELOG.md) and attempt to follow the conventions described in [Keep a Changelog](https://keepachangelog.com). + +Structure requirements on commit messages, issues and pull requests are other than that pretty relaxed, (for now 🤞). + +### Using pre-commit hooks + + Using a pre-commit hook to locally check simpler CI validation steps is encouraged to avoid squash commit requests by the maintainers, but also `git commit --amend && git push --force` abuse. This can be achieved by pasting the following into `.git/hooks/pre-commit`: + +```sh +#!/bin/sh +set -e + +# Make sure the toolchain is up to date and includes the +# necessary components specified in rust-toolchain.toml: +rustup update "$(rustup toolchain list | rg override | cut -d ' ' -f1)" + +# Make sure things are properly formatted +cargo fmt -- --check +taplo fmt --check --diff + +# Make sure things follow common linting recommendations +cargo clippy --all-features --tests -- -D warnings + +# Check documentation +RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features + +# Some may also want to uncomment: +# cargo test --all-features +# mdbook test +``` + +### Running tests + +Pretty standard procedure apart from noting that some tests may be behind feature flags, so: + +```sh +cargo test --all-features +``` + +Book testing may be done by: + +```sh +mdbook test +``` + +### Generating and opening documentation + +```sh +cargo doc --no-deps --all-features --open +``` + +Book documentation may be generated by installing [`mdbook`](https://rust-lang.github.io/mdBook/guide/installation.html) before running `mdbook serve --open`. + +## Release (for maintainers) + +1. Make sure CI is not failing. +2. Bump version in the workspace `Cargo.toml` file. +3. Move the unreleased section in the CHANGELOG.md into a release with the current date added. +4. Finally: + +```sh +git commit -am "Prepare X.X.X release." +git tag "X.X.X" +git push && git push --tags +``` diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..e770f38 --- /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 = "PROJECT_NAME-common" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..72d6c04 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,17 @@ +[workspace] +resolver = "2" +members = ["crates/*"] + +[workspace.package] +authors = ["AUTHOR_EMAIL"] +repository = "https://github.com/GITHUB_PATH" +exclude = ["/.github"] +edition = "2021" +readme = "README.md" +version = "0.1.0" + +[workspace.dependencies] + +[workspace.lints.rust] +unused_must_use = "deny" +missing_docs = "deny" diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..a612ad9 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e573a27 --- /dev/null +++ b/README.md @@ -0,0 +1,59 @@ +# PROJECT_NAME - PROJECT_DESCRIPTION + +[![ci_status](https://img.shields.io/github/actions/workflow/status/GITHUB_PATH/ci.yaml?style=for-the-badge)](https://github.com/GITHUB_PATH/actions/workflows/ci.yaml) +[![codecov](https://img.shields.io/codecov/c/gh/GITHUB_PATH?token=CODE_COV_TOKEN&style=for-the-badge)](https://codecov.io/gh/GITHUB_PATH) +[![license](https://img.shields.io/github/license/GITHUB_PATH.svg?style=for-the-badge)](https://github.com/GITHUB_PATH/blob/main/LICENSE.md) + +## Usage + +Update the respective value in [template.sh](/template.sh) and execute it. (Assumes `fd` is installed.) +Remove `template.sh`, but also the [[#Usage]] and [[#Features]] README.md sections + +### CI/CD expects the following environment variables: + +`ci.yaml` + +* `CODECOV_TOKEN` - for code coverage reporting + +`releases.yaml` + +* `CARGO_REGISTRY_TOKEN` - for crate publishing + +## Features + +### CI/CD + +#### Linting + +* cargo fmt +* cargo clippy +* taplo lint +* taplo fmt +* cargo doc warnings +* lychee - link checking +* cargo udeps - unused dependencies +* typos + +#### Testing + +* cargo test +* mdbook test +* cargo llvm-cod - uploaded to codecov + +#### Misc + +* cargo deny - dependency vulnerability scanning +* dependabot - weekly depencendy updates scanning + +#### Release + +* On tagged commits only +* mdbook publish +* cargo publish + +## Further reading + +* [Architecture](ARCHITECTURE_URL) +* [Contributing](/CODE_OF_CONDUCT.md) +* [Code of conduct](/CODE_OF_CONDUCT.md) +* [Security policy](/SECURITY.md) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..10b01fd --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,11 @@ +# Security Policy + +## Reporting a Vulnerability + +* If you have discovered a security vulnerability in this project, then please disclose it as a security advisory [here](https://github.com/GITHUB_PATH/security/advisories/new). +* Do not reveal the problem to others until it has been resolved, or when 90 days have passed since the security advisory was first created. +* Do not take advantage of the vulnerability problem you have discovered. + +## Supported Versions + +The security policy applies to all versions, but security updates will only be added as parts of a new release. The same goes for bug fixes of any kind. diff --git a/book.toml b/book.toml new file mode 100644 index 0000000..d2abd82 --- /dev/null +++ b/book.toml @@ -0,0 +1,19 @@ +[book] +authors = ["AUTHOR_EMAIL"] +language = "en" +multilingual = false +src = "book" +title = "PROJECT_NAME Documentation" + +[rust] +edition = "2021" + +[build] +build-dir = "target/book" + +[output.html] +preferred-dark-theme = "navy" +curly-quotes = true +git-repository-url = "https://github.com/GITHUB_PATH/PROJECT_NAME" +edit-url-template = "https://github.com/GITHUB_PATH/PROJECT_NAME/edit/main/{path}" +cname = "GITHUB_PAGES_URL" diff --git a/book/SUMMARY.md b/book/SUMMARY.md new file mode 100644 index 0000000..71eb5de --- /dev/null +++ b/book/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +[Introduction](./introduction.md) diff --git a/book/introduction.md b/book/introduction.md new file mode 100644 index 0000000..e10b99d --- /dev/null +++ b/book/introduction.md @@ -0,0 +1 @@ +# Introduction diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml new file mode 100644 index 0000000..2033ad1 --- /dev/null +++ b/crates/common/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "PROJECT_NAME-common" +authors.workspace = true +repository.workspace = true +exclude.workspace = true +edition.workspace = true +readme.workspace = true +version.workspace = true + +[lints] +workspace = true + +[dependencies] diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs new file mode 100644 index 0000000..ef67619 --- /dev/null +++ b/crates/common/src/lib.rs @@ -0,0 +1 @@ +//! PROJECT_NAME commons. diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..5d56faf --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly" diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..0d2c907 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,3 @@ +max_width = 140 +imports_granularity = "Crate" +group_imports = "StdExternalCrate" diff --git a/taplo.toml b/taplo.toml new file mode 100644 index 0000000..65948ab --- /dev/null +++ b/taplo.toml @@ -0,0 +1,2 @@ +[formatting] +inline_table_expand = false diff --git a/template.sh b/template.sh new file mode 100755 index 0000000..0ca4f6a --- /dev/null +++ b/template.sh @@ -0,0 +1,13 @@ +#!/bin/sh +replace_all() { + fd --type file . | xargs sed -i -e "s^$1^$2^g" +} + +# Assumptions: hosted on github.com, default branch is main. +replace_all 'PROJECT_NAME' 'project-name' +replace_all 'PROJECT_DESCRIPTION' 'Some description' +replace_all 'AUTHOR_EMAIL' 'First Last ' +replace_all 'GITHUB_PATH' 'username/repo' +replace_all 'GITHUB_PAGES_URL' 'username.github.io' +replace_all 'CODE_COV_TOKEN' 'xxx' +replace_all 'ARCHITECTURE_URL' 'https://i.kym-cdn.com/photos/images/original/002/546/187/fb1.jpg'