Crates.io | rust_lib_example |
lib.rs | rust_lib_example |
version | 0.2.0 |
source | src |
created_at | 2021-04-14 19:30:44.860509 |
updated_at | 2021-05-02 10:23:27.61008 |
description | Rust project example |
homepage | |
repository | https://github.com/Nicolas-Ferre/rust-example |
max_upload_size | |
id | 384161 |
size | 38,367 |
This repository contains an example of Rust project structure.
Most of the components can be reusable in your own projects:
The CI
workflow is triggered for any commit or pull request on the main
branch and runs the following jobs:
#[mutate]
annotations)clippy
rustfmt
to check code is correctly formattedcargo-deny
to check dependenciesThis workflow is only run on Ubuntu virtual environment.
The CD
workflow is triggered manually and runs the following jobs:
Cargo.toml
filesCHANGELOG.md
file and push the changesCHANGELOG.md
fileCHANGELOG.md
file and push the changesThe CD
workflow requires the following secrets:
CRATES_IO_TOKEN
: token to publish the crate(s) on crates.ioGIT_TOKEN
: GitHub personal access token to allow pushing changes as administrator (if the main
branch is protected, "Include administrators" must be unchecked in settings)These secrets must be stored in a repository environment called Deployment
.
Settings of the CI
workflow can be modified in the file .github/workflows/ci.yml
, in the env
section:
RUST_VERSION_STABLE
: version of the stable Rust compiler to useRUST_VERSION_NIGHTLY
: version of the nightly Rust compiler to use when requiredMUTAGEN_COMMIT
: commit of the mutagen version to install (from mutagen repository)COV_THRESHOLD
: minimum threshold the coverage must reached to succeed the jobMUTAGEN_THRESHOLD
: minimum threshold the mutation tests must reached to succeed the jobCRATE_PATHS
: package names separated by ;
in publication order if the repository is a Cargo workspace, else .
Settings of the CD
workflow can be modified in the file .github/workflows/cd.yml
, in the env
section:
RUST_VERSION_STABLE
: version of the stable Rust compiler to useCRATE_PATHS
: package names separated by ;
in publication order if the repository is a Cargo workspace, else .
act can be used to run the workflows on your own machine.
Once installed, run act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04
in the repository folder to run all supported jobs.
This repository contains a single crate, but the workflows should also work with a Cargo workspace.
This project example is made to be reused. If you are interested in using this template, you can copy the files in your own project and:
.github/workflows/ci.yml
, in the env
section.github/workflows/cd.yml
, in the env
section.lints
, deny.toml
, rustfmt.toml
, Cargo.toml
and README.md
files as wanted.github/ISSUE_TEMPLATE
as wantedCHANGELOG.md
file (make sure there is at least a section ## [Unreleased] - yyyy-mm-dd
)LICENSE-MIT
and LICENSE-APACHE
files if you keep these licensesDeployment
with the CRATES_IO_TOKEN
and GIT_TOKEN
secretsmain
branch is configured as protected, make sure Include administrators
is unchecked in the configurationLicensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.