diff --git a/.convco b/.convco new file mode 100644 index 0000000..a6f7c1e --- /dev/null +++ b/.convco @@ -0,0 +1,68 @@ +header: | + # Changelog +types: +- type: feat + increment: Minor + section: Features + hidden: false +- type: fix + increment: Patch + section: Fixes + hidden: false +- type: build + increment: None + section: Other + hidden: true +- type: chore + increment: None + section: Other + hidden: true +- type: ci + increment: None + section: Other + hidden: true +- type: docs + increment: None + section: Documentation + hidden: true +- type: style + increment: None + section: Other + hidden: true +- type: refactor + increment: None + section: Other + hidden: true +- type: perf + increment: None + section: Other + hidden: true +- type: test + increment: None + section: Other + hidden: true +preMajor: false +commitUrlFormat: '{{@root.host}}/{{@root.owner}}/{{@root.repository}}/commit/{{hash}}' +compareUrlFormat: '{{@root.host}}/{{@root.owner}}/{{@root.repository}}/compare/{{previousTag}}...{{currentTag}}' +issueUrlFormat: '{{@root.host}}/{{@root.owner}}/{{@root.repository}}/issues/{{issue}}' +userUrlFormat: '{{host}}/{{user}}' +releaseCommitMessageFormat: 'chore(release): {{currentTag}}' +issuePrefixes: +- '#' +host: null +owner: null +repository: null +template: null +commitTemplate: null +scopeRegex: ^[[:alnum:]]+(?:[-_/][[:alnum:]]+)*$ +lineLength: 80 +wrapDisabled: false +linkCompare: true +linkReferences: true +merges: false +firstParent: false +stripRegex: '' +description: + length: + min: 10 + max: null diff --git a/.github/workflows/essentials.yml b/.github/workflows/essentials.yml index 2e8138c..a9679a2 100644 --- a/.github/workflows/essentials.yml +++ b/.github/workflows/essentials.yml @@ -9,27 +9,27 @@ on: jobs: test: - name: Test + name: Quality checks & tests runs-on: ubuntu-latest strategy: matrix: rust: [stable] steps: - name: Rust install - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} - profile: minimal - override: true components: rustfmt, clippy - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - fetch-depth: ${{ github.event.pull_request.commits }} + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + # fetch-depth: ${{ github.event.pull_request.commits }} - name: Cache crates from crates.io - uses: actions/cache@v3 + uses: actions/cache@v4 continue-on-error: false with: path: | @@ -48,35 +48,44 @@ jobs: - name: Quality - convco check run: | git show-ref + echo Commit message: "$(git log -1 --pretty=%B)" curl -sSfLO https://github.com/convco/convco/releases/latest/download/convco-ubuntu.zip unzip convco-ubuntu.zip chmod +x convco - ./convco check + ./convco --version + ./convco check -c .convco rm convco - name: Quality - cargo deny check run: | - curl -sSfL https://github.com/EmbarkStudios/cargo-deny/releases/download/0.14.2/cargo-deny-0.14.2-x86_64-unknown-linux-musl.tar.gz | tar zx --no-anchored cargo-deny --strip-components=1 + curl -sSfL https://github.com/EmbarkStudios/cargo-deny/releases/download/0.16.1/cargo-deny-0.16.1-x86_64-unknown-linux-musl.tar.gz | tar zx --no-anchored cargo-deny --strip-components=1 chmod +x cargo-deny mv cargo-deny ~/.cargo/bin/ cargo deny check - - name: Install cargo check tools + - name: Quality - cargo audit check + run: | + curl -sSfL https://github.com/rustsec/rustsec/releases/download/cargo-audit%2Fv0.17.3/cargo-audit-x86_64-unknown-linux-musl-v0.17.3.tgz | tar zx --no-anchored cargo-audit --strip-components=1 + chmod +x cargo-audit + mv cargo-audit ~/.cargo/bin/ + rm -rf ~/.cargo/advisory-db/ + cargo audit --ignore RUSTSEC-2020-0071 # time-rs, but not used by chrono, see https://github.com/chronotope/chrono/issues/602 + + - name: Quality - cargo outdated timeout-minutes: 20 - if: ${{ matrix.rust == 'stable' }} run: | cargo install --locked cargo-outdated || true - # cargo install --locked cargo-udeps || true # needs nightly - cargo install --locked cargo-audit || true - cargo install --locked cargo-pants || true + rm -rf ~/.cargo/advisory-db + cargo outdated --exit-code 1 - - name: Check - if: ${{ matrix.rust == 'stable' }} + # - name: Quality - cargo udeps (needs nightly) + # run: | + # cargo install --locked cargo-udeps || true + # cargo udeps + + - name: Quality - cargo pants run: | - cargo outdated --exit-code 1 - # cargo udeps - rm -rf ~/.cargo/advisory-db - cargo audit --ignore RUSTSEC-2020-0071 # time-rs, but not used by chrono, see https://github.com/chronotope/chrono/issues/602 + cargo install --locked cargo-pants || true cargo pants - name: Build (dev) diff --git a/.github/workflows/large-scope.yml b/.github/workflows/large-scope.yml index a5c6027..eace811 100644 --- a/.github/workflows/large-scope.yml +++ b/.github/workflows/large-scope.yml @@ -12,22 +12,21 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rust: [1.50.0, beta, nightly] + # rust: [1.74.0, beta, nightly] + rust: [1.74.0, beta] steps: - name: Rust install - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} - profile: minimal - override: true components: rustfmt, clippy - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cache crates from crates.io - uses: actions/cache@v3 + uses: actions/cache@v4 continue-on-error: false with: path: | @@ -43,22 +42,46 @@ jobs: cargo fmt --all -- --check cargo clippy -- -D warnings - # - name: Install cargo check tools + # - name: Quality - convco check + # run: | + # git show-ref + # curl -sSfLO https://github.com/convco/convco/releases/latest/download/convco-ubuntu.zip + # unzip convco-ubuntu.zip + # chmod +x convco + # ./convco --version + # ./convco check -c .convco + # rm convco + + # - name: Quality - cargo deny check + # run: | + # curl -sSfL https://github.com/EmbarkStudios/cargo-deny/releases/download/0.12.2/cargo-deny-0.12.2-x86_64-unknown-linux-musl.tar.gz | tar zx --no-anchored cargo-deny --strip-components=1 + # chmod +x cargo-deny + # mv cargo-deny ~/.cargo/bin/ + # cargo deny check + + # - name: Quality - cargo audit check + # run: | + # curl -sSfL https://github.com/rustsec/rustsec/releases/download/cargo-audit%2Fv0.17.3/cargo-audit-x86_64-unknown-linux-musl-v0.17.3.tgz | tar zx --no-anchored cargo-audit --strip-components=1 + # chmod +x cargo-audit + # mv cargo-audit ~/.cargo/bin/ + # rm -rf ~/.cargo/advisory-db/ + # cargo audit --ignore RUSTSEC-2020-0071 # time-rs, but not used by chrono, see https://github.com/chronotope/chrono/issues/602 + + # - name: Quality - cargo outdated # timeout-minutes: 20 - # if: ${{ matrix.rust == 'stable' }} # run: | # cargo install --locked cargo-outdated || true - # # cargo install --locked cargo-udeps || true # needs nightly - # cargo install --locked cargo-audit || true - # cargo install --locked cargo-pants || true + # rm -rf ~/.cargo/advisory-db + # cargo outdated --exit-code 1 - # - name: Check - # if: ${{ matrix.rust == 'stable' }} + # - name: Quality - cargo udeps (needs nightly) # run: | - # cargo outdated --exit-code 1 - # # cargo udeps - # rm -rf ~/.cargo/advisory-db - # cargo audit --ignore RUSTSEC-2020-0071 # time-rs, but not used by chrono, see https://github.com/chronotope/chrono/issues/602 + # cargo install --locked cargo-udeps || true + # cargo udeps + + # - name: Quality - cargo pants + # run: | + # cargo install --locked cargo-pants || true # cargo pants - name: Build (dev) @@ -76,30 +99,31 @@ jobs: strategy: matrix: include: - - os: macos-latest + - os: macos-13 target: x86_64-apple-darwin type: unix + toolchain: stable - os: macos-latest target: aarch64-apple-darwin type: unix + toolchain: stable - os: windows-latest target: x86_64-pc-windows-msvc type: windows + toolchain: stable steps: - name: Rust install - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master with: - toolchain: stable - profile: minimal - override: true + toolchain: ${{ matrix.toolchain }} target: ${{ matrix.target }} components: rustfmt, clippy - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cache crates from crates.io - uses: actions/cache@v3 + uses: actions/cache@v4 continue-on-error: false with: path: | @@ -110,10 +134,13 @@ jobs: target/ key: '${{ runner.os }}-${{ matrix.target }}-cargo-stable-${{ hashFiles(''**/Cargo.lock'') }}' - - name: Lint - run: | - cargo fmt --all -- --check - cargo clippy -- -D warnings + # - name: Quality - cargo fmt + # run: | + # cargo fmt --all -- --check + + # - name: Quality - cargo clippy + # run: | + # cargo clippy -- -D warnings # - name: Quality - convco check # run: | @@ -121,9 +148,9 @@ jobs: # curl -sSfLO https://github.com/convco/convco/releases/latest/download/convco-ubuntu.zip # unzip convco-ubuntu.zip # chmod +x convco - # ./convco check + # ./convco --version + # ./convco check -c .convco # rm convco - # shell: bash # - name: Quality - cargo deny check # run: | @@ -131,25 +158,31 @@ jobs: # chmod +x cargo-deny # mv cargo-deny ~/.cargo/bin/ # cargo deny check - # shell: bash - - name: Install cargo check tools - timeout-minutes: 20 - run: | - cargo install --locked cargo-outdated || true - # cargo install --locked cargo-udeps || true # needs nightly - cargo install --locked cargo-audit || true - cargo install --locked cargo-pants || true - shell: bash + # - name: Quality - cargo audit check + # run: | + # curl -sSfL https://github.com/rustsec/rustsec/releases/download/cargo-audit%2Fv0.17.3/cargo-audit-x86_64-unknown-linux-musl-v0.17.3.tgz | tar zx --no-anchored cargo-audit --strip-components=1 + # chmod +x cargo-audit + # mv cargo-audit ~/.cargo/bin/ + # rm -rf ~/.cargo/advisory-db/ + # cargo audit --ignore RUSTSEC-2020-0071 # time-rs, but not used by chrono, see https://github.com/chronotope/chrono/issues/602 - - name: Check - run: | - cargo outdated --exit-code 1 - # cargo udeps - rm -rf ~/.cargo/advisory-db - cargo audit --ignore RUSTSEC-2020-0071 # time-rs, but not used by chrono, see https://github.com/chronotope/chrono/issues/602 - cargo pants - shell: bash + # - name: Quality - cargo outdated + # timeout-minutes: 20 + # run: | + # cargo install --locked cargo-outdated || true + # rm -rf ~/.cargo/advisory-db + # cargo outdated --exit-code 1 + + # - name: Quality - cargo udeps (needs nightly) + # run: | + # cargo install --locked cargo-udeps || true + # cargo udeps + + # - name: Quality - cargo pants + # run: | + # cargo install --locked cargo-pants || true + # cargo pants - name: Build (dev) run: cargo build --all-features diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..017be21 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +name: Release +on: + push: + tags: + - 'v*' + +jobs: + release: + name: Create a GitHub Release + # if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: checkout + uses: actions/checkout@v4 + with: + # convco needs all history to create the changelog + fetch-depth: 0 + + - name: Extract version + id: extract-version + run: | + echo "tag-name=${GITHUB_REF#refs/tags/}" >> ${GITHUB_OUTPUT} + + - name: Download convco + run: | + git show-ref + curl -sSfLO https://github.com/convco/convco/releases/latest/download/convco-ubuntu.zip + unzip convco-ubuntu.zip + chmod +x convco + + - name: Use convco to create the changelog + run: | + ./convco changelog -c .convco --max-versions 1 --include-hidden-sections > CHANGELOG.md + rm convco convco-ubuntu.zip + + - uses: ncipollo/release-action@v1 + with: + artifacts: "*.zip,*.tar.xz" + bodyFile: "CHANGELOG.md" + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index e088d32..d934fbc 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,14 @@ [![crate](https://img.shields.io/crates/v/si-scale.svg)](https://crates.io/crates/si-scale) [![documentation](https://docs.rs/si-scale/badge.svg)](https://docs.rs/si-scale) -[![minimum rustc 1.8](https://img.shields.io/badge/rustc-1.50+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html) +[![minimum rustc 1.74](https://img.shields.io/badge/rustc-1.74+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html) [![build status](https://github.com/graelo/si-scale/actions/workflows/essentials.yml/badge.svg)](https://github.com/graelo/si-scale/actions/workflows/essentials.yml) Format value with units according to SI ([système international d’unités](https://en.wikipedia.org/wiki/International_System_of_Units)). -Version requirement: _rustc 1.50+_ +Version requirement: _rustc 1.74+_ ```toml [dependencies] diff --git a/ci/test_full.sh b/ci/test_full.sh index 78c4a27..6670c47 100755 --- a/ci/test_full.sh +++ b/ci/test_full.sh @@ -3,7 +3,7 @@ set -e CRATE=si-scale -MSRV=1.50 +MSRV=1.74 get_rust_version() { local array=($(rustc --version)); @@ -28,7 +28,7 @@ if ! check_version $MSRV ; then fi FEATURES=() -# check_version 1.27 && FEATURES+=(libm) +# check_version 1.74 && FEATURES+=(libm) echo "Testing supported features: ${FEATURES[*]}" set -x diff --git a/deny.toml b/deny.toml index 1af1c9d..0949f3c 100644 --- a/deny.toml +++ b/deny.toml @@ -35,16 +35,6 @@ targets = [ db-path = "~/.cargo/advisory-db" # 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" # A list of advisory IDs to ignore. Note that ignored advisories will still # output a note when they are encountered. ignore = [ @@ -70,8 +60,6 @@ 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)]. @@ -80,26 +68,6 @@ allow = [ "Apache-2.0", #"Apache-2.0 WITH LLVM-exception", ] -# 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", -] -# Lint level for licenses considered copyleft -copyleft = "warn" -# 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. diff --git a/src/lib.rs b/src/lib.rs index 002b96f..82963ca 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ //! Format value with units according to SI ([système international d'unités](https://en.wikipedia.org/wiki/International_System_of_Units)). //! -//! Version requirement: _rustc 1.50+_ +//! Version requirement: _rustc 1.74+_ //! //! ```toml //! [dependencies] @@ -21,11 +21,11 @@ //! //! - this crate yields more terse code at the call sites //! - it gives you more control over the output. As shown later in this page, -//! you can extend it pretty easily to handle throughput, etc. (seriously, see -//! below) +//! you can extend it pretty easily to handle throughput, etc. (seriously, see +//! below) //! - but it only operates on numbers, so it does not prevent you from using a -//! function to print meters on a duration value (which human-repr does -//! brilliantly). +//! function to print meters on a duration value (which human-repr does +//! brilliantly). //! //! ## Getting started //! @@ -213,7 +213,7 @@ //! - the mantissa, //! - the SI unit prefix (such as "kilo", "Mega", etc), //! - and the base which represents the cases where "1 k" means 1000 (most -//! common) and the cases where "1 k" means 1024 (for kiB, MiB, etc). +//! common) and the cases where "1 k" means 1024 (for kiB, MiB, etc). //! //! This crate provides 2 APIs: a low-level API, and a high-level API for //! convenience. @@ -221,9 +221,9 @@ //! For the low-level API, the typical use case is //! //! - first parse a number into a [`Value`](`crate::value::Value`). For doing -//! this, you have to specify the base, and maybe some constraint on the SI -//! scales. See [`Value::new()`](`crate::value::Value::new()`) and -//! [`Value::new_with()`](`crate::value::Value::new_with()`) +//! this, you have to specify the base, and maybe some constraint on the SI +//! scales. See [`Value::new()`](`crate::value::Value::new()`) and +//! [`Value::new_with()`](`crate::value::Value::new_with()`) //! //! - then display the `Value` either by yourself formatting the mantissa //! and prefix (implements the `fmt::Display` trait), or using the provided diff --git a/src/prefix.rs b/src/prefix.rs index e3aaeb4..deb7f9d 100644 --- a/src/prefix.rs +++ b/src/prefix.rs @@ -93,10 +93,10 @@ impl Prefix { /// For instance, /// /// - if self is `-12` ("pico"), then `exponent()` returns `-12` so that - /// `Base::B1000.pow(-12)` returns the scaling factor `1e-12`. + /// `Base::B1000.pow(-12)` returns the scaling factor `1e-12`. /// /// - if self is `3` ("kilo"), then `exponent()` returns `3` so that - /// `Base::B1024.pow(3)` returns the scaling factor `1024`. + /// `Base::B1024.pow(3)` returns the scaling factor `1024`. pub fn exponent(&self) -> i32 { *self as i32 }