From 75dfec29cedbd177b4834ae294383f149f356960 Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Sun, 4 Sep 2022 12:23:16 +0200 Subject: [PATCH 01/15] Fix Markdown Formatting --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 27a8873..5f48f3b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ > **Python PEP-440 Version Parsing** -This package allows for parsing Python PEP-440 version numbers and comparisons between PEP-440 Versions +This package allows for parsing Python PEP-440 version numbers and comparisons +between PEP-440 Versions ## Usage @@ -22,7 +23,6 @@ let b = PackageVersion::new("v1.0a2.dev457").unwrap(); assert_eq!(a < b, true); ``` - ## Contribution For now Contributions will be quite loose. From ab433a52a164dcc1e38f9d7fccdb3a5d378260cf Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Sun, 4 Sep 2022 12:43:55 +0200 Subject: [PATCH 02/15] Created Github Actions (#4) resolves #4 --- .github/workflows/checks.yml | 106 ++++++++++++++++++++++++++++++++ .github/workflows/md_checks.yml | 16 +++++ 2 files changed, 122 insertions(+) create mode 100644 .github/workflows/checks.yml create mode 100644 .github/workflows/md_checks.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..3285193 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,106 @@ +name: Checks + +on: [push, pull_request] + +env: + CARGO_TERM_COLOR: always + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run cargo check + uses: actions-rs/cargo@v1 + with: + command: check + + test: + name: Test Suite + + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + toolchain: [stable] + + runs-on: ${{ matrix.os }} + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.toolchain }} + + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run cargo test on ${{ matrix.os }} + uses: actions-rs/cargo@v1 + with: + command: test + + lints: + name: Lints + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: rustfmt, clippy + + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - name: Run cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings \ No newline at end of file diff --git a/.github/workflows/md_checks.yml b/.github/workflows/md_checks.yml new file mode 100644 index 0000000..a99d0ef --- /dev/null +++ b/.github/workflows/md_checks.yml @@ -0,0 +1,16 @@ +name: MD-Checks + +on: [push, pull_request] + +jobs: + lint-changelog: + name: Lint changelog file + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Markdown Linting Action + uses: avto-dev/markdown-lint@v1.5.0 + with: + args: "*.md" From 4363928360f56e35a7d399314b36abf41fdde15c Mon Sep 17 00:00:00 2001 From: Jan Bronicki Date: Sun, 4 Sep 2022 15:02:32 +0200 Subject: [PATCH 03/15] Enhance README documentation and add CI jobs (#10) * Add more additional info and status badges to the README. * Add CI jobs covering `ubuntu`, `windows`, `macos` with `stable`, `beta`, `nightly` toolchains, and some other misc CI jobs. --- .github/workflows/build.yml | 36 ++++++ .github/workflows/checks.yml | 106 ---------------- .github/workflows/docs.yml | 18 +++ .github/workflows/format.yml | 19 +++ .github/workflows/lint.yml | 31 +++++ .github/workflows/md_checks.yml | 16 --- .github/workflows/package.yml | 36 ++++++ .github/workflows/tests.yml | 28 +++++ .rustfmt.toml | 1 + CHANGELOG.md | 12 +- Cargo.toml | 11 +- LICENSE | 21 ++++ README.md | 15 ++- deny.toml | 206 ++++++++++++++++++++++++++++++++ src/lib.rs | 3 +- 15 files changed, 422 insertions(+), 137 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/checks.yml create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/format.yml create mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/md_checks.yml create mode 100644 .github/workflows/package.yml create mode 100644 .github/workflows/tests.yml create mode 100644 .rustfmt.toml create mode 100644 LICENSE create mode 100644 deny.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..508cad4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: ๐Ÿ”จ Build + +on: + pull_request: + push: + branches: ["main", "develop"] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + toolchain: [stable, beta, nightly] + name: ๐Ÿ”จ Build release + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: Install latest ${{ matrix.toolchain }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Build release + run: cargo build --release + diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml deleted file mode 100644 index 3285193..0000000 --- a/.github/workflows/checks.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: Checks - -on: [push, pull_request] - -env: - CARGO_TERM_COLOR: always - -jobs: - check: - name: Check - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - name: Run cargo check - uses: actions-rs/cargo@v1 - with: - command: check - - test: - name: Test Suite - - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - toolchain: [stable] - - runs-on: ${{ matrix.os }} - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.toolchain }} - - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - name: Run cargo test on ${{ matrix.os }} - uses: actions-rs/cargo@v1 - with: - command: test - - lints: - name: Lints - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - components: rustfmt, clippy - - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - name: Run cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - - name: Run cargo clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings \ No newline at end of file diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..29ddbbb --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,18 @@ +name: ๐Ÿ“„ Build docs + +on: + pull_request: + push: + branches: ["main", "develop"] + +env: + CARGO_TERM_COLOR: always + +jobs: + docs: + name: ๐Ÿ“„ Build docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build docs + run: cargo doc --verbose diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..5bb5c0e --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,19 @@ +name: ๐Ÿ‘” Check formatting + +on: + pull_request: + push: + branches: ["main", "develop"] + +env: + CARGO_TERM_COLOR: always + +jobs: + check_format: + name: ๐Ÿ‘” Check formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check Formatting + run: cargo fmt -- --verbose --check --color auto + diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..89b6c2e --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,31 @@ +name: ๐Ÿ–‹ Check linting + +on: + pull_request: + push: + branches: ["main", "develop"] + +env: + CARGO_TERM_COLOR: always + +jobs: + check_lint_rust: + name: ๐Ÿ–‹ Check linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check linting + run: | + rustup component add clippy + set env RUSTFLAGS="-Dwarnings" + cargo clippy --workspace -- -D warnings + check_lint_markdown: + name: ๐Ÿ–‹ Check markdown files + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Markdown Linting Action + uses: avto-dev/markdown-lint@v1.5.0 + with: + args: "*.md" diff --git a/.github/workflows/md_checks.yml b/.github/workflows/md_checks.yml deleted file mode 100644 index a99d0ef..0000000 --- a/.github/workflows/md_checks.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: MD-Checks - -on: [push, pull_request] - -jobs: - lint-changelog: - name: Lint changelog file - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Markdown Linting Action - uses: avto-dev/markdown-lint@v1.5.0 - with: - args: "*.md" diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 0000000..f1b6413 --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,36 @@ +name: ๐Ÿ“ฆ Package + +on: + pull_request: + push: + branches: ["main", "develop"] + +env: + CARGO_TERM_COLOR: always + +jobs: + license: + name: ๐Ÿซ License check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check license + run: | + cargo install cargo-deny + cargo deny check + + cargo_check: + name: ๐Ÿ“ฆ Check package integrity + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check package integrity + run: cargo package --verbose + + publish_dry_run: + name: ๐Ÿ“ข Publish dry-run + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Publish dry run + run: cargo publish --dry-run --verbose diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..63a7372 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,28 @@ +name: ๐Ÿงช Tests + +on: + pull_request: + push: + branches: ["main", "develop"] + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + toolchain: [stable, beta, nightly] + name: ๐Ÿงช Run tests + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: Install latest ${{ matrix.toolchain }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + - uses: actions/checkout@v2 + - name: Run tests + run: cargo test --verbose + diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..1460aaa --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1 @@ +max_width = 88 diff --git a/CHANGELOG.md b/CHANGELOG.md index 76a9e15..ae4155c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,17 @@ # Changelog -All notable changes to this project will be documented in this file. + + +## Unreleased ## [0.0.1] - 2022-09-03 ### Added -- Created Baseline Project +* Created Baseline Project diff --git a/Cargo.toml b/Cargo.toml index c6ac447..f3baa7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,13 @@ [package] name = "pyver" -description = "Python PEP-440 Version Parsing" -authors = ["Allstreamer "] +description = "Python PEP-440 Version Parser" +authors = [ + "Allstreamer ", + "Jan Bronicki ", +] license = "MIT" version = "0.1.0" -keywords = ["versions", "python"] +keywords = ["versions", "python", "parser", "semver", "pep-440"] readme = "README.md" edition = "2021" repository = "https://github.com/Allstreamer/pyver" @@ -17,4 +20,4 @@ serde = { version = "1", features = ["derive"] } regex = { version = "1" } lazy_static = { version = "1.4.0" } pomsky-macro = { version = "0.6.0" } -derivative = { version = "2.2.0" } \ No newline at end of file +derivative = { version = "2.2.0" } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4d20996 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 + +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. diff --git a/README.md b/README.md index 5f48f3b..bc349bc 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,20 @@ -# PyVer (WIP) +# PyVer -[![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](LICENSE-MIT) + +[![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](LICENSE-MIT) [![๐Ÿงช Tests](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml) [![๐Ÿ–‹ Check linting](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml) [![๐Ÿ”จ Build](https://github.com/Allstreamer/pyver/actions/workflows/build.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/build.yml) [![๐Ÿ“ฆ Package](https://github.com/Allstreamer/pyver/actions/workflows/package.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/package.yml) [![๐Ÿ“„ Build docs](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml) [![๐Ÿ‘” Check formatting](https://github.com/Allstreamer/pyver/actions/workflows/format.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/format.yml) + -> **Python PEP-440 Version Parsing** +> **Python PEP-440 Version Parser** -This package allows for parsing Python PEP-440 version numbers and comparisons -between PEP-440 Versions +This package allows for parsing Python [PEP-440](https://peps.python.org/pep-0440/) +version numbers and for comparisons between +[PEP-440](https://peps.python.org/pep-0440/) version numbers. ## Usage ```Toml [dependencies] -pyver = "0.0.1" +pyver = "0" ``` ```Rust diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..498290c --- /dev/null +++ b/deny.toml @@ -0,0 +1,206 @@ +# This template contains all of the possible sections and their default values + +# Note that all fields that take a lint level have these possible values: +# * deny - An error will be produced and the check will fail +# * warn - A warning will be produced, but the check will not fail +# * allow - No warning or error will be produced, though in some cases a note +# will be + +# The values provided in this template are the default values that will be used +# when any section or field is not specified in your own configuration + +# 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 +# dependency, such as, for example, the `nix` crate only being used via the +# `target_family = "unix"` configuration, that only having windows targets in +# this list would mean the nix crate, as well as any of its exclusive +# dependencies not shared by any other crates, would be ignored, as the target +# list here is effectively saying which targets you are building for. +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" }, + # 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. + #{ triple = "wasm32-unknown-unknown", features = ["atomics"] }, +] + +# This section is considered when running `cargo deny check advisories` +# 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 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 = [ + #"RUSTSEC-0000-0000", +] +# 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 = + +# This section is considered when running `cargo deny check licenses` +# 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 = "warn" +# 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", + "Apache-2.0", + "Apache-2.0 WITH LLVM-exception", + "Unicode-DFS-2016", +] +# 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. +# [possible values: any between 0.0 and 1.0]. +confidence-threshold = 0.8 +# Allow 1 or more licenses on a per-crate basis, so that particular licenses +# aren't accepted for every possible crate as with the normal allow list +exceptions = [ + # Each entry is the crate and version constraint, and its specific allow + # list + #{ allow = ["Zlib"], name = "adler32", version = "*" }, +] + +# 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 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 +# the license expression. If the contents match, the clarification will be used +# when running the license check, otherwise the clarification will be ignored +# 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 } +#] + +[licenses.private] +# If true, ignores workspace crates that aren't published, or are only +# published to private registries. +# To see how to mark a crate as unpublished (to the official registry), +# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field. +ignore = false +# One or more private registries that you might publish crates to, if a crate +# is only published to private registries, and ignore is true, the crate will +# not have its license(s) checked +registries = [ + #"https://sekretz.com/registry +] + +# This section is considered when running `cargo deny check bans`. +# More documentation about the 'bans' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html +[bans] +# Lint level for when multiple versions of the same crate are detected +multiple-versions = "warn" +# Lint level for when a crate version requirement is `*` +wildcards = "allow" +# The graph highlighting used when creating dotgraphs for crates +# with multiple versions +# * lowest-version - The path to the lowest versioned duplicate is highlighted +# * simplest-path - The path to the version with the fewest edges is highlighted +# * all - Both lowest-version and simplest-path are used +highlight = "all" +# List of crates that are allowed. Use with care! +allow = [ + #{ name = "ansi_term", version = "=0.11.0" }, +] +# 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" }, + # + # 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 = [] }, +] +# Certain crates/versions that will be skipped when doing duplicate detection. +skip = [ + #{ name = "ansi_term", version = "=0.11.0" }, +] +# 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 }, +] + +# This section is considered when running `cargo deny check sources`. +# More documentation about the 'sources' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html +[sources] +# Lint level for what to happen when a crate from a crate registry that is not +# in the allow list is encountered +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 = "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"] +# List of URLs for allowed Git repositories +allow-git = [] + +[sources.allow-org] +# 1 or more github.com organizations to allow git sources for +github = [""] +# 1 or more gitlab.com organizations to allow git sources for +gitlab = [""] +# 1 or more bitbucket.org organizations to allow git sources for +bitbucket = [""] diff --git a/src/lib.rs b/src/lib.rs index a32f2b0..82f1d60 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,7 +162,8 @@ impl PackageVersion { None => None, }; - let local: Option = version_match.name("local").map(|v| v.as_str().to_string()); + let local: Option = + version_match.name("local").map(|v| v.as_str().to_string()); Ok(Self { original: version.to_string(), From 293ad297d473e6980335ab48178f59121814186c Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Sun, 4 Sep 2022 16:36:35 +0200 Subject: [PATCH 04/15] [`#2`] Moved tests to their respective files (#11) closes #2 --- src/ids/dev_id.rs | 11 +++++ src/ids/post_id.rs | 28 +++++++++++ src/ids/pre_id.rs | 21 +++++++++ src/ids/release_id.rs | 22 +++++++++ src/lib.rs | 105 ++---------------------------------------- 5 files changed, 87 insertions(+), 100 deletions(-) diff --git a/src/ids/dev_id.rs b/src/ids/dev_id.rs index 0092069..a16dbeb 100644 --- a/src/ids/dev_id.rs +++ b/src/ids/dev_id.rs @@ -6,3 +6,14 @@ use serde::{Deserialize, Serialize}; pub struct DevHead { pub dev_num: Option, } + +#[cfg(test)] +mod tests { + use super::DevHead; + + #[test] + fn test_dev_ordering() { + assert!(DevHead { dev_num: Some(0) } > DevHead { dev_num: None }); + assert!(DevHead { dev_num: Some(1) } > DevHead { dev_num: Some(0) }); + } +} diff --git a/src/ids/post_id.rs b/src/ids/post_id.rs index 9e6a691..1c5c04a 100644 --- a/src/ids/post_id.rs +++ b/src/ids/post_id.rs @@ -40,3 +40,31 @@ impl PartialOrd for PostHeader { } } } + +#[cfg(test)] +mod tests { + use super::PostHead; + use super::PostHeader; + + #[test] + fn test_post_ordering() { + assert!( + PostHeader { + post_head: Some(PostHead::Post), + post_num: Some(0), + } > PostHeader { + post_head: Some(PostHead::Post), + post_num: None, + } + ); + assert!( + PostHeader { + post_head: Some(PostHead::Post), + post_num: Some(1), + } > PostHeader { + post_head: Some(PostHead::Post), + post_num: Some(0), + } + ); + } +} diff --git a/src/ids/pre_id.rs b/src/ids/pre_id.rs index c2f8fff..63fb122 100644 --- a/src/ids/pre_id.rs +++ b/src/ids/pre_id.rs @@ -33,3 +33,24 @@ pub enum PreHeader { /// ``` ReleaseCandidate(Option), } + +#[cfg(test)] +mod tests { + use super::PreHeader; + + #[test] + fn test_pre_ordering() { + assert!(PreHeader::ReleaseCandidate(None) > PreHeader::Preview(None)); + assert!(PreHeader::Preview(None) > PreHeader::Alpha(None)); + assert!(PreHeader::Alpha(None) > PreHeader::Beta(None)); + + assert!( + PreHeader::ReleaseCandidate(Some(2)) > PreHeader::ReleaseCandidate(Some(1)) + ); + assert!(PreHeader::Preview(Some(50)) > PreHeader::Preview(Some(3))); + assert!(PreHeader::Alpha(Some(504)) > PreHeader::Alpha(Some(0))); + assert!(PreHeader::Beta(Some(1234)) > PreHeader::Beta(Some(1))); + + assert!(PreHeader::ReleaseCandidate(Some(1)) > PreHeader::Beta(Some(45067885))); + } +} diff --git a/src/ids/release_id.rs b/src/ids/release_id.rs index 689b31d..c7e048a 100644 --- a/src/ids/release_id.rs +++ b/src/ids/release_id.rs @@ -8,3 +8,25 @@ pub struct ReleaseHeader { /// Minor release Such as new functionality pub minor: u32, } + +#[cfg(test)] +mod test { + use super::ReleaseHeader; + + #[test] + fn test_release_ordering() { + assert!( + ReleaseHeader { major: 1, minor: 0 } > ReleaseHeader { major: 0, minor: 0 } + ); + assert!( + ReleaseHeader { major: 1, minor: 1 } > ReleaseHeader { major: 1, minor: 0 } + ); + assert!( + ReleaseHeader { major: 2, minor: 1 } + > ReleaseHeader { + major: 1, + minor: 52, + } + ); + } +} diff --git a/src/lib.rs b/src/lib.rs index 82f1d60..4b9f761 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -185,113 +185,18 @@ impl fmt::Display for PackageVersion { #[cfg(test)] mod tests { - use std::fmt::Debug; - use crate::PackageVersion; - use anyhow::bail; use anyhow::Result; - use crate::DevHead; - use crate::PostHead; - use crate::PostHeader; - use crate::PreHeader; - use crate::ReleaseHeader; - - fn test_a_greater(a: T, b: T) -> Result<()> - where - T: PartialEq + PartialOrd + Debug, - { - if a <= b { - bail!( - "Failed Less Than or Equal Check for A: {:?} \n<=\n B: {:?}", - a, - b - ) - } - Ok(()) - } - #[test] fn test_pep440_ordering() -> Result<()> { - test_a_greater( + assert!( PackageVersion::new( "v1!1.0-preview-921.post-516.dev-241+yeah.this.is.the.problem.with.local.versions", - )?, - PackageVersion::new("1.0")?, - )?; - Ok(()) - } - - #[test] - fn test_release_ordering() -> Result<()> { - test_a_greater( - ReleaseHeader { major: 1, minor: 0 }, - ReleaseHeader { major: 0, minor: 0 }, - )?; - test_a_greater( - ReleaseHeader { major: 1, minor: 1 }, - ReleaseHeader { major: 1, minor: 0 }, - )?; - test_a_greater( - ReleaseHeader { major: 2, minor: 1 }, - ReleaseHeader { - major: 1, - minor: 52, - }, - )?; - Ok(()) - } - - #[test] - fn test_pre_ordering() -> Result<()> { - test_a_greater(PreHeader::ReleaseCandidate(None), PreHeader::Preview(None))?; - test_a_greater(PreHeader::Preview(None), PreHeader::Alpha(None))?; - test_a_greater(PreHeader::Alpha(None), PreHeader::Beta(None))?; - - test_a_greater( - PreHeader::ReleaseCandidate(Some(2)), - PreHeader::ReleaseCandidate(Some(1)), - )?; - test_a_greater(PreHeader::Preview(Some(50)), PreHeader::Preview(Some(3)))?; - test_a_greater(PreHeader::Alpha(Some(504)), PreHeader::Alpha(Some(0)))?; - test_a_greater(PreHeader::Beta(Some(1234)), PreHeader::Beta(Some(1)))?; - - test_a_greater( - PreHeader::ReleaseCandidate(Some(1)), - PreHeader::Beta(Some(45067885)), - )?; - Ok(()) - } - - #[test] - fn test_post_ordering() -> Result<()> { - test_a_greater( - PostHeader { - post_head: Some(PostHead::Post), - post_num: Some(0), - }, - PostHeader { - post_head: Some(PostHead::Post), - post_num: None, - }, - )?; - test_a_greater( - PostHeader { - post_head: Some(PostHead::Post), - post_num: Some(1), - }, - PostHeader { - post_head: Some(PostHead::Post), - post_num: Some(0), - }, - )?; - Ok(()) - } - - #[test] - fn test_dev_ordering() -> Result<()> { - test_a_greater(DevHead { dev_num: Some(0) }, DevHead { dev_num: None })?; - test_a_greater(DevHead { dev_num: Some(1) }, DevHead { dev_num: Some(0) })?; + )? + > + PackageVersion::new("1.0")? + ); Ok(()) } From dee1ea1b18851ef52ebab8b563963efe8d5d9bb8 Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Sun, 4 Sep 2022 17:08:59 +0200 Subject: [PATCH 05/15] [`#12`] Created check.yml (#14) - Created check.yml - Removed build.yml resolves #12 --- .github/workflows/{build.yml => check.yml} | 12 ++++++------ .github/workflows/tests.yml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) rename .github/workflows/{build.yml => check.yml} (81%) diff --git a/.github/workflows/build.yml b/.github/workflows/check.yml similarity index 81% rename from .github/workflows/build.yml rename to .github/workflows/check.yml index 508cad4..21f5c39 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/check.yml @@ -1,4 +1,4 @@ -name: ๐Ÿ”จ Build +name: ๐Ÿ”จ Cargo Check on: pull_request: @@ -9,12 +9,12 @@ env: CARGO_TERM_COLOR: always jobs: - build: + check: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - toolchain: [stable, beta, nightly] - name: ๐Ÿ”จ Build release + toolchain: [stable] + name: ๐Ÿ”จ Cargo Check runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -31,6 +31,6 @@ jobs: ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Build release - run: cargo build --release + - name: Cargo Check + run: cargo check --release diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 63a7372..6e83dca 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - toolchain: [stable, beta, nightly] + toolchain: [stable] name: ๐Ÿงช Run tests runs-on: ${{ matrix.os }} steps: From dc3e37561b706ff6564e3afb79a14a61e3b4250d Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Sun, 4 Sep 2022 20:23:17 +0200 Subject: [PATCH 06/15] [`#1`] Improve Rust Docs (#15) - Added more code examples - Added Descriptions for each identifier - Added Examples to the main file --- src/ids/dev_id.rs | 19 ++++++++++++-- src/ids/mod.rs | 2 +- src/ids/post_id.rs | 37 +++++++++++++++++++++++++++ src/ids/pre_id.rs | 12 ++++----- src/lib.rs | 64 ++++++++++++++++++++++++++++++++++------------ src/validator.rs | 2 +- 6 files changed, 110 insertions(+), 26 deletions(-) diff --git a/src/ids/dev_id.rs b/src/ids/dev_id.rs index a16dbeb..f12a167 100644 --- a/src/ids/dev_id.rs +++ b/src/ids/dev_id.rs @@ -1,7 +1,22 @@ -//! # `PEP-440` Developmental release identifier - use serde::{Deserialize, Serialize}; +/// # `PEP-440` Developmental release identifier +/// This identifier is used to mark a developmental release +/// +/// Examples of versions that use this struct: +/// - `1.0.dev456` +/// - `1.0rc1.dev1` +/// +/// ## Example Usage +/// ``` +/// use pyver::ids::DevHead; +/// +/// assert!( +/// DevHead { dev_num: Some(0) } +/// > +/// DevHead { dev_num: None } +/// ); +/// ``` #[derive(Debug, Serialize, Deserialize, Eq, PartialEq, PartialOrd)] pub struct DevHead { pub dev_num: Option, diff --git a/src/ids/mod.rs b/src/ids/mod.rs index 78e2589..0d9a9e6 100644 --- a/src/ids/mod.rs +++ b/src/ids/mod.rs @@ -1,5 +1,5 @@ //! # Identifiers -//! Importing +//! Importing Example //! ``` //! use pyver::ids::{PreHeader, PostHeader, PostHead, DevHead, ReleaseHeader}; //! ``` diff --git a/src/ids/post_id.rs b/src/ids/post_id.rs index 1c5c04a..4c06a96 100644 --- a/src/ids/post_id.rs +++ b/src/ids/post_id.rs @@ -2,6 +2,27 @@ use serde::{Deserialize, Serialize}; use std::cmp::Ordering; /// # `PEP-440` Post-Release identifier +/// This identifier is used to mark a Post Release/Revision Version +/// +/// Examples of versions that use this struct: +/// - `1.0.post456` +/// - `1.0rev` +/// +/// ## Example Usage +/// ``` +/// use pyver::ids::PostHeader; +/// use pyver::ids::PostHead; +/// +/// assert!( +/// PostHeader { +/// post_head: Some(PostHead::Post), +/// post_num: Some(0), +/// } > PostHeader { +/// post_head: Some(PostHead::Post), +/// post_num: None, +/// } +/// ); +/// ``` #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] pub struct PostHeader { pub post_head: Option, @@ -9,9 +30,25 @@ pub struct PostHeader { } /// `PEP-440` Post-Release Identifier Keyword +/// This is a helper enum to tack whether it's a Revision or +/// a Post-Release +/// +/// Examples of versions that use this enum: +/// - `1.0.post456` +/// - `1.0rev` #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] pub enum PostHead { + /// ``` + /// use pyver::ids::PostHead; + /// + /// PostHead::Post; + /// ``` Post, + /// ``` + /// use pyver::ids::PostHead; + /// + /// PostHead::Rev; + /// ``` Rev, } diff --git a/src/ids/pre_id.rs b/src/ids/pre_id.rs index 63fb122..b8f78aa 100644 --- a/src/ids/pre_id.rs +++ b/src/ids/pre_id.rs @@ -1,33 +1,33 @@ -//! # `PEP-440` Pre-Release identifier - use serde::{Deserialize, Serialize}; +/// # `PEP-440` Pre-Release identifier +/// This identifier is used to mark a Pre-Release version #[derive(Debug, Serialize, Deserialize, Eq, PartialEq, PartialOrd)] pub enum PreHeader { /// Present in versions like 1.1beta1 or 1.0b1 both are represented the same way /// ``` - ///# use pyver::ids::PreHeader; + /// use pyver::ids::PreHeader; /// /// PreHeader::Beta(Some(1)); /// ``` Beta(Option), /// Present in versions like 1.0alpha2 or 1.0a2 both are represented the same way /// ``` - ///# use pyver::ids::PreHeader; + /// use pyver::ids::PreHeader; /// /// PreHeader::Alpha(Some(2)); /// ``` Alpha(Option), /// Present in versions like 1.1pre3 /// ``` - ///# use pyver::ids::PreHeader; + /// use pyver::ids::PreHeader; /// /// PreHeader::Preview(Some(3)); /// ``` Preview(Option), /// Present in versions like 1.1-rc-4 or 1.1c-4 /// ``` - ///# use pyver::ids::PreHeader; + /// use pyver::ids::PreHeader; /// /// PreHeader::ReleaseCandidate(Some(4)); /// ``` diff --git a/src/lib.rs b/src/lib.rs index 4b9f761..2ced73d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,37 @@ -//! # Handling of `PEP-440` -//! -//! This library implements Pythons Package versioning system. -//! Read more at +/*! +# Handling of `PEP-440` +This library implements Pythons Package versioning system. +Read more at + +# Usage +The `pyver` crate is available on [crates.io](https://crates.io/crates/pyver), +you can include it in your project by adding the following to your `Cargo.toml`. +```toml +[dependencies] +pyver = "0.1" +``` +# Example +The following example shows how to parse a package version and +how to compare them +``` +use pyver::PackageVersion; + +let a = PackageVersion::new("v1.0a2.dev456").unwrap(); +let b = PackageVersion::new("v1.1a2.dev457").unwrap(); + +assert!(a < b); +``` + +If you want to verify single version strings do +``` +use pyver::validate_440_version; + +assert!( + validate_440_version("1.0").is_ok() +); +``` +*/ use anyhow::Result; use serde::{Deserialize, Serialize}; use std::fmt; @@ -13,16 +42,15 @@ extern crate derivative; mod validator; pub use validator::validate_440_version; -/// Make Identifiers module available for lib user +/// Identifiers (i.e. the components of a version string) pub mod ids; use ids::{DevHead, PostHead, PostHeader, PreHeader, ReleaseHeader}; /// `PEP-440` Compliant versioning system /// -/// This struct is sorted so that PartialOrd -/// correctly interprets priority -/// -/// Lower == More important +//# This struct is sorted so that PartialOrd +//# correctly interprets priority +//# Lower == More important /// /// # Example Usage /// ``` @@ -32,10 +60,14 @@ use ids::{DevHead, PostHead, PostHeader, PreHeader, ReleaseHeader}; #[derive(Derivative, Debug, Serialize, Deserialize)] #[derivative(PartialOrd, PartialEq)] pub struct PackageVersion { + /// ## Original String + /// Just holds the original string passed in when creating + /// the `PackageVersion` as some formating data is lost + /// when parsing the string #[derivative(PartialOrd = "ignore", PartialEq = "ignore")] pub original: String, - /// # `PEP-440` Local version identifier + /// ## `PEP-440` Local version identifier /// Local version sorting will have to be it's own issue /// since there are no limits to what a local version can be /// @@ -43,26 +75,26 @@ pub struct PackageVersion { /// `[a-z0-9]+(?:(?:[\-_.][a-z0-9]+)+)?` /// /// Here in Rulex: - /// ```ignore + /// ```toml /// ['a'-'z' '0'-'9']+ /// ((["-" "_" "."] ['a'-'z' '0'-'9']+)+)? /// ``` #[derivative(PartialOrd = "ignore", PartialEq = "ignore")] pub local: Option, - /// # `PEP-440` Developmental release identifier + /// ## `PEP-440` Developmental release identifier pub dev: Option, - /// # `PEP-440` Post-Release identifier + /// ## `PEP-440` Post-Release identifier pub post: Option, - /// # `PEP-440` Pre-Release identifier + /// ## `PEP-440` Pre-Release identifier pub pre: Option, - /// # `PEP-440` Release number + /// ## `PEP-440` Release number pub release: ReleaseHeader, - /// # `PEP-440` Version-Epoch + /// ## `PEP-440` Version-Epoch pub epoch: Option, } diff --git a/src/validator.rs b/src/validator.rs index c151fd0..a634a94 100644 --- a/src/validator.rs +++ b/src/validator.rs @@ -3,7 +3,7 @@ use lazy_static::lazy_static; use pomsky_macro::pomsky; use regex::Captures; -/// Utility Function for Checking if a PEP-440 Version String is valid +/// Utility Function for Checking if a `PEP-440` Version String is valid /// and getting it's groups /// /// # Example Usage From 885c6c1d6683fd6abe3e8f762c957f0403b3fc81 Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Sun, 4 Sep 2022 21:36:57 +0200 Subject: [PATCH 07/15] Add more Caching (#18) resolves #17 --- .github/workflows/docs.yml | 9 +++++++++ .github/workflows/format.yml | 9 +++++++++ .github/workflows/lint.yml | 9 +++++++++ .github/workflows/package.yml | 9 +++++++++ .github/workflows/tests.yml | 9 +++++++++ 5 files changed, 45 insertions(+) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 29ddbbb..20cfcf0 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,6 +13,15 @@ jobs: name: ๐Ÿ“„ Build docs runs-on: ubuntu-latest steps: + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - uses: actions/checkout@v2 - name: Build docs run: cargo doc --verbose diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 5bb5c0e..b578bab 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -13,6 +13,15 @@ jobs: name: ๐Ÿ‘” Check formatting runs-on: ubuntu-latest steps: + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - uses: actions/checkout@v2 - name: Check Formatting run: cargo fmt -- --verbose --check --color auto diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 89b6c2e..9eeedb3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,6 +13,15 @@ jobs: name: ๐Ÿ–‹ Check linting runs-on: ubuntu-latest steps: + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - uses: actions/checkout@v2 - name: Check linting run: | diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index f1b6413..c8cb8cf 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -14,6 +14,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Check license run: | cargo install cargo-deny diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6e83dca..e62c4a4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,6 +22,15 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: ${{ matrix.toolchain }} + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - uses: actions/checkout@v2 - name: Run tests run: cargo test --verbose From 261ad876691d616d66a1b0532bc8c332630699a7 Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Sun, 4 Sep 2022 21:51:00 +0200 Subject: [PATCH 08/15] Updated Licence to match github template (#19) --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 4d20996..b6b23e9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 +Copyright (c) 2022 Allstreamer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From d0bb8e5d52a15599cd098a0780dfc5b5e3202779 Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Mon, 5 Sep 2022 09:17:16 +0200 Subject: [PATCH 09/15] [`#13`] Change Licence Badge (#20) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc349bc..273ce30 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # PyVer -[![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](LICENSE-MIT) [![๐Ÿงช Tests](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml) [![๐Ÿ–‹ Check linting](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml) [![๐Ÿ”จ Build](https://github.com/Allstreamer/pyver/actions/workflows/build.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/build.yml) [![๐Ÿ“ฆ Package](https://github.com/Allstreamer/pyver/actions/workflows/package.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/package.yml) [![๐Ÿ“„ Build docs](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml) [![๐Ÿ‘” Check formatting](https://github.com/Allstreamer/pyver/actions/workflows/format.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/format.yml) +![GitHub](https://img.shields.io/github/license/Allstreamer/pyver) [![๐Ÿงช Tests](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml) [![๐Ÿ–‹ Check linting](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml) [![๐Ÿ”จ Build](https://github.com/Allstreamer/pyver/actions/workflows/build.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/build.yml) [![๐Ÿ“ฆ Package](https://github.com/Allstreamer/pyver/actions/workflows/package.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/package.yml) [![๐Ÿ“„ Build docs](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml) [![๐Ÿ‘” Check formatting](https://github.com/Allstreamer/pyver/actions/workflows/format.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/format.yml) > **Python PEP-440 Version Parser** From c925568fb473a503bd85d67c1bfe70aa92818922 Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Mon, 5 Sep 2022 09:48:35 +0200 Subject: [PATCH 10/15] [`#16`] Moved PackageVersion to version.rs (#21) - Moved PackageVersion to version.rs - Fixed some doc stuff --- src/lib.rs | 267 ++----------------------------------------------- src/version.rs | 262 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 268 insertions(+), 261 deletions(-) create mode 100644 src/version.rs diff --git a/src/lib.rs b/src/lib.rs index 2ced73d..805c93d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ /*! # Handling of `PEP-440` -This library implements Pythons Package versioning system. +This library implements Python's Package versioning system. Read more at @@ -32,273 +32,18 @@ assert!( ); ``` */ -use anyhow::Result; -use serde::{Deserialize, Serialize}; -use std::fmt; #[macro_use] extern crate derivative; mod validator; +// Expose validate_440_version function pub use validator::validate_440_version; /// Identifiers (i.e. the components of a version string) +// Expose Ids Module pub mod ids; -use ids::{DevHead, PostHead, PostHeader, PreHeader, ReleaseHeader}; -/// `PEP-440` Compliant versioning system -/// -//# This struct is sorted so that PartialOrd -//# correctly interprets priority -//# Lower == More important -/// -/// # Example Usage -/// ``` -///# use pyver::PackageVersion; -/// let _ = PackageVersion::new("v1.0"); -/// ``` -#[derive(Derivative, Debug, Serialize, Deserialize)] -#[derivative(PartialOrd, PartialEq)] -pub struct PackageVersion { - /// ## Original String - /// Just holds the original string passed in when creating - /// the `PackageVersion` as some formating data is lost - /// when parsing the string - #[derivative(PartialOrd = "ignore", PartialEq = "ignore")] - pub original: String, - - /// ## `PEP-440` Local version identifier - /// Local version sorting will have to be it's own issue - /// since there are no limits to what a local version can be - /// - /// For those who can read regex here it is for the local version: - /// `[a-z0-9]+(?:(?:[\-_.][a-z0-9]+)+)?` - /// - /// Here in Rulex: - /// ```toml - /// ['a'-'z' '0'-'9']+ - /// ((["-" "_" "."] ['a'-'z' '0'-'9']+)+)? - /// ``` - #[derivative(PartialOrd = "ignore", PartialEq = "ignore")] - pub local: Option, - - /// ## `PEP-440` Developmental release identifier - pub dev: Option, - - /// ## `PEP-440` Post-Release identifier - pub post: Option, - - /// ## `PEP-440` Pre-Release identifier - pub pre: Option, - - /// ## `PEP-440` Release number - pub release: ReleaseHeader, - - /// ## `PEP-440` Version-Epoch - pub epoch: Option, -} - -impl PackageVersion { - pub fn new(version: &str) -> Result { - let version_match = validate_440_version(version)?; - - let epoch: Option = match version_match.name("epoch") { - // Convert Epoch String to Epoch Number - Some(v) => Some(v.as_str().parse::()?), - None => None, - }; - - let release: ReleaseHeader = match version_match.name("release") { - Some(v) => { - // Does Release String contain minor version - if v.as_str().contains('.') { - let split: Vec<&str> = v.as_str().split('.').into_iter().collect(); - ReleaseHeader { - major: split[0].parse::()?, - minor: split[1].parse::()?, - } - } else { - ReleaseHeader { - major: v.as_str().parse::()?, - minor: 0, - } - } - } - // There always has to be at least a major version - None => anyhow::bail!("Failed to decode version {}", version), - }; - - let pre: Option = match version_match.name("pre") { - Some(_) => { - let pre_n = match version_match.name("pre_n") { - Some(v) => Some(v.as_str().parse::()?), - None => None, - }; - - // Should be safe to unwrap since we already checked if pre has a value - // since pre_n has to exist - match version_match.name("pre_l").unwrap().as_str() { - "alpha" => Some(PreHeader::Alpha(pre_n)), - "a" => Some(PreHeader::Alpha(pre_n)), - "beta" => Some(PreHeader::Beta(pre_n)), - "b" => Some(PreHeader::Beta(pre_n)), - "rc" => Some(PreHeader::ReleaseCandidate(pre_n)), - "c" => Some(PreHeader::ReleaseCandidate(pre_n)), - "preview" => Some(PreHeader::Preview(pre_n)), - "pre" => Some(PreHeader::Preview(pre_n)), - _ => None, - } - } - None => None, - }; - - let post: Option = match version_match.name("post") { - Some(_) => { - let post_num: Option = match version_match.name("post_n1") { - Some(v) => Some(v.as_str().parse::()?), - None => match version_match.name("post_n2") { - Some(v) => Some(v.as_str().parse::()?), - _ => None, - }, - }; - - let post_head: Option = match version_match.name("post_l") { - Some(v) => { - match v.as_str() { - "post" => Some(PostHead::Post), - "rev" => Some(PostHead::Rev), - "r" => Some(PostHead::Rev), - // This branch Should be impossible (see regex-group post_l) - _ => None, - } - } - None => None, - }; - - Some(PostHeader { - post_head, - post_num, - }) - } - None => None, - }; - - let dev: Option = match version_match.name("dev") { - Some(_) => { - let dev_num = match version_match.name("dev_n") { - Some(v) => Some(v.as_str().parse::()?), - None => None, - }; - Some(DevHead { dev_num }) - } - None => None, - }; - - let local: Option = - version_match.name("local").map(|v| v.as_str().to_string()); - - Ok(Self { - original: version.to_string(), - epoch, - release, - pre, - post, - dev, - local, - }) - } -} - -impl fmt::Display for PackageVersion { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.original) - } -} - -#[cfg(test)] -mod tests { - use crate::PackageVersion; - use anyhow::Result; - - #[test] - fn test_pep440_ordering() -> Result<()> { - assert!( - PackageVersion::new( - "v1!1.0-preview-921.post-516.dev-241+yeah.this.is.the.problem.with.local.versions", - )? - > - PackageVersion::new("1.0")? - ); - Ok(()) - } - - #[test] - fn test_pep440_equality() -> Result<()> { - assert_eq!( - PackageVersion::new("1.0a1")?, - PackageVersion::new("1.0alpha1")? - ); - assert_eq!( - PackageVersion::new("1.0b")?, - PackageVersion::new("1.0beta")? - ); - assert_eq!(PackageVersion::new("1.0r")?, PackageVersion::new("1.0rev")?); - assert_eq!(PackageVersion::new("1.0c")?, PackageVersion::new("1.0rc")?); - assert_eq!(PackageVersion::new("v1.0")?, PackageVersion::new("1.0")?); - Ok(()) - } - - #[test] - fn test_pep440() { - // list of every example mentioned in pep-440 - let versions = vec![ - "1.0", - "v1.1", - "2.0", - "2013.10", - "2014.04", - "1!1.0", - "1!1.1", - "1!2.0", - "2!1.0.pre0", - "1.0.dev456", - "1.0a1", - "1.0a2.dev456", - "1.0a12.dev456", - "1.0a12", - "1.0b1.dev456", - "1.0b2", - "1.0b2.post345.dev456", - "1.0b2.post345", - "1.0rc1.dev456", - "1.0rc1", - "1.0", - "1.0+abc.5", - "1.0+abc.7", - "1.0+5", - "1.0.post456.dev34", - "1.0.post456", - "1.0.15", - "1.1.dev1", - ]; - - for version in versions { - match PackageVersion::new(version) { - Ok(_v) => continue, - Err(e) => panic!("Oh no {}", e), - } - } - } - - #[test] - fn test_pep440_negative() { - let versions = vec!["not a version"]; - - for version in versions { - match PackageVersion::new(version) { - Ok(v) => panic!("Oh no {}", v), - Err(_e) => continue, - } - } - } -} +mod version; +// Expose PackageVersion Struct +pub use version::PackageVersion; diff --git a/src/version.rs b/src/version.rs new file mode 100644 index 0000000..151a31c --- /dev/null +++ b/src/version.rs @@ -0,0 +1,262 @@ +use super::ids::{DevHead, PostHead, PostHeader, PreHeader, ReleaseHeader}; +use super::validate_440_version; +use anyhow::Result; +use serde::{Deserialize, Serialize}; +use std::fmt; + +/// `PEP-440` Compliant versioning system +/// +//# This struct is sorted so that PartialOrd +//# correctly interprets priority +//# Lower == More important +/// +/// # Example Usage +/// ``` +///# use pyver::PackageVersion; +/// let _ = PackageVersion::new("v1.0"); +/// ``` +#[derive(Derivative, Debug, Serialize, Deserialize)] +#[derivative(PartialOrd, PartialEq)] +pub struct PackageVersion { + /// ## Original String + /// Just holds the original string passed in when creating + /// the `PackageVersion` as some formating data is lost + /// when parsing the string + #[derivative(PartialOrd = "ignore", PartialEq = "ignore")] + pub original: String, + + /// ## `PEP-440` Local version identifier + /// Local version sorting will have to be it's own issue + /// since there are no limits to what a local version can be + /// + /// For those who can read regex here it is for the local version: + /// `[a-z0-9]+(?:(?:[\-_.][a-z0-9]+)+)?` + /// + /// Here in Rulex: + /// ```toml + /// ['a'-'z' '0'-'9']+ + /// ((["-" "_" "."] ['a'-'z' '0'-'9']+)+)? + /// ``` + #[derivative(PartialOrd = "ignore", PartialEq = "ignore")] + pub local: Option, + + /// ## `PEP-440` Developmental release identifier + pub dev: Option, + + /// ## `PEP-440` Post-Release identifier + pub post: Option, + + /// ## `PEP-440` Pre-Release identifier + pub pre: Option, + + /// ## `PEP-440` Release number + pub release: ReleaseHeader, + + /// ## `PEP-440` Version-Epoch + pub epoch: Option, +} + +impl PackageVersion { + pub fn new(version: &str) -> Result { + let version_match = validate_440_version(version)?; + + let epoch: Option = match version_match.name("epoch") { + // Convert Epoch String to Epoch Number + Some(v) => Some(v.as_str().parse::()?), + None => None, + }; + + let release: ReleaseHeader = match version_match.name("release") { + Some(v) => { + // Does Release String contain minor version + if v.as_str().contains('.') { + let split: Vec<&str> = v.as_str().split('.').into_iter().collect(); + ReleaseHeader { + major: split[0].parse::()?, + minor: split[1].parse::()?, + } + } else { + ReleaseHeader { + major: v.as_str().parse::()?, + minor: 0, + } + } + } + // There always has to be at least a major version + None => anyhow::bail!("Failed to decode version {}", version), + }; + + let pre: Option = match version_match.name("pre") { + Some(_) => { + let pre_n = match version_match.name("pre_n") { + Some(v) => Some(v.as_str().parse::()?), + None => None, + }; + + // Should be safe to unwrap since we already checked if pre has a value + // since pre_n has to exist + match version_match.name("pre_l").unwrap().as_str() { + "alpha" => Some(PreHeader::Alpha(pre_n)), + "a" => Some(PreHeader::Alpha(pre_n)), + "beta" => Some(PreHeader::Beta(pre_n)), + "b" => Some(PreHeader::Beta(pre_n)), + "rc" => Some(PreHeader::ReleaseCandidate(pre_n)), + "c" => Some(PreHeader::ReleaseCandidate(pre_n)), + "preview" => Some(PreHeader::Preview(pre_n)), + "pre" => Some(PreHeader::Preview(pre_n)), + _ => None, + } + } + None => None, + }; + + let post: Option = match version_match.name("post") { + Some(_) => { + let post_num: Option = match version_match.name("post_n1") { + Some(v) => Some(v.as_str().parse::()?), + None => match version_match.name("post_n2") { + Some(v) => Some(v.as_str().parse::()?), + _ => None, + }, + }; + + let post_head: Option = match version_match.name("post_l") { + Some(v) => { + match v.as_str() { + "post" => Some(PostHead::Post), + "rev" => Some(PostHead::Rev), + "r" => Some(PostHead::Rev), + // This branch Should be impossible (see regex-group post_l) + _ => None, + } + } + None => None, + }; + + Some(PostHeader { + post_head, + post_num, + }) + } + None => None, + }; + + let dev: Option = match version_match.name("dev") { + Some(_) => { + let dev_num = match version_match.name("dev_n") { + Some(v) => Some(v.as_str().parse::()?), + None => None, + }; + Some(DevHead { dev_num }) + } + None => None, + }; + + let local: Option = + version_match.name("local").map(|v| v.as_str().to_string()); + + Ok(Self { + original: version.to_string(), + epoch, + release, + pre, + post, + dev, + local, + }) + } +} + +impl fmt::Display for PackageVersion { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.original) + } +} + +#[cfg(test)] +mod tests { + use crate::PackageVersion; + use anyhow::Result; + + #[test] + fn test_pep440_ordering() -> Result<()> { + assert!( + PackageVersion::new( + "v1!1.0-preview-921.post-516.dev-241+yeah.this.is.the.problem.with.local.versions", + )? + > + PackageVersion::new("1.0")? + ); + Ok(()) + } + + #[test] + fn test_pep440_equality() -> Result<()> { + assert_eq!( + PackageVersion::new("1.0a1")?, + PackageVersion::new("1.0alpha1")? + ); + assert_eq!( + PackageVersion::new("1.0b")?, + PackageVersion::new("1.0beta")? + ); + assert_eq!(PackageVersion::new("1.0r")?, PackageVersion::new("1.0rev")?); + assert_eq!(PackageVersion::new("1.0c")?, PackageVersion::new("1.0rc")?); + assert_eq!(PackageVersion::new("v1.0")?, PackageVersion::new("1.0")?); + Ok(()) + } + + #[test] + fn test_pep440() { + // list of every example mentioned in pep-440 + let versions = vec![ + "1.0", + "v1.1", + "2.0", + "2013.10", + "2014.04", + "1!1.0", + "1!1.1", + "1!2.0", + "2!1.0.pre0", + "1.0.dev456", + "1.0a1", + "1.0a2.dev456", + "1.0a12.dev456", + "1.0a12", + "1.0b1.dev456", + "1.0b2", + "1.0b2.post345.dev456", + "1.0b2.post345", + "1.0rc1.dev456", + "1.0rc1", + "1.0", + "1.0+abc.5", + "1.0+abc.7", + "1.0+5", + "1.0.post456.dev34", + "1.0.post456", + "1.0.15", + "1.1.dev1", + ]; + + for version in versions { + match PackageVersion::new(version) { + Ok(_v) => continue, + Err(e) => panic!("Oh no {}", e), + } + } + } + + #[test] + fn test_pep440_negative() { + let versions = vec!["not a version"]; + + for version in versions { + match PackageVersion::new(version) { + Ok(v) => panic!("Oh no {}", v), + Err(_e) => continue, + } + } + } +} From fc1593e354b3c5dbd4eff768feddc0079308e599 Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Mon, 5 Sep 2022 18:21:01 +0200 Subject: [PATCH 11/15] Update CHANGELOG.md (#22) --- CHANGELOG.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae4155c..fee7369 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,25 @@ and this project adheres to: ## Unreleased -## [0.0.1] - 2022-09-03 +### Added + +* Added Github Actions for (cargo check, cargo fmt, cargo clippy, cargo test) [#10](https://github.com/Allstreamer/pyver/pull/10) +* Added CHANGELOG.md +* Added `ids` module + +### Changed + +* Added LICENSE with MIT License [#10](https://github.com/Allstreamer/pyver/pull/10) +* Added CI Badges to Readme by [#10](https://github.com/Allstreamer/pyver/pull/10) +* Moved PackageVersion & it's tests to version.rs [#21](https://github.com/Allstreamer/pyver/pull/21) +* Moved Identifiers & tests to `ids` module + +### Docs + +* Added Struct descriptions to each struct [#15](https://github.com/Allstreamer/pyver/pull/15) +* Added Examples to Rust Docs [#15](https://github.com/Allstreamer/pyver/pull/15) + +## [0.1.0] - 2022-09-03 ### Added From 65d35dd8df51fcc045de8ab35e78b39f8a559db4 Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Tue, 6 Sep 2022 11:07:34 +0200 Subject: [PATCH 12/15] Bumped Version --- CHANGELOG.md | 2 ++ Cargo.toml | 2 +- README.md | 2 +- src/lib.rs | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fee7369..7cbb046 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ and this project adheres to: ### Changed +## [1.0.0] - 2022-09-06 + * Added LICENSE with MIT License [#10](https://github.com/Allstreamer/pyver/pull/10) * Added CI Badges to Readme by [#10](https://github.com/Allstreamer/pyver/pull/10) * Moved PackageVersion & it's tests to version.rs [#21](https://github.com/Allstreamer/pyver/pull/21) diff --git a/Cargo.toml b/Cargo.toml index f3baa7c..b2c35c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ authors = [ "Jan Bronicki ", ] license = "MIT" -version = "0.1.0" +version = "1.0.0" keywords = ["versions", "python", "parser", "semver", "pep-440"] readme = "README.md" edition = "2021" diff --git a/README.md b/README.md index 273ce30..95ecce5 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ version numbers and for comparisons between ```Toml [dependencies] -pyver = "0" +pyver = "1" ``` ```Rust diff --git a/src/lib.rs b/src/lib.rs index 805c93d..a9c3205 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ The `pyver` crate is available on [crates.io](https://crates.io/crates/pyver), you can include it in your project by adding the following to your `Cargo.toml`. ```toml [dependencies] -pyver = "0.1" +pyver = "1.0" ``` # Example The following example shows how to parse a package version and From eb444362f3f14058737922a8c1a96f00c0dc1b78 Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Tue, 6 Sep 2022 14:22:17 +0200 Subject: [PATCH 13/15] Add Examples to Readme - Added additional examples - Added Link to crates.io - Added Link to docs.rs - Changed License tag to use crates.io --- README.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 95ecce5..c357ac4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # PyVer -![GitHub](https://img.shields.io/github/license/Allstreamer/pyver) [![๐Ÿงช Tests](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml) [![๐Ÿ–‹ Check linting](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml) [![๐Ÿ”จ Build](https://github.com/Allstreamer/pyver/actions/workflows/build.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/build.yml) [![๐Ÿ“ฆ Package](https://github.com/Allstreamer/pyver/actions/workflows/package.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/package.yml) [![๐Ÿ“„ Build docs](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml) [![๐Ÿ‘” Check formatting](https://github.com/Allstreamer/pyver/actions/workflows/format.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/format.yml) +![Crates.io](https://img.shields.io/crates/l/pyver) ![Crates.io](https://img.shields.io/crates/v/pyver) ![docs.rs](https://img.shields.io/docsrs/pyver) [![๐Ÿงช Tests](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml) [![๐Ÿ–‹ Check linting](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml) [![๐Ÿ”จ Build](https://github.com/Allstreamer/pyver/actions/workflows/build.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/build.yml) [![๐Ÿ“ฆ Package](https://github.com/Allstreamer/pyver/actions/workflows/package.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/package.yml) [![๐Ÿ“„ Build docs](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml) [![๐Ÿ‘” Check formatting](https://github.com/Allstreamer/pyver/actions/workflows/format.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/format.yml) > **Python PEP-440 Version Parser** @@ -17,6 +17,7 @@ version numbers and for comparisons between pyver = "1" ``` +The following is an example for initilizing and comparing two version strings ```Rust use pyver::PackageVersion; @@ -26,6 +27,35 @@ let b = PackageVersion::new("v1.0a2.dev457").unwrap(); assert_eq!(a < b, true); ``` +Comparing single version components +```Rust +use pyver::PackageVersion; + +let a = PackageVersion::new("1!1.323.dev2").unwrap(); +let b = PackageVersion::new("v3.2.dev2").unwrap(); + +// Check that both have the same dev version +assert_eq!(a.dev, b.dev); +``` + +Seperation of version identifiers +```Rust +use pyver::PackageVersion; + +let version = PackageVersion::new("v1.23.dev2").unwrap(); + +println!("{:?}", version.release.major); +// > 1 + +println!("{:?}", version.release.minor); +// > 2 + +println!("{:?}", version.dev); +// > Some(DevHead { dev_num: Some(2) }) +``` + +See more examples at the [docs](https://docs.rs/pyver/latest/pyver/) + ## Contribution For now Contributions will be quite loose. From 648ca19698e66d4250502e734fd801800cc817e8 Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Tue, 6 Sep 2022 14:26:40 +0200 Subject: [PATCH 14/15] Fix MD Linting --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index c357ac4..8971158 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ pyver = "1" ``` The following is an example for initilizing and comparing two version strings + ```Rust use pyver::PackageVersion; @@ -28,6 +29,7 @@ assert_eq!(a < b, true); ``` Comparing single version components + ```Rust use pyver::PackageVersion; @@ -39,6 +41,7 @@ assert_eq!(a.dev, b.dev); ``` Seperation of version identifiers + ```Rust use pyver::PackageVersion; From 9e3b424f970420e2627b630b5e304bd097629f26 Mon Sep 17 00:00:00 2001 From: Allstreamer <48365544+Allstreamer@users.noreply.github.com> Date: Tue, 6 Sep 2022 23:17:51 +0200 Subject: [PATCH 15/15] Fix Readme - Fixed Readme for crates.io - Bumped patch number to allow for uploading --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- README.md | 8 ++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cbb046..6a2ef4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ and this project adheres to: ### Changed +## [1.0.1] - 2022-09-06 + +* [MINOR] Fixed Readme for crates.io + ## [1.0.0] - 2022-09-06 * Added LICENSE with MIT License [#10](https://github.com/Allstreamer/pyver/pull/10) diff --git a/Cargo.toml b/Cargo.toml index b2c35c3..2b754a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ authors = [ "Jan Bronicki ", ] license = "MIT" -version = "1.0.0" +version = "1.0.1" keywords = ["versions", "python", "parser", "semver", "pep-440"] readme = "README.md" edition = "2021" diff --git a/README.md b/README.md index 8971158..338fc78 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,14 @@ version numbers and for comparisons between ## Usage -```Toml +```toml [dependencies] pyver = "1" ``` The following is an example for initilizing and comparing two version strings -```Rust +```rust use pyver::PackageVersion; let a = PackageVersion::new("v1.0a2.dev456").unwrap(); @@ -30,7 +30,7 @@ assert_eq!(a < b, true); Comparing single version components -```Rust +```rust use pyver::PackageVersion; let a = PackageVersion::new("1!1.323.dev2").unwrap(); @@ -42,7 +42,7 @@ assert_eq!(a.dev, b.dev); Seperation of version identifiers -```Rust +```rust use pyver::PackageVersion; let version = PackageVersion::new("v1.23.dev2").unwrap();