Skip to content

Commit

Permalink
Merge pull request #147 from epage/update
Browse files Browse the repository at this point in the history
chore: Adopt '_rust/main' template
  • Loading branch information
Muscraft authored Oct 10, 2024
2 parents 9b26728 + 218d7ff commit 220289c
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 75 deletions.
41 changes: 39 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
permissions:
contents: none
name: CI
needs: [test, msrv, lockfile, docs, rustfmt, clippy]
needs: [test, msrv, lockfile, docs, rustfmt, clippy, minimal-versions]
runs-on: ubuntu-latest
if: "always()"
steps:
Expand All @@ -34,7 +34,7 @@ jobs:
name: Test
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-14"]
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
rust: ["stable"]
continue-on-error: ${{ matrix.rust != 'stable' }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -65,6 +65,24 @@ jobs:
- uses: taiki-e/install-action@cargo-hack
- name: Default features
run: cargo hack check --feature-powerset --locked --rust-version --ignore-private --workspace --lib --bins
minimal-versions:
name: Minimal versions
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- name: Downgrade dependencies to minimal versions
run: cargo +nightly generate-lockfile -Z minimal-versions
- name: Compile with minimal versions
run: cargo +stable check --workspace --all-features --locked
lockfile:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -138,3 +156,22 @@ jobs:
wait-for-processing: true
- name: Report status
run: cargo clippy --workspace --all-features --all-targets -- -D warnings --allow deprecated
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Gather coverage
run: cargo tarpaulin --output-dir coverage --out lcov --timeout 120
- name: Publish to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: pre-commit/[email protected]
2 changes: 1 addition & 1 deletion .github/workflows/rust-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: Test
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest", "macos-14"]
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
rust: ["stable", "beta"]
include:
- os: ubuntu-latest
Expand Down
133 changes: 80 additions & 53 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,66 +1,31 @@
[package]
name = "annotate-snippets"
version = "0.11.4"
edition = "2021"
rust-version = "1.65" # MSRV
authors = ["Zibi Braniecki <[email protected]>"]
description = "Library for building code annotations"
license = "Apache-2.0/MIT"
repository = "https://github.com/rust-lang/annotate-snippets-rs"
readme = "README.md"
keywords = ["code", "analysis", "ascii", "errors", "debug"]
[workspace]
resolver = "2"

[package.metadata.release]
tag-name = "{{version}}"
pre-release-replacements = [
{file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1},
{file="CHANGELOG.md", search="\\.\\.\\.HEAD", replace="...{{tag_name}}", exactly=1},
{file="CHANGELOG.md", search="ReleaseDate", replace="{{date}}", min=1},
{file="CHANGELOG.md", search="<!-- next-header -->", replace="<!-- next-header -->\n## [Unreleased] - ReleaseDate\n", exactly=1},
{file="CHANGELOG.md", search="<!-- next-url -->", replace="<!-- next-url -->\n[Unreleased]: https://github.com/rust-lang/annotate-snippets-rs/compare/{{tag_name}}...HEAD", exactly=1},
[workspace.package]
repository = "https://github.com/rust-lang/annotate-snippets-rs"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.65.0" # MSRV
include = [
"build.rs",
"src/**/*",
"Cargo.toml",
"Cargo.lock",
"LICENSE*",
"README.md",
"benches/**/*",
"examples/**/*"
]

[badges]
maintenance = { status = "actively-developed" }

[dependencies]
anstyle = "1.0.4"
memchr = { version = "2.7.4", optional = true }
unicode-width = "0.1.11"

[dev-dependencies]
annotate-snippets = { path = ".", features = ["testing-colors"] }
anstream = "0.6.13"
difference = "2.0.0"
divan = "0.1.14"
glob = "0.3.1"
serde = { version = "1.0.199", features = ["derive"] }
snapbox = { version = "0.6.0", features = ["diff", "term-svg", "cmd", "examples"] }
toml = "0.5.11"
tryfn = "0.2.1"

[[bench]]
name = "bench"
harness = false

[[test]]
name = "fixtures"
harness = false

[features]
default = []
simd = ["memchr"]
testing-colors = []

[lints.rust]
[workspace.lints.rust]
rust_2018_idioms = { level = "warn", priority = -1 }
unreachable_pub = "warn"
unsafe_op_in_unsafe_fn = "warn"
unused_lifetimes = "warn"
unused_macro_rules = "warn"
unused_qualifications = "warn"

[lints.clippy]
[workspace.lints.clippy]
bool_assert_comparison = "allow"
branches_sharing_code = "allow"
checked_conversions = "warn"
Expand Down Expand Up @@ -115,6 +80,68 @@ string_lit_as_bytes = "warn"
string_to_string = "warn"
todo = "warn"
trait_duplication_in_bounds = "warn"
uninlined_format_args = "warn"
verbose_file_reads = "warn"
wildcard_imports = "warn"
zero_sized_map_values = "warn"

[package]
name = "annotate-snippets"
version = "0.11.4"
description = "Library for building code annotations"
categories = []
keywords = ["code", "analysis", "ascii", "errors", "debug"]
repository.workspace = true
license.workspace = true
edition.workspace = true
rust-version.workspace = true
include.workspace = true

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.release]
tag-name = "{{version}}"
pre-release-replacements = [
{file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1},
{file="CHANGELOG.md", search="\\.\\.\\.HEAD", replace="...{{tag_name}}", exactly=1},
{file="CHANGELOG.md", search="ReleaseDate", replace="{{date}}", min=1},
{file="CHANGELOG.md", search="<!-- next-header -->", replace="<!-- next-header -->\n## [Unreleased] - ReleaseDate\n", exactly=1},
{file="CHANGELOG.md", search="<!-- next-url -->", replace="<!-- next-url -->\n[Unreleased]: https://github.com/rust-lang/annotate-snippets-rs/compare/{{tag_name}}...HEAD", exactly=1},
]

[badges]
maintenance = { status = "actively-developed" }

[dependencies]
anstyle = "1.0.4"
memchr = { version = "2.7.4", optional = true }
unicode-width = "0.1.11"

[dev-dependencies]
annotate-snippets = { path = ".", features = ["testing-colors"] }
anstream = "0.6.13"
difference = "2.0.0"
divan = "0.1.14"
glob = "0.3.1"
serde = { version = "1.0.199", features = ["derive"] }
snapbox = { version = "0.6.0", features = ["diff", "term-svg", "cmd", "examples"] }
toml = "0.5.11"
tryfn = "0.2.1"

[[bench]]
name = "bench"
harness = false

[[test]]
name = "fixtures"
harness = false

[features]
default = []
simd = ["memchr"]
testing-colors = []

[lints]
workspace = true
5 changes: 3 additions & 2 deletions LICENSE-APACHE
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright {yyyy} {name of copyright owner}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -199,3 +199,4 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

14 changes: 7 additions & 7 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Copyright 2017 Mozilla
Copyright (c) Individual contributors

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:
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.
Expand Down
3 changes: 2 additions & 1 deletion release.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
allow-branch = ["master"]
dependent-version = "fix"
allow-branch = ["main"]
13 changes: 5 additions & 8 deletions src/renderer/display_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl<'a> DisplaySet<'a> {
self.format_label(line_offset, &annotation.label, stylesheet, buffer)
} else {
let id = match &annotation.id {
Some(id) => format!("[{}]", id),
Some(id) => format!("[{id}]"),
None => String::new(),
};
buffer.append(
Expand Down Expand Up @@ -290,12 +290,12 @@ impl<'a> DisplaySet<'a> {
} => {
let lineno_color = stylesheet.line_no();
if anonymized_line_numbers && lineno.is_some() {
let num = format!("{:>width$} |", ANONYMIZED_LINE_NUM, width = lineno_width);
let num = format!("{ANONYMIZED_LINE_NUM:>lineno_width$} |");
buffer.puts(line_offset, 0, &num, *lineno_color);
} else {
match lineno {
Some(n) => {
let num = format!("{:>width$} |", n, width = lineno_width);
let num = format!("{n:>lineno_width$} |");
buffer.puts(line_offset, 0, &num, *lineno_color);
}
None => {
Expand Down Expand Up @@ -645,7 +645,7 @@ impl<'a> DisplaySet<'a> {
} else if formatted_len != 0 {
formatted_len += 2;
let id = match &annotation.annotation.id {
Some(id) => format!("[{}]", id),
Some(id) => format!("[{id}]"),
None => String::new(),
};
buffer.puts(
Expand Down Expand Up @@ -1292,10 +1292,7 @@ fn format_body(
None
}
}) {
panic!(
"SourceAnnotation range `{:?}` is beyond the end of buffer `{}`",
bigger, source_len
)
panic!("SourceAnnotation range `{bigger:?}` is beyond the end of buffer `{source_len}`")
}

let mut body = vec![];
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn setup(input_path: std::path::PathBuf) -> tryfn::Case {
.to_str()
.unwrap();
let file_name = input_path.file_name().unwrap().to_str().unwrap();
let name = format!("{}/{}", parent, file_name);
let name = format!("{parent}/{file_name}");
let expected = Data::read_from(&input_path.with_extension("svg"), None);
tryfn::Case {
name,
Expand Down

0 comments on commit 220289c

Please sign in to comment.