From 6627c453f45e55b40f1b2521ea71f721b40d5339 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 11 Nov 2024 15:55:15 +0100 Subject: [PATCH 1/3] Update repo based on https://github.com/rerun-io/rerun_template/ --- .gitattributes | 2 ++ .github/pull_request_template.md | 13 ++++++++ .github/workflows/cargo_machete.yml | 17 ++++++++++ .github/workflows/links.yml | 7 ++++- .github/workflows/rust.yml | 20 +++++++----- .typos.toml | 2 +- RELEASES.md | 9 ++++++ deny.toml | 4 +-- release_checklist.md | 11 ------- rust-toolchain | 2 +- scripts/generate_changelog.py | 48 ++++++++++++++++++++--------- scripts/template_update.py | 13 ++++++-- 12 files changed, 108 insertions(+), 40 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/cargo_machete.yml create mode 100644 RELEASES.md delete mode 100644 release_checklist.md 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/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..52f1457 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,13 @@ + + +* Closes #ISSUE_NUMBER diff --git a/.github/workflows/cargo_machete.yml b/.github/workflows/cargo_machete.yml new file mode 100644 index 0000000..71b959a --- /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 + uses: bnjbvr/cargo-machete@main 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 b6a713f..dbaffa2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,13 +1,15 @@ # Copied from https://github.com/rerun-io/rerun_template -on: [push, pull_request] +on: + push: + branches: + - "main" + pull_request: + types: [ opened, synchronize ] name: Rust env: - # --cfg=web_sys_unstable_apis is required to enable the web_sys clipboard API which egui_web uses - # https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html - # https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html - RUSTFLAGS: -D warnings --cfg=web_sys_unstable_apis + RUSTFLAGS: -D warnings RUSTDOCFLAGS: -D warnings jobs: @@ -24,10 +26,11 @@ jobs: override: true - name: Install packages (Linux) + if: runner.os == 'Linux' uses: awalsh128/cache-apt-pkgs-action@v1.3.0 with: - # Some deps used by eframe: - packages: libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev + # some deps used by eframe, if that is part of the project + packages: libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev # libgtk-3-dev is used by rfd version: 1.0 execute_install_scripts: true @@ -107,6 +110,7 @@ jobs: toolchain: 1.76.0 target: wasm32-unknown-unknown override: true + components: clippy - name: Set up cargo cache uses: Swatinem/rust-cache@v2 @@ -152,4 +156,4 @@ jobs: - name: Build run: cd example_app && ../trunk build --release --public-url $public_url --dist ../dist/ env: - public_url: "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}" \ No newline at end of file + public_url: "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}" diff --git a/.typos.toml b/.typos.toml index fbea054..aae3ebb 100644 --- a/.typos.toml +++ b/.typos.toml @@ -7,4 +7,4 @@ extend-exclude = ["docs/example_app.js"] [default.extend-words] -teh = "teh" # part of @teh-cmc +teh = "teh" # part of @teh-cmc diff --git a/RELEASES.md b/RELEASES.md new file mode 100644 index 0000000..0308c1a --- /dev/null +++ b/RELEASES.md @@ -0,0 +1,9 @@ +# Release Checklist + +* [ ] 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 new_project_name` +* [ ] `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/new_repo_name/releases/new diff --git a/deny.toml b/deny.toml index ea8767f..fb66fd1 100644 --- a/deny.toml +++ b/deny.toml @@ -35,7 +35,7 @@ ignore = [] [bans] multiple-versions = "deny" -wildcards = "allow" # We use them for examples +wildcards = "deny" deny = [ { name = "openssl", reason = "Use rustls" }, { name = "openssl-sys", reason = "Use rustls" }, @@ -58,7 +58,7 @@ allow = [ "BSL-1.0", # https://tldrlegal.com/license/boost-software-license-1.0-explained "CC0-1.0", # https://creativecommons.org/publicdomain/zero/1.0/ "ISC", # https://www.tldrlegal.com/license/isc-license - "LicenseRef-UFL-1.0", # See https://github.com/emilk/egui/issues/2321 + "LicenseRef-UFL-1.0", # no official SPDX, see https://github.com/emilk/egui/issues/2321 "MIT-0", # https://choosealicense.com/licenses/mit-0/ "MIT", # https://tldrlegal.com/license/mit-license "MPL-2.0", # https://www.mozilla.org/en-US/MPL/2.0/FAQ/ - see Q11. Used by webpki-roots on Linux. diff --git a/release_checklist.md b/release_checklist.md deleted file mode 100644 index adbe37d..0000000 --- a/release_checklist.md +++ /dev/null @@ -1,11 +0,0 @@ -- [ ] Update `CHANGELOG.md` with `./scripts/generate_changelog.py` -- [ ] Bump version number -- [ ] `(cd example_app && trunk serve)` -- [ ] `git commit -m 'Release 0.x.0 - summary'` -- [ ] `cargo publish -p ewebsock` -- [ ] `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 && git push --tags` -- [ ] Check that CI is green -- [ ] Do a GitHub release: https://github.com/rerun-io/ewebsock/releases/new -- [ ] Post on Twitter diff --git a/rust-toolchain b/rust-toolchain index 871f562..ae5c85c 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.76.0" +channel = "1.76" # 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/generate_changelog.py b/scripts/generate_changelog.py index 033c2d4..60ad831 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 = "ewebsock" INCLUDE_LABELS = False # It adds quite a bit of visual noise -OFFICIAL_RERUN_DEVS = [ - "abey79", - "emilk", - "jleibs", - "jprochazk", - "nikolausWest", - "teh-cmc", - "Wumpf", -] @dataclass @@ -119,13 +111,41 @@ def print_section(crate: str, items: list[str]) -> None: print() +def 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() repo = Repo(".") - commits = list(repo.iter_commits(args.commit_range)) + commits = list(repo.iter_commits(commit_range(args.version))) commits.reverse() # Most recent last commit_infos = list(map(get_commit_info, commits)) @@ -169,8 +189,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 +199,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/{args.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 163a7d3..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,6 +107,13 @@ def init(languages: set[str], dry_run: bool) -> None: delete_files_and_folder(files_to_delete, dry_run) +def remove_file(filepath: str) -> None: + try: + os.remove(filepath) + except FileNotFoundError: + pass + + def delete_files_and_folder(paths: set[str], dry_run: bool) -> None: repo_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) for path in paths: @@ -113,7 +122,7 @@ def delete_files_and_folder(paths: set[str], dry_run: bool) -> None: if os.path.isfile(full_path): print(f"Removing file {full_path}…") if not dry_run: - os.remove(full_path) + remove_file(full_path) elif os.path.isdir(full_path): print(f"Removing folder {full_path}…") if not dry_run: @@ -124,7 +133,7 @@ def update(languages: set[str], dry_run: bool) -> None: for file in DEAD_FILES: print(f"Removing dead file {file}…") if not dry_run: - os.remove(file) + remove_file(file) files_to_ignore = calc_deny_set(languages) | DO_NOT_OVERWRITE repo_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) From 366537b57921a9a5ffaa89c8e8b2b12b08131d5c Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 11 Nov 2024 16:01:50 +0100 Subject: [PATCH 2/3] fix releases.md --- RELEASES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 0308c1a..4afb5c6 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -3,7 +3,7 @@ * [ ] 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 new_project_name` +* [ ] `cargo publish --quiet -p ewebsock` * [ ] `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/new_repo_name/releases/new +* [ ] Do a GitHub release: https://github.com/rerun-io/ewebsock/releases/new From bb2cf51548dae140ec095d18d1a1ffdfd6f9512a Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 11 Nov 2024 16:05:58 +0100 Subject: [PATCH 3/3] Update some crates and crate imports --- Cargo.lock | 32 ++++++++++++++++---------------- Cargo.toml | 2 ++ example_app/Cargo.toml | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6284af7..4ae67bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -554,9 +554,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytemuck" -version = "1.14.3" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" +checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" dependencies = [ "bytemuck_derive", ] @@ -1237,9 +1237,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1247,9 +1247,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" @@ -1264,9 +1264,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" @@ -1283,9 +1283,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -1294,21 +1294,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", diff --git a/Cargo.toml b/Cargo.toml index 834685a..7ebbb03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,8 @@ members = ["ewebsock", "example_app", "echo_server"] [workspace.dependencies] +ewebsock = { version = "0.7.0", path = "ewebsock", default-features = false } + async-stream = "0.3" document-features = "0.2" eframe = "0.29.1" diff --git a/example_app/Cargo.toml b/example_app/Cargo.toml index 586cfd1..9248dd5 100644 --- a/example_app/Cargo.toml +++ b/example_app/Cargo.toml @@ -17,7 +17,7 @@ tokio = ["ewebsock/tokio", "dep:tokio"] [dependencies] -ewebsock = { path = "../ewebsock", features = ["tls"] } +ewebsock = { workspace = true, features = ["tls"] } eframe.workspace = true log.workspace = true