diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2bef7f0..e57de79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,14 +6,13 @@ on: branches: - master schedule: - - cron: '30 18 * * 5' # Every Friday at 18:30 UTC + - cron: "30 18 * * 5" # Every Friday at 18:30 UTC env: CARGO_TERM_COLOR: always RUSTFLAGS: -D warnings jobs: - build: name: Build on ${{ matrix.os }} (${{ matrix.rust }}) runs-on: ${{ matrix.os }} @@ -61,3 +60,21 @@ jobs: env: RUSTDOCFLAGS: --deny rustdoc::broken_intra_doc_links run: cargo doc --all-features --no-deps + + format: + name: Format + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # We use an unstable rustfmt feature and we thus need the + # nightly channel to enforce the formatting. + - name: Setup Rust nightly + run: rustup default nightly + + - name: Install rustfmt + run: rustup component add rustfmt + + - name: Check Formatting + uses: dprint/check@v2.2 diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index a157cd8..6b4ee09 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -3,7 +3,7 @@ name: Prepare Release PR on: push: branches: - - 'release-*' + - "release-*" jobs: prepare-release: diff --git a/Cargo.toml b/Cargo.toml index 6cb41b8..55cf80e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,14 +2,14 @@ name = "version-sync" version = "0.9.4" authors = ["Martin Geisler "] -description = "Crate for ensuring that version numbers in README files and other files are kept in sync with the crate version." +categories = ["development-tools", "rust-patterns"] documentation = "https://docs.rs/version-sync/" -repository = "https://github.com/mgeisler/version-sync" -readme = "README.md" +edition = "2021" keywords = ["version"] -categories = ["development-tools", "rust-patterns"] license = "MIT" -edition = "2021" +readme = "README.md" +repository = "https://github.com/mgeisler/version-sync" +description = "Crate for ensuring that version numbers in README files and other files are kept in sync with the crate version." [features] default = ["markdown_deps_updated", "html_root_url_updated", "contains_regex"] @@ -18,13 +18,13 @@ html_root_url_updated = ["url", "semver", "syn", "proc-macro2"] contains_regex = ["regex", "semver"] [dependencies] +proc-macro2 = { version = "1.0.36", default-features = false, features = ["span-locations"], optional = true } pulldown-cmark = { version = "0.9.1", default-features = false, optional = true } +regex = { version = "1.5.4", default-features = false, features = ["std", "unicode"], optional = true } semver = { version = "1.0.5", optional = true } syn = { version = "2.0.15", default-features = false, features = ["parsing", "printing", "full"], optional = true } -proc-macro2 = { version = "1.0.36", default-features = false, features = ["span-locations"], optional = true } toml = { version = "0.7.8", optional = true } url = { version = "2.2.2", optional = true } -regex = { version = "1.5.4", default-features = false, features = ["std", "unicode"], optional = true } [dev-dependencies] tempfile = "3.3.0" diff --git a/README.md b/README.md index e5e16b9..6502732 100644 --- a/README.md +++ b/README.md @@ -5,20 +5,22 @@ [![](https://img.shields.io/crates/v/version-sync.svg)][crates-io] [![](https://docs.rs/version-sync/badge.svg)][api-docs] -Rust projects typically reference the crate version number in several -places, such as the `README.md` file. The version-sync crate makes it -easy to add an integration test that checks that `README.md` is -updated when the crate version changes. +Rust projects typically reference the crate version number in several places, +such as the `README.md` file. The version-sync crate makes it easy to add an +integration test that checks that `README.md` is updated when the crate version +changes. ## Usage Add this to your `Cargo.toml`: + ```toml [dev-dependencies] version-sync = "0.9" ``` Then create a `tests/version-numbers.rs` file with: + ```rust #[test] fn test_readme_deps() { @@ -31,10 +33,10 @@ fn test_html_root_url() { } ``` -This integration test will ensure that the dependencies mentioned in -your `README.md` file are kept in sync with your crate version and -that your `html_root_url` points to the correct documentation on -docs.rs. If everything is well, the test passes: +This integration test will ensure that the dependencies mentioned in your +`README.md` file are kept in sync with your crate version and that your +`html_root_url` points to the correct documentation on docs.rs. If everything is +well, the test passes: ``` $ cargo test @@ -48,12 +50,11 @@ test test_html_root_url ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured ``` -If the README or `html_root_url` is out of sync with the crate -version, the tests fail. In this example, the crate is called -`your-crate` and the version number in `Cargo.toml` has been changed -to 0.2.0 while the `README.md` and `html_root_url` still use 0.1.2. -The tests now fail and the problematic TOML code and attribute are -shown: +If the README or `html_root_url` is out of sync with the crate version, the +tests fail. In this example, the crate is called `your-crate` and the version +number in `Cargo.toml` has been changed to 0.2.0 while the `README.md` and +`html_root_url` still use 0.1.2. The tests now fail and the problematic TOML +code and attribute are shown: ``` $ cargo test @@ -94,15 +95,15 @@ error: test failed ### Excluding TOML Code -You can add `no_sync` to the language line in a code block to exclude -it from the checks done by `assert_markdown_deps_updated!`: +You can add `no_sync` to the language line in a code block to exclude it from +the checks done by `assert_markdown_deps_updated!`: -~~~markdown +````markdown ```toml,no_sync [dependencies] your_crate = "0.1.2" ``` -~~~ +```` ## Release History @@ -110,48 +111,48 @@ This is a changelog describing the most important changes per release. ### Version 0.9.4 — 2021-12-14 -* [#115](https://github.com/mgeisler/version-sync/pull/115): Expand - `assert_markdown_deps_updated!` to also check version numbers such - as `=1.2.3`, `>1.2.3`, and `>=1.2.3`. -* [#119](https://github.com/mgeisler/version-sync/pull/119): Add new - `assert_only_contains_regex!` macro which can ensure that all - version numbers in a file are updated. +- [#115](https://github.com/mgeisler/version-sync/pull/115): Expand + `assert_markdown_deps_updated!` to also check version numbers such as + `=1.2.3`, `>1.2.3`, and `>=1.2.3`. +- [#119](https://github.com/mgeisler/version-sync/pull/119): Add new + `assert_only_contains_regex!` macro which can ensure that all version numbers + in a file are updated. ### Version 0.9.3 — 2021-09-20 -* [#108](https://github.com/mgeisler/version-sync/pull/108): Make all +- [#108](https://github.com/mgeisler/version-sync/pull/108): Make all dependencies optional. Thanks @rlee287! -* [#109](https://github.com/mgeisler/version-sync/pull/109): Forbid - the use of unsafe code. -* [#110](https://github.com/mgeisler/version-sync/pull/110): Add - simple `check_contains_version` function. +- [#109](https://github.com/mgeisler/version-sync/pull/109): Forbid the use of + unsafe code. +- [#110](https://github.com/mgeisler/version-sync/pull/110): Add simple + `check_contains_version` function. ### Version 0.9.2 — 2021-02-13 -* [#94](https://github.com/mgeisler/version-sync/pull/94): Update - pulldown-cmark to 0.8. -* [#95](https://github.com/mgeisler/version-sync/pull/95): Fix - `non_fmt_panic` lint error in latest nightly. +- [#94](https://github.com/mgeisler/version-sync/pull/94): Update pulldown-cmark + to 0.8. +- [#95](https://github.com/mgeisler/version-sync/pull/95): Fix `non_fmt_panic` + lint error in latest nightly. ### Version 0.9.1 — 2020-07-07 -* [#91](https://github.com/mgeisler/version-sync/pull/91): Pull in - fewer dependencies. This optimizes the build time by 1-2 seconds. -* [#92](https://github.com/mgeisler/version-sync/pull/92): Normalize - `\r\n` to `\n` to ensure `^` and `$` always match line boundaries. +- [#91](https://github.com/mgeisler/version-sync/pull/91): Pull in fewer + dependencies. This optimizes the build time by 1-2 seconds. +- [#92](https://github.com/mgeisler/version-sync/pull/92): Normalize `\r\n` to + `\n` to ensure `^` and `$` always match line boundaries. ### Version 0.9.0 — 2020-03-30 -Drop support for Rust 1.31.0 since our dependencies keep releasing new -patch versions that push up the minimum required Rust version. At the -time of writing, the code compiles with Rust 1.36, but this will -likely become outdated soon. +Drop support for Rust 1.31.0 since our dependencies keep releasing new patch +patch versions that push up the minimum required Rust version. At the time of +writing, the code compiles with Rust 1.36, but this will likely become outdated +soon. Issues closed: -* [#83][issue-83]: version-sync fails to parse TOML blocks when - inside blockquotes -* [#84][issue-84]: Release update to crates.io with syn 1.0 +- [#83][issue-83]: version-sync fails to parse TOML blocks when inside + blockquotes +- [#84][issue-84]: Release update to crates.io with syn 1.0 ### Version 0.8.1 — 2019-04-03 @@ -159,94 +160,89 @@ Dependencies were relaxed to make it easier to upgrade version-sync. ### Version 0.8.0 — 2019-03-28 -We now use [Rust 2018][rust-2018], which means we require Rust version -1.31.0 or later. The `assert_html_root_url_updated!` macro will again -report accurate line numbers based on span information from the syn -crate. +We now use [Rust 2018][rust-2018], which means we require Rust version 1.31.0 or +later. The `assert_html_root_url_updated!` macro will again report accurate line +numbers based on span information from the syn crate. ### Version 0.7.0 — 2019-01-14 -Special characters are now correctly escaped in the `{name}` and -`{version}` placeholders in `assert_contains_regex!`. +Special characters are now correctly escaped in the `{name}` and `{version}` +placeholders in `assert_contains_regex!`. -Dependencies were updated and version-sync now requires Rust version -1.27.2 or later. +Dependencies were updated and version-sync now requires Rust version 1.27.2 or +later. ### Version 0.6.0 — 2018-11-22 -You can use `assert_contains_regex!` to grep files for the current -version number. The search is done with a regular expression where -`{version}` is replaced with the current version number. +You can use `assert_contains_regex!` to grep files for the current version +number. The search is done with a regular expression where `{version}` is +replaced with the current version number. Git dependencies are now always accepted, which means that blocks like -~~~markdown +````markdown ```toml [dependencies] your_crate = { git = "..." } ``` -~~~ +```` will work without you having to add `no_sync`. Issues closed: -* [#17][issue-17]: Allow to check non-markdown sources -* [#39][issue-39]: Version 0.5 requires Rust version 1.21.0 -* [#42][issue-42]: Handle Git dependencies - +- [#17][issue-17]: Allow to check non-markdown sources +- [#39][issue-39]: Version 0.5 requires Rust version 1.21.0 +- [#42][issue-42]: Handle Git dependencies ### Version 0.5.0 — 2017-11-19 -Dependencies were updated and version-sync now requires Rust version -1.21 or later. +Dependencies were updated and version-sync now requires Rust version 1.21 or +later. -Error messages from `assert_html_root_url_updated!` now again include -line numbers (based on a heuristic until the syn crate can provide the -information). +Error messages from `assert_html_root_url_updated!` now again include line +numbers (based on a heuristic until the syn crate can provide the information). ### Version 0.4.0 — 2017-11-01 -This release replaces the dependency on the abandoned syntex_syntax -with with a dependency on the much lighter syn crate. This improves -compilation speed. Unfortunately, the syn crate does not provide -information about line numbers, so error messages are are no longer as -good. We might be able to work around that in a later version. +This release replaces the dependency on the abandoned syntex_syntax with with a +dependency on the much lighter syn crate. This improves compilation speed. +Unfortunately, the syn crate does not provide information about line numbers, so +error messages are are no longer as good. We might be able to work around that +in a later version. ### Version 0.3.1 — 2017-09-26 -This release fixes a small problem with the handling of pre-release -identifiers. +This release fixes a small problem with the handling of pre-release identifiers. Issues closed: -* [#19][issue-19]: Pre-release identifiers were ignored. +- [#19][issue-19]: Pre-release identifiers were ignored. ### Version 0.3.0 — 2017-09-23 -When checking dependencies in READMEs, TOML blocks can now be excluded -from the check by adding `no_sync` to the language line: +When checking dependencies in READMEs, TOML blocks can now be excluded from the +check by adding `no_sync` to the language line: -~~~markdown +````markdown ```toml,no_sync [dependencies] your_crate = "0.1" ``` -~~~ +```` -This TOML block will not be checked. This is similar to `no_run` for -Rust code blocks. +This TOML block will not be checked. This is similar to `no_run` for Rust code +blocks. ### Version 0.2.0 — 2017-09-20 -Added `assert_html_root_url_updated!` which will check that the -`html_root_url` attribute points to the correct version of the crate -documentation on docs.rs. +Added `assert_html_root_url_updated!` which will check that the `html_root_url` +attribute points to the correct version of the crate documentation on docs.rs. ### Version 0.1.3 — 2017-09-18 -First public release with support for finding outdated version numbers -in `dependencies` and `dev-dependencies`. +First public release with support for finding outdated version numbers in +`dependencies` and `dev-dependencies`. Versions 0.1.0 to 0.1.2 were released under the name check-versions. diff --git a/dprint.json b/dprint.json new file mode 100644 index 0000000..3629e1c --- /dev/null +++ b/dprint.json @@ -0,0 +1,13 @@ +{ + "markdown": { "textWrap": "always" }, + "exec": { + "commands": [{ "exts": ["rs"], "command": "rustfmt" }] + }, + "excludes": ["target/"], + "plugins": [ + "https://plugins.dprint.dev/exec-0.4.3.json@42343548b8022c99b1d750be6b894fe6b6c7ee25f72ae9f9082226dd2e515072", + "https://plugins.dprint.dev/markdown-0.16.1.wasm", + "https://plugins.dprint.dev/prettier-0.27.0.json@3557a62b4507c55a47d8cde0683195b14d13c41dda66d0f0b0e111aed107e2fe", + "https://plugins.dprint.dev/toml-0.5.4.wasm" + ] +}