From 9e3f116caa4abe952c720ff733a47a40e495d491 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Dec 2024 18:41:32 +0100 Subject: [PATCH 1/5] Update MSRV to 1.80 --- .github/workflows/cargo_machete.yml | 17 ++++++++ .github/workflows/links.yml | 7 +++- .github/workflows/rust.yml | 14 +++++-- Cargo.toml | 20 +++++++--- RELEASES.md | 6 +-- clippy.toml | 2 +- rust-toolchain | 2 +- scripts/clippy_wasm/clippy.toml | 2 +- scripts/generate_changelog.py | 61 +++++++++++++++++++++-------- scripts/template_update.py | 4 +- 10 files changed, 101 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/cargo_machete.yml diff --git a/.github/workflows/cargo_machete.yml b/.github/workflows/cargo_machete.yml new file mode 100644 index 0000000..0a74614 --- /dev/null +++ b/.github/workflows/cargo_machete.yml @@ -0,0 +1,17 @@ +name: Cargo Machete + +on: + push: + branches: + - "main" + pull_request: + types: [opened, synchronize] + +jobs: + cargo-machete: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Machete + run: cargo install cargo-machete --locked && cargo machete diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml index 8bb984c..aeb663d 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/links.yml @@ -1,5 +1,10 @@ # Copied from https://github.com/rerun-io/rerun_template -on: [push, pull_request] +on: + push: + branches: + - "main" + pull_request: + types: [ opened, synchronize ] name: Link checker diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5826ddb..d38333f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,5 +1,10 @@ # Copied from https://github.com/rerun-io/rerun_template -on: [push, pull_request] +on: + push: + branches: + - "main" + pull_request: + types: [ opened, synchronize ] name: Rust @@ -17,7 +22,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: default - toolchain: 1.77.0 + toolchain: 1.80.0 override: true - name: Install packages (Linux) @@ -102,9 +107,10 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.77.0 + toolchain: 1.80.0 target: wasm32-unknown-unknown override: true + components: clippy - name: Set up cargo cache uses: Swatinem/rust-cache@v2 @@ -129,6 +135,6 @@ jobs: - uses: actions/checkout@v3 - uses: EmbarkStudios/cargo-deny-action@v1 with: - rust-version: "1.77.0" + rust-version: "1.80.0" log-level: warn command: check diff --git a/Cargo.toml b/Cargo.toml index 5e441a2..a64659a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" name = "egui_tiles" readme = "README.md" repository = "https://github.com/rerun-io/egui_tiles" -rust-version = "1.77" +rust-version = "1.80" version = "0.10.1" [package.metadata.docs.rs] @@ -72,13 +72,13 @@ workspace = true unsafe_code = "deny" elided_lifetimes_in_paths = "warn" -future_incompatible = "warn" -nonstandard_style = "warn" -rust_2018_idioms = "warn" +future_incompatible = { level = "warn", priority = -1 } +nonstandard_style = { level = "warn", priority = -1 } +rust_2018_idioms = { level = "warn", priority = -1 } rust_2021_prelude_collisions = "warn" semicolon_in_expressions_from_macros = "warn" trivial_numeric_casts = "warn" -unsafe_op_in_unsafe_fn = "warn" # `unsafe_op_in_unsafe_fn` may become the default in future Rust versions: https://github.com/rust-lang/rust/issues/71668 +unsafe_op_in_unsafe_fn = "warn" # `unsafe_op_in_unsafe_fn` may become the default in future Rust versions: https://github.com/rust-lang/rust/issues/71668 unused_extern_crates = "warn" unused_import_braces = "warn" unused_lifetimes = "warn" @@ -110,6 +110,7 @@ disallowed_types = "warn" # See clippy.toml doc_link_with_quotes = "warn" doc_markdown = "warn" empty_enum = "warn" +empty_enum_variants_with_brackets = "warn" enum_glob_use = "warn" equatable_if_let = "warn" exit = "warn" @@ -133,6 +134,8 @@ inefficient_to_string = "warn" infinite_loop = "warn" into_iter_without_iter = "warn" invalid_upcast_comparisons = "warn" +iter_filter_is_ok = "warn" +iter_filter_is_some = "warn" iter_not_returning_iterator = "warn" iter_on_empty_collections = "warn" iter_on_single_items = "warn" @@ -143,6 +146,7 @@ large_include_file = "warn" large_stack_arrays = "warn" large_stack_frames = "warn" large_types_passed_by_value = "warn" +let_underscore_must_use = "warn" let_underscore_untyped = "warn" let_unit_value = "warn" linkedlist = "warn" @@ -151,6 +155,7 @@ macro_use_imports = "warn" manual_assert = "warn" manual_clamp = "warn" manual_instant_elapsed = "warn" +manual_is_variant_and = "warn" manual_let_else = "warn" manual_ok_or = "warn" manual_string_new = "warn" @@ -169,6 +174,7 @@ missing_assert_message = "warn" missing_enforced_import_renames = "warn" missing_errors_doc = "warn" missing_safety_doc = "warn" +mixed_attributes_style = "warn" mut_mut = "warn" mutex_integer = "warn" needless_borrow = "warn" @@ -178,14 +184,17 @@ needless_pass_by_ref_mut = "warn" needless_pass_by_value = "warn" negative_feature_names = "warn" nonstandard_macro_braces = "warn" +option_as_ref_cloned = "warn" option_option = "warn" path_buf_push_overwrite = "warn" ptr_as_ptr = "warn" ptr_cast_constness = "warn" +pub_underscore_fields = "warn" pub_without_shorthand = "warn" rc_mutex = "warn" readonly_write_lock = "warn" redundant_type_annotations = "warn" +ref_as_ptr = "warn" ref_option_ref = "warn" rest_pat_in_fully_bound_structs = "warn" same_functions_in_if_condition = "warn" @@ -193,6 +202,7 @@ semicolon_if_nothing_returned = "warn" should_panic_without_expect = "warn" significant_drop_tightening = "warn" single_match_else = "warn" +str_split_at_newline = "warn" str_to_string = "warn" string_add = "warn" string_add_assign = "warn" diff --git a/RELEASES.md b/RELEASES.md index 96bc93e..3e1f52a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,11 +1,9 @@ # Release Checklist -* [ ] Update `CHANGELOG.md` using `./scripts/generate_changelog.py --commit-range 0.x.y..HEAD` -* [ ] Bump version numbers +* [ ] Update `CHANGELOG.md` using `./scripts/generate_changelog.py --version 0.NEW.VERSION` +* [ ] Bump version numbers in `Cargo.toml` and run `cargo check`. * [ ] `git commit -m 'Release 0.x.0 - summary'` * [ ] `cargo publish --quiet -p egui_tiles` * [ ] `git tag -a 0.x.0 -m 'Release 0.x.0 - summary'` * [ ] `git pull --tags && git tag -d latest && git tag -a latest -m 'Latest release' && git push --tags origin latest --force && git push origin main ; git push --tags` * [ ] Do a GitHub release: https://github.com/rerun-io/egui_tiles/releases/new -* [ ] Wait for documentation to build: https://docs.rs/releases/queue -* [ ] Post on Twitter diff --git a/clippy.toml b/clippy.toml index 9679663..af7d2b4 100644 --- a/clippy.toml +++ b/clippy.toml @@ -5,7 +5,7 @@ # ----------------------------------------------------------------------------- # Section identical to scripts/clippy_wasm/clippy.toml: -msrv = "1.77" +msrv = "1.80" allow-unwrap-in-tests = true diff --git a/rust-toolchain b/rust-toolchain index ed934c1..0ce0490 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -5,6 +5,6 @@ # to the user in the error, instead of "error: invalid channel name '[toolchain]'". [toolchain] -channel = "1.77.0" +channel = "1.80" # Avoid specifying a patch version here; see https://github.com/emilk/eframe_template/issues/145 components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] diff --git a/scripts/clippy_wasm/clippy.toml b/scripts/clippy_wasm/clippy.toml index 71cfefb..d3bbc55 100644 --- a/scripts/clippy_wasm/clippy.toml +++ b/scripts/clippy_wasm/clippy.toml @@ -8,7 +8,7 @@ # ----------------------------------------------------------------------------- # Section identical to the main clippy.toml: -msrv = "1.77" +msrv = "1.80" allow-unwrap-in-tests = true diff --git a/scripts/generate_changelog.py b/scripts/generate_changelog.py index 6102688..9fa25ad 100755 --- a/scripts/generate_changelog.py +++ b/scripts/generate_changelog.py @@ -16,6 +16,7 @@ import re import sys from dataclasses import dataclass +from datetime import date from typing import Any, Optional import requests @@ -25,15 +26,6 @@ OWNER = "rerun-io" REPO = "egui_tiles" INCLUDE_LABELS = False # It adds quite a bit of visual noise -OFFICIAL_RERUN_DEVS = [ - "abey79", - "emilk", - "jleibs", - "jprochazk", - "nikolausWest", - "teh-cmc", - "Wumpf", -] @dataclass @@ -96,11 +88,18 @@ def fetch_pr_info(pr_number: int) -> Optional[PrInfo]: def get_commit_info(commit: Any) -> CommitInfo: - match = re.match(r"(.*) \(#(\d+)\)", commit.summary) - if match: + # Squash-merge commits: + if match := re.match(r"(.*) \(#(\d+)\)", commit.summary): title = str(match.group(1)) pr_number = int(match.group(2)) return CommitInfo(hexsha=commit.hexsha, title=title, pr_number=pr_number) + + # Normal merge commits: + elif match := re.match(r"Merge pull request #(\d+) from (.*)", commit.summary): + title = str(match.group(2)) + pr_number = int(match.group(1)) + return CommitInfo(hexsha=commit.hexsha, title=title, pr_number=pr_number) + else: return CommitInfo(hexsha=commit.hexsha, title=commit.summary, pr_number=None) @@ -119,13 +118,43 @@ def print_section(crate: str, items: list[str]) -> None: print() +def calc_commit_range(new_version: str) -> str: + parts = new_version.split(".") + assert len(parts) == 3, "Expected version to be on the format X.Y.Z" + major = int(parts[0]) + minor = int(parts[1]) + patch = int(parts[2]) + + if 0 < patch: + # A patch release. + # Include changes since last patch release. + # This assumes we've cherry-picked stuff for this release. + diff_since_version = f"0.{minor}.{patch - 1}" + elif 0 < minor: + # A minor release + # The diff should span everything since the last minor release. + # The script later excludes duplicated automatically, so we don't include stuff that + # was part of intervening patch releases. + diff_since_version = f"{major}.{minor - 1}.0" + else: + # A major release + # The diff should span everything since the last major release. + # The script later excludes duplicated automatically, so we don't include stuff that + # was part of intervening minor/patch releases. + diff_since_version = f"{major - 1}.{minor}.0" + + return f"{diff_since_version}..HEAD" + + def main() -> None: parser = argparse.ArgumentParser(description="Generate a changelog.") - parser.add_argument("--commit-range", help="e.g. 0.1.0..HEAD", required=True) + parser.add_argument("--version", required=True, help="The version of the new release, e.g. 0.42.0") args = parser.parse_args() + commit_range = calc_commit_range(args.version) + repo = Repo(".") - commits = list(repo.iter_commits(args.commit_range)) + commits = list(repo.iter_commits(commit_range)) commits.reverse() # Most recent last commit_infos = list(map(get_commit_info, commits)) @@ -169,8 +198,7 @@ def main() -> None: if pr_info is not None: gh_user_name = pr_info.gh_user_name - if gh_user_name not in OFFICIAL_RERUN_DEVS: - summary += f" (thanks [@{gh_user_name}](https://github.com/{gh_user_name})!)" + summary += f" by [@{gh_user_name}](https://github.com/{gh_user_name})" prs.append(summary) @@ -180,8 +208,9 @@ def main() -> None: line = line[0].upper() + line[1:] # Upper-case first letter prs[i] = line + print(f"## {args.version} - {date.today()}") print() - print(f"Full diff at https://github.com/rerun-io/{REPO}/compare/{args.commit_range}") + print(f"Full diff at https://github.com/{OWNER}/{REPO}/compare/{commit_range}") print() print_section("PRs", prs) print_section("Unsorted commits", unsorted_commits) diff --git a/scripts/template_update.py b/scripts/template_update.py index 04710e0..1e4ac02 100755 --- a/scripts/template_update.py +++ b/scripts/template_update.py @@ -59,6 +59,7 @@ # Files required by Rust, but not by _both_ C++ and Python RUST_FILES = { + ".github/workflows/cargo_machete.yml", ".github/workflows/rust.yml", "bacon.toml", "Cargo.lock", @@ -67,6 +68,7 @@ "clippy.toml", "Cranky.toml", "deny.toml", + "RELEASES.md", "rust-toolchain", "scripts/clippy_wasm/", "scripts/clippy_wasm/clippy.toml", @@ -105,7 +107,7 @@ def init(languages: set[str], dry_run: bool) -> None: delete_files_and_folder(files_to_delete, dry_run) -def remove_file(filepath: str): +def remove_file(filepath: str) -> None: try: os.remove(filepath) except FileNotFoundError: From 2ced2124b150d69a513e164bf816d71afdf224c7 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Dec 2024 18:42:38 +0100 Subject: [PATCH 2/5] Update url --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79cb62a..ada4d85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1751,9 +1751,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", From 95f703fd44d37d6191678ba8e1a6f815bd26ca6b Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Dec 2024 18:44:19 +0100 Subject: [PATCH 3/5] Allow unicode 3.0 license --- deny.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/deny.toml b/deny.toml index bdb87c5..049d8ee 100644 --- a/deny.toml +++ b/deny.toml @@ -64,6 +64,7 @@ allow = [ "MPL-2.0", # https://www.mozilla.org/en-US/MPL/2.0/FAQ/ - see Q11. Used by webpki-roots on Linux. "OFL-1.1", # https://spdx.org/licenses/OFL-1.1.html "OpenSSL", # https://www.openssl.org/source/license.html - used on Linux + "Unicode-3.0", # https://www.unicode.org/license.txt "Unicode-DFS-2016", # https://spdx.org/licenses/Unicode-DFS-2016.html "Zlib", # https://tldrlegal.com/license/zlib-libpng-license-(zlib) ] From e9f6bb5af917b97a5ee776523d42ece6d8adb378 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Dec 2024 18:46:32 +0100 Subject: [PATCH 4/5] clippy fixes --- src/container/linear.rs | 6 +++--- src/tiles.rs | 2 +- src/tree.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/container/linear.rs b/src/container/linear.rs index 3747a8f..795538e 100644 --- a/src/container/linear.rs +++ b/src/container/linear.rs @@ -116,7 +116,7 @@ impl Linear { } } - fn visible_children(&mut self, tiles: &Tiles) -> Vec { + fn visible_children(&self, tiles: &Tiles) -> Vec { self.children .iter() .copied() @@ -168,7 +168,7 @@ impl Linear { } fn layout_horizontal( - &mut self, + &self, tiles: &mut Tiles, style: &egui::Style, behavior: &mut dyn Behavior, @@ -192,7 +192,7 @@ impl Linear { } fn layout_vertical( - &mut self, + &self, tiles: &mut Tiles, style: &egui::Style, behavior: &mut dyn Behavior, diff --git a/src/tiles.rs b/src/tiles.rs index 6ea752f..54535c4 100644 --- a/src/tiles.rs +++ b/src/tiles.rs @@ -191,7 +191,7 @@ impl Tiles { let mut id = TileId::from_u64(self.next_tile_id); // Make sure it doesn't collide with an existing id - while self.tiles.get(&id).is_some() { + while self.tiles.contains_key(&id) { self.next_tile_id += 1; id = TileId::from_u64(self.next_tile_id); } diff --git a/src/tree.rs b/src/tree.rs index e9ce826..28ae07a 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -460,7 +460,7 @@ impl Tree { if let Some(Tile::Pane(pane)) = self.tiles.get_mut(dragged_tile_id) { // Intentionally ignore the response, since the user cannot possibly // begin a drag on the preview pane. - let _: UiResponse = behavior.pane_ui( + let _ignored: UiResponse = behavior.pane_ui( &mut ui.new_child(egui::UiBuilder::new().max_rect(preview_rect)), dragged_tile_id, pane, From 2f0c4ac8a79e8ff71bfcf10cd498caad6aee04cb Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Dec 2024 19:06:41 +0100 Subject: [PATCH 5/5] clippy --- examples/advanced.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/advanced.rs b/examples/advanced.rs index 936917e..bf1a122 100644 --- a/examples/advanced.rs +++ b/examples/advanced.rs @@ -42,7 +42,7 @@ impl Pane { Self { nr } } - pub fn ui(&mut self, ui: &mut egui::Ui) -> egui_tiles::UiResponse { + pub fn ui(&self, ui: &mut egui::Ui) -> egui_tiles::UiResponse { let color = egui::epaint::Hsva::new(0.103 * self.nr as f32, 0.5, 0.5, 1.0); ui.painter().rect_filled(ui.max_rect(), 0.0, color); let dragged = ui