Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
19 changes: 7 additions & 12 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust
name: CI
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Harden workflow + cancel redundant runs

Add least-privilege permissions and PR-run concurrency; also bump checkout to v4.

Apply:

 name: CI
+permissions:
+  contents: read
+
 on:
   pull_request:
     branches: ["main"]
@@
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4

Optionally cap job runtime:

 jobs:
   build:
     runs-on: ubuntu-latest
+    timeout-minutes: 20
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name: CI
name: CI
permissions:
contents: read
on:
pull_request:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
# … other steps …
🤖 Prompt for AI Agents
.github/workflows/pr.yml around line 1: the workflow needs hardening and run
deduplication; update the top-level workflow to (1) add a permissions block
granting only required least-privilege scopes for the jobs (e.g., read:
contents, pull-requests; write only what is needed), (2) add a concurrency key
that cancels redundant PR runs (e.g., concurrency: { group: 'pr-${{ github.ref
}}', cancel-in-progress: true }), (3) bump actions/checkout from v3 to v4 in the
checkout step, and (4) optionally add timeout-minutes on long-running jobs to
cap runtime; make these edits directly in .github/workflows/pr.yml.


on:
pull_request:
Expand All @@ -14,21 +14,16 @@ jobs:
steps:
- uses: actions/checkout@v3

# Install Rust with clippy/rustfmt
- uses: actions-rust-lang/setup-rust-toolchain@v1
# Install Nix
- uses: cachix/install-nix-action@v27
with:
target: wasm32-unknown-unknown
components: clippy, rustfmt
github_access_token: ${{ secrets.GITHUB_TOKEN }}

# Install Just to run CI scripts
- uses: extractions/setup-just@v3

# Cargo binstall is used to install tools faster than compiling them from source.
- uses: cargo-bins/cargo-binstall@main
- run: just setup-tools
# Use our flake to get all development tools (Rust, pnpm, just, cargo tools, etc.)
- run: nix develop --command echo "Development environment ready"

# Set RUSTFLAGS
- run: echo "RUSTFLAGS=--cfg=web_sys_unstable_apis" >> $GITHUB_ENV

# Make sure u guys don't write bad code
- run: just check
- run: nix develop --command just check
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
target
Cargo.lock

# Node.js
node_modules/
dist/

# Direnv
.direnv/
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ members = [
"web-transport",
"web-transport-proto",
"web-transport-quinn",
"web-transport-tauri",
"web-transport-trait",
"web-transport-wasm",
"web-transport-ws",
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This project is broken up into quite a few different crates:
- [web-transport](web-transport) provides a generic interface, delegating to [web-transport-quinn](web-transport-quinn) or [web-transport-wasm](web-transport-wasm) depending on the platform.
- [web-transport-quinn](web-transport-quinn) mirrors the [Quinn API](https://docs.rs/quinn/latest/quinn/index.html), abstracting away the HTTP/3 setup.
- [web-transport-wasm](web-transport-wasm) wraps the [browser API](https://developer.mozilla.org/en-US/docs/Web/API/WebTransport_API)
- [web-transport-ws](web-transport-ws) crudely implements the WebTransport API over WebSockets for backwards compatibility. Also includes a NPM package.
- [web-transport-tauri](web-transport-tauri) polyfills the WebTransport API using Tauri. The web client communicates with the Rust client via a JSON RPC.
- [web-transport-ws](web-transport-ws) polyfills the WebTransport API using WebSockets. The web client communicates with the Rust server.
- [web-transport-trait](web-transport-trait) defines an async trait, currently implemented by [web-transport-quinn](web-transport-quinn) and [web-transport-ws](web-transport-ws).
- [web-transport-proto](web-transport-proto) a bare minimum implementation of HTTP/3 just to establish the WebTransport session.
36 changes: 36 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// This has to be in the root otherwise the VSCode plugin will not work out of the box.
{
"$schema": "https://biomejs.dev/schemas/2.2.3/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"formatter": {
// We repeat the editorconfig settings here because biome has spotty mono-repo support.
// "useEditorconfig": true,
"lineWidth": 120,
"indentStyle": "tab",
"indentWidth": 4,
"lineEnding": "lf"
},
"files": {
"includes": ["**", "!**/permissions/schemas/*.json"]
},
"linter": {
"rules": {
"style": {
"useNodejsImportProtocol": "off"
},
"suspicious": {
// Some runtimes need ts-ignore
"noTsIgnore": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
description = "Web Transport development environment";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };

rustTools = [
pkgs.rustc
pkgs.cargo
pkgs.rustfmt
pkgs.clippy
pkgs.cargo-shear
pkgs.cargo-sort
pkgs.cargo-edit
];

jsTools = [
pkgs.nodejs_24
pkgs.pnpm_10
pkgs.biome
];

tools = [
pkgs.just
];
in
{
devShells.default = pkgs.mkShell {
packages = rustTools ++ jsTools ++ tools;
};
}
);
}
23 changes: 10 additions & 13 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@ default:

# Install any required dependencies.
setup:
# Install cargo-binstall for faster tool installation.
cargo install cargo-binstall
just setup-tools

# A separate entrypoint for CI.
setup-tools:
cargo binstall -y cargo-shear cargo-sort cargo-upgrades cargo-edit
cargo install -y cargo-shear cargo-sort cargo-upgrades cargo-edit
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

cargo install -y is invalid; remove -y and optionally gate installs.

cargo install doesn’t support -y. This will fail the setup step.

Apply this diff:

-	cargo install -y cargo-shear cargo-sort cargo-upgrades cargo-edit
+	# Install only missing tools; keep reproducible with --locked
+	set -eu
+	for crate in cargo-shear cargo-sort cargo-upgrades cargo-edit; do
+	  if ! command -v "$crate" >/dev/null 2>&1; then
+	    cargo install --locked "$crate"
+	  fi
+	done
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cargo install -y cargo-shear cargo-sort cargo-upgrades cargo-edit
# Install only missing tools; keep reproducible with --locked
set -eu
for crate in cargo-shear cargo-sort cargo-upgrades cargo-edit; do
if ! command -v "$crate" >/dev/null 2>&1; then
cargo install --locked "$crate"
fi
done
🤖 Prompt for AI Agents
In justfile around line 14, the command uses an unsupported flag "-y" with
"cargo install"; remove the "-y" so it reads "cargo install cargo-shear
cargo-sort cargo-upgrades cargo-edit". Optionally wrap the installs behind a
guard (check if each binary is already installed or gate with an environment
variable) to avoid reinstalling during CI or local runs.


# Run the CI checks
check:
cargo check --all-targets --all-features
cargo test --all-targets --all-features
cargo clippy --all-targets --all-features -- -D warnings

# Do the same but explicitly use the WASM target.
Expand All @@ -37,17 +31,16 @@ check:
# requires: cargo install cargo-sort
cargo sort --workspace --check

# Run any CI tests
test:
cargo test
# JavaScript/TypeScript checks
pnpm install --frozen-lockfile
pnpm -r run check
pnpm exec biome check

# Automatically fix some issues.
fix:
cargo fix --allow-staged --all-targets --all-features
cargo clippy --fix --allow-staged --all-targets --all-features

# Do the same but explicitly use the WASM target.
cargo fix --allow-staged --all-targets --all-features --target wasm32-unknown-unknown -p web-transport
cargo clippy --fix --allow-staged --all-targets --all-features --target wasm32-unknown-unknown -p web-transport

# requires: cargo install cargo-shear
Expand All @@ -59,6 +52,10 @@ fix:
# And of course, make sure the formatting is correct.
cargo fmt --all

# JavaScript/TypeScript fixes
pnpm install
pnpm exec biome check --fix

# Upgrade any tooling
upgrade:
rustup upgrade
Expand Down
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "web-transport-workspace",
"private": true,
"type": "module",
"engines": {
"node": ">=18"
},
"scripts": {
"build": "pnpm -r build",
"dev": "pnpm -r dev",
"check": "pnpm -r check",
"clean": "pnpm -r clean && rimraf dist node_modules/.cache",
"install-all": "pnpm install --frozen-lockfile"
},
"devDependencies": {
"typescript": "^5.9.2",
"rimraf": "^6.0.1",
"@types/node": "^24.3.0",
"tsx": "^4.20.5",
"@biomejs/biome": "^2.2.2"
}
}
Loading
Loading