Skip to content

Commit

Permalink
Update infra with stuff from rerun_template repo
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Dec 17, 2024
1 parent b02829c commit 37c6b1d
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto eol=lf
Cargo.lock linguist-generated=false
17 changes: 17 additions & 0 deletions .github/workflows/cargo_machete.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion .github/workflows/links.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
19 changes: 12 additions & 7 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

# ---------------------------------------------------------------------------

Expand Down
13 changes: 12 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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.
2 changes: 1 addition & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
49 changes: 44 additions & 5 deletions scripts/generate_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import re
import sys
from dataclasses import dataclass
from datetime import date
from typing import Any, Optional

import requests
Expand Down Expand Up @@ -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)

Expand All @@ -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))

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions scripts/template_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -67,6 +68,7 @@
"clippy.toml",
"Cranky.toml",
"deny.toml",
"RELEASES.md",
"rust-toolchain",
"scripts/clippy_wasm/",
"scripts/clippy_wasm/clippy.toml",
Expand Down

0 comments on commit 37c6b1d

Please sign in to comment.