diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..b1f5e11 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=auto eol=lf +Cargo.lock linguist-generated=false 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 373d0c7..e5301fe 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 @@ -129,12 +134,12 @@ jobs: name: Check Rust dependencies (cargo-deny) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: EmbarkStudios/cargo-deny-action@v1 - with: - rust-version: "1.80.0" - log-level: warn - command: check + - uses: actions/checkout@v3 + - uses: EmbarkStudios/cargo-deny-action@v1 + with: + rust-version: "1.80.0" + log-level: warn + command: check # --------------------------------------------------------------------------- diff --git a/Cargo.toml b/Cargo.toml index 791f95c..934a12b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,6 +92,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" @@ -115,6 +116,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" @@ -125,6 +128,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" @@ -133,12 +137,14 @@ 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" map_err_ignore = "warn" map_flatten = "warn" map_unwrap_or = "warn" +match_bool = "warn" match_on_vec_items = "warn" match_same_arms = "warn" match_wild_err_arm = "warn" @@ -150,6 +156,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" @@ -159,22 +166,25 @@ 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" -ref_patterns = "warn" rest_pat_in_fully_bound_structs = "warn" same_functions_in_if_condition = "warn" 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" @@ -210,3 +220,4 @@ wildcard_imports = "warn" zero_sized_map_values = "warn" manual_range_contains = "allow" # this one is just worse imho +ref_patterns = "allow" # It's nice to avoid ref pattern, but there are some situations that are hard (impossible?) to express without. diff --git a/RELEASES.md b/RELEASES.md index 824cd72..34ee514 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -53,7 +53,7 @@ I usually do this all on the `main` branch, but doing it in a release branch is * [ ] `git commit -m 'Release 0.x.0 - summary'` * [ ] `cargo publish -p egui_plot` * [ ] `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 --tags` +* [ ] `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` * [ ] merge release PR or push to `main` * [ ] check that CI is green * [ ] do a GitHub release: https://github.com/emilk/egui/releases/new diff --git a/rust-toolchain b/rust-toolchain index d4417fd..0ce0490 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -6,5 +6,5 @@ [toolchain] 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" ] +components = ["rustfmt", "clippy"] +targets = ["wasm32-unknown-unknown"] diff --git a/scripts/generate_changelog.py b/scripts/generate_changelog.py index b76d8cc..c030c89 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 @@ -87,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) @@ -110,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)) @@ -170,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/{OWNER}/{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 201871e..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",