From c6bf9c1f050971cdd0f94b46ce59f937da3e496b Mon Sep 17 00:00:00 2001 From: Jane Losare-Lusby Date: Wed, 6 Aug 2025 14:31:49 -0700 Subject: [PATCH] Add release-plz to CI (#242) also fix clippy warnings --- .github/workflows/ci.yml | 2 +- .github/workflows/release-plz.yml | 61 +++++++++++++++++++++++++++ Cargo.lock | 2 +- color-eyre/Cargo.toml | 34 --------------- color-eyre/examples/debug_perf.rs | 2 +- color-eyre/examples/github_issue.rs | 2 +- color-eyre/src/config.rs | 12 +++--- color-eyre/src/handler.rs | 15 +++---- color-eyre/src/section/github.rs | 2 +- color-eyre/src/section/help.rs | 10 ++--- color-eyre/src/section/mod.rs | 1 + color-eyre/tests/bt_disabled.rs | 2 +- color-eyre/tests/bt_enabled.rs | 2 +- color-eyre/tests/location_disabled.rs | 2 +- color-eyre/tests/theme.rs | 4 +- eyre/examples/custom_handler.rs | 6 +-- eyre/src/error/pyo3_compat.rs | 2 +- eyre/src/lib.rs | 12 +++--- eyre/tests/test_location.rs | 14 +++--- eyre/tests/test_pyo3.rs | 2 +- 20 files changed, 108 insertions(+), 81 deletions(-) create mode 100644 .github/workflows/release-plz.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 014e490..43f9bfd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,7 @@ jobs: args: --all ${{ matrix.features }} test-msrv: - name: Test Suite + name: Test Suite (msrv) runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml new file mode 100644 index 0000000..41f72ba --- /dev/null +++ b/.github/workflows/release-plz.yml @@ -0,0 +1,61 @@ +name: Release-plz + +permissions: + pull-requests: write + contents: write + +on: + push: + branches: + - master + +jobs: + + # Release unpublished packages. + # Disabled until we're ready to release eyre since we've already bumped the version in toml + # release-plz-release: + # name: Release-plz release + # runs-on: ubuntu-latest + # if: ${{ github.repository_owner == 'eyre-rs' }} + # permissions: + # contents: write + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + # with: + # fetch-depth: 0 + # - name: Install Rust toolchain + # uses: dtolnay/rust-toolchain@stable + # - name: Run release-plz + # uses: release-plz/action@v0.5 + # with: + # command: release + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + # Create a PR with the new versions and changelog, preparing the next release. + release-plz-pr: + name: Release-plz PR + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'eyre-rs' }} + permissions: + contents: write + pull-requests: write + concurrency: + group: release-plz-${{ github.ref }} + cancel-in-progress: false + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + - name: Run release-plz + uses: release-plz/action@v0.5 + with: + command: release-pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/Cargo.lock b/Cargo.lock index 2e2cc23..1c1ca71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -165,7 +165,7 @@ checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632" [[package]] name = "eyre" -version = "0.6.11" +version = "1.0.0" dependencies = [ "anyhow", "autocfg", diff --git a/color-eyre/Cargo.toml b/color-eyre/Cargo.toml index 6fb6c44..e4b801c 100644 --- a/color-eyre/Cargo.toml +++ b/color-eyre/Cargo.toml @@ -44,40 +44,6 @@ rustdoc-args = ["--cfg", "docsrs"] [package.metadata.release] dev-version = false -[[package.metadata.release.pre-release-replacements]] -file = "CHANGELOG.md" -search = "Unreleased" -replace="{{version}}" - -[[package.metadata.release.pre-release-replacements]] -file = "src/lib.rs" -search = "#!\\[doc\\(html_root_url.*" -replace = "#![doc(html_root_url = \"https://docs.rs/{{crate_name}}/{{version}}\")]" -exactly = 1 - -[[package.metadata.release.pre-release-replacements]] -file = "CHANGELOG.md" -search = "\\.\\.\\.HEAD" -replace="...{{tag_name}}" -exactly = 1 - -[[package.metadata.release.pre-release-replacements]] -file = "CHANGELOG.md" -search = "ReleaseDate" -replace="{{date}}" - -[[package.metadata.release.pre-release-replacements]] -file="CHANGELOG.md" -search="" -replace="\n\n## [Unreleased] - ReleaseDate" -exactly=1 - -[[package.metadata.release.pre-release-replacements]] -file="CHANGELOG.md" -search="" -replace="\n[Unreleased]: https://github.com/eyre-rs/{{crate_name}}/compare/{{tag_name}}...HEAD" -exactly=1 - [[example]] name = "color-eyre-usage" path = "examples/usage.rs" diff --git a/color-eyre/examples/debug_perf.rs b/color-eyre/examples/debug_perf.rs index fbf03d6..e036375 100644 --- a/color-eyre/examples/debug_perf.rs +++ b/color-eyre/examples/debug_perf.rs @@ -30,7 +30,7 @@ fn time_report_inner() { .suggestion("try using a file that exists next time") .unwrap_err(); - println!("Error: {:?}", report); + println!("Error: {report:?}"); drop(report); let end = std::time::Instant::now(); diff --git a/color-eyre/examples/github_issue.rs b/color-eyre/examples/github_issue.rs index a5e223b..94118d3 100644 --- a/color-eyre/examples/github_issue.rs +++ b/color-eyre/examples/github_issue.rs @@ -19,7 +19,7 @@ fn main() -> Result<(), Report> { .install()?; let report = read_config().unwrap_err(); - eprintln!("Error: {:?}", report); + eprintln!("Error: {report:?}"); read_config2(); diff --git a/color-eyre/src/config.rs b/color-eyre/src/config.rs index 6523831..38d6f87 100644 --- a/color-eyre/src/config.rs +++ b/color-eyre/src/config.rs @@ -1,5 +1,6 @@ //! Configuration options for customizing the behavior of the provided panic //! and error reporting hooks +#![allow(deprecated)] // for PanicHook until we bump MSRV use crate::{ section::PanicMessage, writers::{EnvSection, WriterExt}, @@ -271,7 +272,7 @@ impl fmt::Display for SourceSection<'_> { line.style(theme.active_line), )?; } else { - write!(&mut f, "{:>8} │ {}", cur_line_no, line)?; + write!(&mut f, "{cur_line_no:>8} │ {line}")?; } f = separated.ready(); } @@ -837,7 +838,7 @@ fn print_panic_info(report: &PanicReport<'_>, f: &mut fmt::Formatter<'_>) -> fmt let mut separated = f.header("\n\n"); if let Some(ref section) = report.hook.section { - write!(&mut separated.ready(), "{}", section)?; + write!(&mut separated.ready(), "{section}")?; } #[cfg(feature = "capture-spantrace")] @@ -855,8 +856,7 @@ fn print_panic_info(report: &PanicReport<'_>, f: &mut fmt::Formatter<'_>) -> fmt let fmted_bt = report.hook.format_backtrace(bt); write!( indented(&mut separated.ready()).with_format(Format::Uniform { indentation: " " }), - "{}", - fmted_bt + "{fmted_bt}" )?; } @@ -867,7 +867,7 @@ fn print_panic_info(report: &PanicReport<'_>, f: &mut fmt::Formatter<'_>) -> fmt span_trace: report.span_trace.as_ref(), }; - write!(&mut separated.ready(), "{}", env_section)?; + write!(&mut separated.ready(), "{env_section}")?; } #[cfg(feature = "issue-url")] @@ -892,7 +892,7 @@ fn print_panic_info(report: &PanicReport<'_>, f: &mut fmt::Formatter<'_>) -> fmt #[cfg(feature = "capture-spantrace")] let issue_section = issue_section.with_span_trace(report.span_trace.as_ref()); - write!(&mut separated.ready(), "{}", issue_section)?; + write!(&mut separated.ready(), "{issue_section}")?; } } diff --git a/color-eyre/src/handler.rs b/color-eyre/src/handler.rs index 80c1417..b48e44a 100644 --- a/color-eyre/src/handler.rs +++ b/color-eyre/src/handler.rs @@ -85,7 +85,7 @@ impl eyre::EyreHandler for Handler { .iter() .filter(|s| matches!(s, HelpInfo::Error(_, _))) { - write!(separated.ready(), "{}", section)?; + write!(separated.ready(), "{section}")?; } for section in self @@ -93,7 +93,7 @@ impl eyre::EyreHandler for Handler { .iter() .filter(|s| matches!(s, HelpInfo::Custom(_))) { - write!(separated.ready(), "{}", section)?; + write!(separated.ready(), "{section}")?; } #[cfg(feature = "capture-spantrace")] @@ -120,8 +120,7 @@ impl eyre::EyreHandler for Handler { write!( indented(&mut separated.ready()) .with_format(Format::Uniform { indentation: " " }), - "{}", - fmted_bt + "{fmted_bt}" )?; } } @@ -135,7 +134,7 @@ impl eyre::EyreHandler for Handler { .iter() .filter(|s| !matches!(s, HelpInfo::Custom(_) | HelpInfo::Error(_, _))) { - write!(&mut f, "{}", section)?; + write!(&mut f, "{section}")?; f = h.ready(); } @@ -146,7 +145,7 @@ impl eyre::EyreHandler for Handler { span_trace, }; - write!(&mut separated.ready(), "{}", env_section)?; + write!(&mut separated.ready(), "{env_section}")?; } #[cfg(feature = "issue-url")] @@ -155,7 +154,7 @@ impl eyre::EyreHandler for Handler { let mut payload = String::from("Error: "); for (n, error) in errors() { writeln!(&mut payload)?; - write!(indented(&mut payload).ind(n), "{}", error)?; + write!(indented(&mut payload).ind(n), "{error}")?; } let issue_section = crate::section::github::IssueSection::new(url, &payload) @@ -165,7 +164,7 @@ impl eyre::EyreHandler for Handler { #[cfg(feature = "capture-spantrace")] let issue_section = issue_section.with_span_trace(span_trace); - write!(&mut separated.ready(), "{}", issue_section)?; + write!(&mut separated.ready(), "{issue_section}")?; } Ok(()) diff --git a/color-eyre/src/section/github.rs b/color-eyre/src/section/github.rs index f0734e6..8ab7cac 100644 --- a/color-eyre/src/section/github.rs +++ b/color-eyre/src/section/github.rs @@ -146,7 +146,7 @@ where writeln!(f, "|--|--|").expect("writing to a string doesn't panic"); for (key, value) in self.metadata { - writeln!(f, "|**{}**|{}|", key, value).expect("writing to a string doesn't panic"); + writeln!(f, "|**{key}**|{value}|").expect("writing to a string doesn't panic"); } out diff --git a/color-eyre/src/section/help.rs b/color-eyre/src/section/help.rs index a03cf3e..ef22111 100644 --- a/color-eyre/src/section/help.rs +++ b/color-eyre/src/section/help.rs @@ -275,7 +275,7 @@ impl Display for HelpInfo { "Suggestion".style(theme.help_info_suggestion), suggestion ), - HelpInfo::Custom(section) => write!(f, "{}", section), + HelpInfo::Custom(section) => write!(f, "{section}"), HelpInfo::Error(error, theme) => { // a lot here let errors = std::iter::successors( @@ -300,19 +300,19 @@ impl fmt::Debug for HelpInfo { match self { HelpInfo::Note(note, ..) => f .debug_tuple("Note") - .field(&format_args!("{}", note)) + .field(&format_args!("{note}")) .finish(), HelpInfo::Warning(warning, ..) => f .debug_tuple("Warning") - .field(&format_args!("{}", warning)) + .field(&format_args!("{warning}")) .finish(), HelpInfo::Suggestion(suggestion, ..) => f .debug_tuple("Suggestion") - .field(&format_args!("{}", suggestion)) + .field(&format_args!("{suggestion}")) .finish(), HelpInfo::Custom(custom, ..) => f .debug_tuple("CustomSection") - .field(&format_args!("{}", custom)) + .field(&format_args!("{custom}")) .finish(), HelpInfo::Error(error, ..) => f.debug_tuple("Error").field(error).finish(), } diff --git a/color-eyre/src/section/mod.rs b/color-eyre/src/section/mod.rs index f7b5b68..3e118d3 100644 --- a/color-eyre/src/section/mod.rs +++ b/color-eyre/src/section/mod.rs @@ -1,4 +1,5 @@ //! Helpers for adding custom sections to error reports +#![allow(deprecated)] // for PanicHook until we bump MSRV use crate::writers::WriterExt; use std::fmt::{self, Display}; diff --git a/color-eyre/tests/bt_disabled.rs b/color-eyre/tests/bt_disabled.rs index 4e6f163..b0cbe23 100644 --- a/color-eyre/tests/bt_disabled.rs +++ b/color-eyre/tests/bt_disabled.rs @@ -10,6 +10,6 @@ fn disabled() { let report = eyre!("error occured"); - let report = format!("{:?}", report); + let report = format!("{report:?}"); assert!(!report.contains("RUST_BACKTRACE")); } diff --git a/color-eyre/tests/bt_enabled.rs b/color-eyre/tests/bt_enabled.rs index 7bc6f03..2f4ffcc 100644 --- a/color-eyre/tests/bt_enabled.rs +++ b/color-eyre/tests/bt_enabled.rs @@ -10,6 +10,6 @@ fn enabled() { let report = eyre!("error occured"); - let report = format!("{:?}", report); + let report = format!("{report:?}"); assert!(report.contains("RUST_BACKTRACE")); } diff --git a/color-eyre/tests/location_disabled.rs b/color-eyre/tests/location_disabled.rs index 7eee57c..6db54c2 100644 --- a/color-eyre/tests/location_disabled.rs +++ b/color-eyre/tests/location_disabled.rs @@ -11,6 +11,6 @@ fn disabled() { let report = eyre!("error occured"); - let report = format!("{:?}", report); + let report = format!("{report:?}"); assert!(!report.contains("Location:")); } diff --git a/color-eyre/tests/theme.rs b/color-eyre/tests/theme.rs index e0666e1..4b4abf9 100644 --- a/color-eyre/tests/theme.rs +++ b/color-eyre/tests/theme.rs @@ -89,7 +89,7 @@ fn test_error_backwards_compatibility() { Below you'll find instructions about how to debug failures of the tests in this file */ - let target = format!("{:?}", error); + let target = format!("{error:?}"); test_backwards_compatibility(target, ERROR_FILE_NAME) } @@ -129,7 +129,7 @@ fn test_panic_backwards_compatibility() { .output() .expect("failed to execute process"); let target = String::from_utf8(output.stderr).expect("failed to convert output to `String`"); - println!("{}", target); + println!("{target}"); test_backwards_compatibility(target, PANIC_FILE_NAME) } diff --git a/eyre/examples/custom_handler.rs b/eyre/examples/custom_handler.rs index a6f0ab2..34c5a2a 100644 --- a/eyre/examples/custom_handler.rs +++ b/eyre/examples/custom_handler.rs @@ -65,15 +65,15 @@ impl EyreHandler for Handler { let errors = iter::successors(Some(error), |error| (*error).source()); for (ind, error) in errors.enumerate() { - write!(f, "\n{:>4}: {}", ind, error)?; + write!(f, "\n{ind:>4}: {error}")?; } if let Some(backtrace) = self.backtrace.as_ref() { - writeln!(f, "\n\nBacktrace:\n{:?}", backtrace)?; + writeln!(f, "\n\nBacktrace:\n{backtrace:?}")?; } if let Some(msg) = self.custom_msg.as_ref() { - writeln!(f, "\n\n{}", msg)?; + writeln!(f, "\n\n{msg}")?; } Ok(()) diff --git a/eyre/src/error/pyo3_compat.rs b/eyre/src/error/pyo3_compat.rs index b70b6a5..5543573 100644 --- a/eyre/src/error/pyo3_compat.rs +++ b/eyre/src/error/pyo3_compat.rs @@ -2,6 +2,6 @@ use crate::Report; impl From for pyo3::PyErr { fn from(error: Report) -> Self { - pyo3::exceptions::PyRuntimeError::new_err(format!("{:?}", error)) + pyo3::exceptions::PyRuntimeError::new_err(format!("{error:?}")) } } diff --git a/eyre/src/lib.rs b/eyre/src/lib.rs index e62df34..4501514 100644 --- a/eyre/src/lib.rs +++ b/eyre/src/lib.rs @@ -721,11 +721,11 @@ pub trait EyreHandler: core::any::Any + Send + Sync { error: &(dyn StdError + 'static), f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { - write!(f, "{}", error)?; + write!(f, "{error}")?; if f.alternate() { for cause in crate::chain::Chain::new(error).skip(1) { - write!(f, ": {}", cause)?; + write!(f, ": {cause}")?; } } @@ -815,7 +815,7 @@ impl EyreHandler for DefaultHandler { return core::fmt::Debug::fmt(error, f); } - write!(f, "{}", error)?; + write!(f, "{error}")?; if let Some(cause) = error.source() { write!(f, "\n\nCaused by:")?; @@ -823,9 +823,9 @@ impl EyreHandler for DefaultHandler { for (n, error) in crate::chain::Chain::new(cause).enumerate() { writeln!(f)?; if multiple { - write!(indenter::indented(f).ind(n), "{}", error)?; + write!(indenter::indented(f).ind(n), "{error}")?; } else { - write!(indenter::indented(f), "{}", error)?; + write!(indenter::indented(f), "{error}")?; } } } @@ -834,7 +834,7 @@ impl EyreHandler for DefaultHandler { { if let Some(location) = self.location { write!(f, "\n\nLocation:\n")?; - write!(indenter::indented(f), "{}", location)?; + write!(indenter::indented(f), "{location}")?; } } diff --git a/eyre/tests/test_location.rs b/eyre/tests/test_location.rs index ad1941c..49bd86e 100644 --- a/eyre/tests/test_location.rs +++ b/eyre/tests/test_location.rs @@ -50,7 +50,7 @@ fn test_wrap_err() { .unwrap_err(); // should panic if the location isn't in our crate - println!("{:?}", err); + println!("{err:?}"); } #[cfg(not(miri))] @@ -80,7 +80,7 @@ fn test_wrap_err_with() { .unwrap_err(); // should panic if the location isn't in our crate - println!("{:?}", err); + println!("{err:?}"); } #[test] @@ -94,7 +94,7 @@ fn test_option_ok_or_eyre() { let err = None::<()>.ok_or_eyre("oopsie").unwrap_err(); // should panic if the location isn't in our crate - println!("{:?}", err); + println!("{err:?}"); } #[cfg(feature = "anyhow")] @@ -111,7 +111,7 @@ fn test_context() { .unwrap_err(); // should panic if the location isn't in our crate - println!("{:?}", err); + println!("{err:?}"); } #[cfg(feature = "anyhow")] @@ -128,7 +128,7 @@ fn test_with_context() { .unwrap_err(); // should panic if the location isn't in our crate - println!("{:?}", err); + println!("{err:?}"); } #[cfg(feature = "anyhow")] @@ -143,7 +143,7 @@ fn test_option_compat_context() { let err = None::<()>.context("oopsie").unwrap_err(); // should panic if the location isn't in our crate - println!("{:?}", err); + println!("{err:?}"); } #[cfg(feature = "anyhow")] @@ -158,5 +158,5 @@ fn test_option_compat_with_context() { let err = None::<()>.with_context(|| "oopsie").unwrap_err(); // should panic if the location isn't in our crate - println!("{:?}", err); + println!("{err:?}"); } diff --git a/eyre/tests/test_pyo3.rs b/eyre/tests/test_pyo3.rs index 18c7ac1..3983dd8 100644 --- a/eyre/tests/test_pyo3.rs +++ b/eyre/tests/test_pyo3.rs @@ -23,7 +23,7 @@ fn test_pyo3_exception_contents() { use pyo3::types::IntoPyDict; let err = h().unwrap_err(); - let expected_contents = format!("{:?}", err); + let expected_contents = format!("{err:?}"); let pyerr = PyErr::from(err); Python::with_gil(|py| {