Skip to content

Commit 013b7e3

Browse files
authored
Update infra with stuff from rerun_template repo (#61)
1 parent b02829c commit 013b7e3

9 files changed

+98
-17
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* text=auto eol=lf
2+
Cargo.lock linguist-generated=false

.github/workflows/cargo_machete.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Cargo Machete
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
types: [opened, synchronize]
9+
10+
jobs:
11+
cargo-machete:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
- name: Machete
17+
run: cargo install cargo-machete --locked && cargo machete

.github/workflows/links.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Copied from https://github.com/rerun-io/rerun_template
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- "main"
6+
pull_request:
7+
types: [ opened, synchronize ]
38

49
name: Link checker
510

.github/workflows/rust.yml

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Copied from https://github.com/rerun-io/rerun_template
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- "main"
6+
pull_request:
7+
types: [ opened, synchronize ]
38

49
name: Rust
510

@@ -129,12 +134,12 @@ jobs:
129134
name: Check Rust dependencies (cargo-deny)
130135
runs-on: ubuntu-latest
131136
steps:
132-
- uses: actions/checkout@v3
133-
- uses: EmbarkStudios/cargo-deny-action@v1
134-
with:
135-
rust-version: "1.80.0"
136-
log-level: warn
137-
command: check
137+
- uses: actions/checkout@v3
138+
- uses: EmbarkStudios/cargo-deny-action@v1
139+
with:
140+
rust-version: "1.80.0"
141+
log-level: warn
142+
command: check
138143

139144
# ---------------------------------------------------------------------------
140145

Cargo.toml

+12-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ disallowed_types = "warn" # See clippy.toml
9292
doc_link_with_quotes = "warn"
9393
doc_markdown = "warn"
9494
empty_enum = "warn"
95+
empty_enum_variants_with_brackets = "warn"
9596
enum_glob_use = "warn"
9697
equatable_if_let = "warn"
9798
exit = "warn"
@@ -115,6 +116,8 @@ inefficient_to_string = "warn"
115116
infinite_loop = "warn"
116117
into_iter_without_iter = "warn"
117118
invalid_upcast_comparisons = "warn"
119+
iter_filter_is_ok = "warn"
120+
iter_filter_is_some = "warn"
118121
iter_not_returning_iterator = "warn"
119122
iter_on_empty_collections = "warn"
120123
iter_on_single_items = "warn"
@@ -125,6 +128,7 @@ large_include_file = "warn"
125128
large_stack_arrays = "warn"
126129
large_stack_frames = "warn"
127130
large_types_passed_by_value = "warn"
131+
let_underscore_must_use = "warn"
128132
let_underscore_untyped = "warn"
129133
let_unit_value = "warn"
130134
linkedlist = "warn"
@@ -133,12 +137,14 @@ macro_use_imports = "warn"
133137
manual_assert = "warn"
134138
manual_clamp = "warn"
135139
manual_instant_elapsed = "warn"
140+
manual_is_variant_and = "warn"
136141
manual_let_else = "warn"
137142
manual_ok_or = "warn"
138143
manual_string_new = "warn"
139144
map_err_ignore = "warn"
140145
map_flatten = "warn"
141146
map_unwrap_or = "warn"
147+
match_bool = "warn"
142148
match_on_vec_items = "warn"
143149
match_same_arms = "warn"
144150
match_wild_err_arm = "warn"
@@ -150,6 +156,7 @@ missing_assert_message = "warn"
150156
missing_enforced_import_renames = "warn"
151157
missing_errors_doc = "warn"
152158
missing_safety_doc = "warn"
159+
mixed_attributes_style = "warn"
153160
mut_mut = "warn"
154161
mutex_integer = "warn"
155162
needless_borrow = "warn"
@@ -159,22 +166,25 @@ needless_pass_by_ref_mut = "warn"
159166
needless_pass_by_value = "warn"
160167
negative_feature_names = "warn"
161168
nonstandard_macro_braces = "warn"
169+
option_as_ref_cloned = "warn"
162170
option_option = "warn"
163171
path_buf_push_overwrite = "warn"
164172
ptr_as_ptr = "warn"
165173
ptr_cast_constness = "warn"
174+
pub_underscore_fields = "warn"
166175
pub_without_shorthand = "warn"
167176
rc_mutex = "warn"
168177
readonly_write_lock = "warn"
169178
redundant_type_annotations = "warn"
179+
ref_as_ptr = "warn"
170180
ref_option_ref = "warn"
171-
ref_patterns = "warn"
172181
rest_pat_in_fully_bound_structs = "warn"
173182
same_functions_in_if_condition = "warn"
174183
semicolon_if_nothing_returned = "warn"
175184
should_panic_without_expect = "warn"
176185
significant_drop_tightening = "warn"
177186
single_match_else = "warn"
187+
str_split_at_newline = "warn"
178188
str_to_string = "warn"
179189
string_add = "warn"
180190
string_add_assign = "warn"
@@ -210,3 +220,4 @@ wildcard_imports = "warn"
210220
zero_sized_map_values = "warn"
211221

212222
manual_range_contains = "allow" # this one is just worse imho
223+
ref_patterns = "allow" # It's nice to avoid ref pattern, but there are some situations that are hard (impossible?) to express without.

RELEASES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ I usually do this all on the `main` branch, but doing it in a release branch is
5353
* [ ] `git commit -m 'Release 0.x.0 - summary'`
5454
* [ ] `cargo publish -p egui_plot`
5555
* [ ] `git tag -a 0.x.0 -m 'Release 0.x.0 - summary'`
56-
* [ ] `git pull --tags ; git tag -d latest && git tag -a latest -m 'Latest release' && git push --tags origin latest --force ; git push --tags`
56+
* [ ] `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`
5757
* [ ] merge release PR or push to `main`
5858
* [ ] check that CI is green
5959
* [ ] do a GitHub release: https://github.com/emilk/egui/releases/new

rust-toolchain

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
[toolchain]
88
channel = "1.80" # Avoid specifying a patch version here; see https://github.com/emilk/eframe_template/issues/145
9-
components = [ "rustfmt", "clippy" ]
10-
targets = [ "wasm32-unknown-unknown" ]
9+
components = ["rustfmt", "clippy"]
10+
targets = ["wasm32-unknown-unknown"]

scripts/generate_changelog.py

+44-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import re
1717
import sys
1818
from dataclasses import dataclass
19+
from datetime import date
1920
from typing import Any, Optional
2021

2122
import requests
@@ -87,11 +88,18 @@ def fetch_pr_info(pr_number: int) -> Optional[PrInfo]:
8788

8889

8990
def get_commit_info(commit: Any) -> CommitInfo:
90-
match = re.match(r"(.*) \(#(\d+)\)", commit.summary)
91-
if match:
91+
# Squash-merge commits:
92+
if match := re.match(r"(.*) \(#(\d+)\)", commit.summary):
9293
title = str(match.group(1))
9394
pr_number = int(match.group(2))
9495
return CommitInfo(hexsha=commit.hexsha, title=title, pr_number=pr_number)
96+
97+
# Normal merge commits:
98+
elif match := re.match(r"Merge pull request #(\d+) from (.*)", commit.summary):
99+
title = str(match.group(2))
100+
pr_number = int(match.group(1))
101+
return CommitInfo(hexsha=commit.hexsha, title=title, pr_number=pr_number)
102+
95103
else:
96104
return CommitInfo(hexsha=commit.hexsha, title=commit.summary, pr_number=None)
97105

@@ -110,13 +118,43 @@ def print_section(crate: str, items: list[str]) -> None:
110118
print()
111119

112120

121+
def calc_commit_range(new_version: str) -> str:
122+
parts = new_version.split(".")
123+
assert len(parts) == 3, "Expected version to be on the format X.Y.Z"
124+
major = int(parts[0])
125+
minor = int(parts[1])
126+
patch = int(parts[2])
127+
128+
if 0 < patch:
129+
# A patch release.
130+
# Include changes since last patch release.
131+
# This assumes we've cherry-picked stuff for this release.
132+
diff_since_version = f"0.{minor}.{patch - 1}"
133+
elif 0 < minor:
134+
# A minor release
135+
# The diff should span everything since the last minor release.
136+
# The script later excludes duplicated automatically, so we don't include stuff that
137+
# was part of intervening patch releases.
138+
diff_since_version = f"{major}.{minor - 1}.0"
139+
else:
140+
# A major release
141+
# The diff should span everything since the last major release.
142+
# The script later excludes duplicated automatically, so we don't include stuff that
143+
# was part of intervening minor/patch releases.
144+
diff_since_version = f"{major - 1}.{minor}.0"
145+
146+
return f"{diff_since_version}..HEAD"
147+
148+
113149
def main() -> None:
114150
parser = argparse.ArgumentParser(description="Generate a changelog.")
115-
parser.add_argument("--commit-range", help="e.g. 0.1.0..HEAD", required=True)
151+
parser.add_argument("--version", required=True, help="The version of the new release, e.g. 0.42.0")
116152
args = parser.parse_args()
117153

154+
commit_range = calc_commit_range(args.version)
155+
118156
repo = Repo(".")
119-
commits = list(repo.iter_commits(args.commit_range))
157+
commits = list(repo.iter_commits(commit_range))
120158
commits.reverse() # Most recent last
121159
commit_infos = list(map(get_commit_info, commits))
122160

@@ -170,8 +208,9 @@ def main() -> None:
170208
line = line[0].upper() + line[1:] # Upper-case first letter
171209
prs[i] = line
172210

211+
print(f"## {args.version} - {date.today()}")
173212
print()
174-
print(f"Full diff at https://github.com/{OWNER}/{REPO}/compare/{args.commit_range}")
213+
print(f"Full diff at https://github.com/{OWNER}/{REPO}/compare/{commit_range}")
175214
print()
176215
print_section("PRs", prs)
177216
print_section("Unsorted commits", unsorted_commits)

scripts/template_update.py

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959

6060
# Files required by Rust, but not by _both_ C++ and Python
6161
RUST_FILES = {
62+
".github/workflows/cargo_machete.yml",
6263
".github/workflows/rust.yml",
6364
"bacon.toml",
6465
"Cargo.lock",
@@ -67,6 +68,7 @@
6768
"clippy.toml",
6869
"Cranky.toml",
6970
"deny.toml",
71+
"RELEASES.md",
7072
"rust-toolchain",
7173
"scripts/clippy_wasm/",
7274
"scripts/clippy_wasm/clippy.toml",

0 commit comments

Comments
 (0)