Add release-plz to CI (#242)

also fix clippy warnings
This commit is contained in:
Jane Losare-Lusby 2025-08-06 14:31:49 -07:00 committed by GitHub
parent dbaf9ed0eb
commit c6bf9c1f05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 108 additions and 81 deletions

View File

@ -60,7 +60,7 @@ jobs:
args: --all ${{ matrix.features }}
test-msrv:
name: Test Suite
name: Test Suite (msrv)
runs-on: ubuntu-latest
strategy:
matrix:

61
.github/workflows/release-plz.yml vendored Normal file
View File

@ -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 }}

2
Cargo.lock generated
View File

@ -165,7 +165,7 @@ checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632"
[[package]]
name = "eyre"
version = "0.6.11"
version = "1.0.0"
dependencies = [
"anyhow",
"autocfg",

View File

@ -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="<!-- next-header -->"
replace="<!-- next-header -->\n\n## [Unreleased] - ReleaseDate"
exactly=1
[[package.metadata.release.pre-release-replacements]]
file="CHANGELOG.md"
search="<!-- next-url -->"
replace="<!-- next-url -->\n[Unreleased]: https://github.com/eyre-rs/{{crate_name}}/compare/{{tag_name}}...HEAD"
exactly=1
[[example]]
name = "color-eyre-usage"
path = "examples/usage.rs"

View File

@ -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();

View File

@ -19,7 +19,7 @@ fn main() -> Result<(), Report> {
.install()?;
let report = read_config().unwrap_err();
eprintln!("Error: {:?}", report);
eprintln!("Error: {report:?}");
read_config2();

View File

@ -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}")?;
}
}

View File

@ -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(())

View File

@ -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

View File

@ -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(),
}

View File

@ -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};

View File

@ -10,6 +10,6 @@ fn disabled() {
let report = eyre!("error occured");
let report = format!("{:?}", report);
let report = format!("{report:?}");
assert!(!report.contains("RUST_BACKTRACE"));
}

View File

@ -10,6 +10,6 @@ fn enabled() {
let report = eyre!("error occured");
let report = format!("{:?}", report);
let report = format!("{report:?}");
assert!(report.contains("RUST_BACKTRACE"));
}

View File

@ -11,6 +11,6 @@ fn disabled() {
let report = eyre!("error occured");
let report = format!("{:?}", report);
let report = format!("{report:?}");
assert!(!report.contains("Location:"));
}

View File

@ -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)
}

View File

@ -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(())

View File

@ -2,6 +2,6 @@ use crate::Report;
impl From<Report> for pyo3::PyErr {
fn from(error: Report) -> Self {
pyo3::exceptions::PyRuntimeError::new_err(format!("{:?}", error))
pyo3::exceptions::PyRuntimeError::new_err(format!("{error:?}"))
}
}

View File

@ -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}")?;
}
}

View File

@ -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:?}");
}

View File

@ -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| {