Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 8 additions & 6 deletions .github/scripts/check-file-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ set -euo pipefail
minimum="${1:-90}"
report="${2:-coverage.json}"
workspace_root="$(pwd -P)/"
contract_root="${workspace_root}crates/tinyhosts-bus/src/"
source_root="${workspace_root}src/"

cargo llvm-cov \
--locked \
--workspace \
--all-targets \
--all-features \
--json \
--output-path "$report"

covered_files="$(jq --arg source_root "$source_root" '
covered_files="$(jq --arg source_root "$source_root" --arg contract_root "$contract_root" '
[
.data[].files[]
| select(.filename | startswith($source_root))
| select(.filename | startswith($source_root) or startswith($contract_root))
| select(.summary.lines.count > 0)
]
| length
Expand All @@ -27,9 +29,9 @@ if [[ "$covered_files" -eq 0 ]]; then
exit 1
fi

summary="$(jq -r --arg workspace_root "$workspace_root" --arg source_root "$source_root" '
summary="$(jq -r --arg workspace_root "$workspace_root" --arg source_root "$source_root" --arg contract_root "$contract_root" '
.data[].files[]
| select(.filename | startswith($source_root))
| select(.filename | startswith($source_root) or startswith($contract_root))
| select(.summary.lines.count > 0)
| [
(.filename | ltrimstr($workspace_root)),
Expand Down Expand Up @@ -58,10 +60,10 @@ fi

failures="$(jq -r \
--arg workspace_root "$workspace_root" \
--arg source_root "$source_root" \
--arg source_root "$source_root" --arg contract_root "$contract_root" \
--argjson minimum "$minimum" '
.data[].files[]
| select(.filename | startswith($source_root))
| select(.filename | startswith($source_root) or startswith($contract_root))
| select(.summary.lines.count > 0)
| select(.summary.lines.percent < $minimum)
| "\(.filename | ltrimstr($workspace_root)): \(.summary.lines.percent)%"
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ jobs:
run: cargo fmt --all -- --check

- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
run: cargo clippy --workspace --all-targets --all-features -- -D warnings

- name: Build
run: cargo build --all-targets --all-features
run: cargo build --workspace --all-targets --all-features

- name: Test
run: cargo test --all-features
run: cargo test --workspace --all-features

- name: Test default features
run: cargo test
run: cargo test --workspace

- name: Require 90% line coverage in every source file
run: .github/scripts/check-file-coverage.sh 90 coverage.json
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
- name: Build documentation
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --no-deps --all-features
run: cargo doc --workspace --no-deps --all-features

msrv:
name: Minimum supported Rust version
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
- uses: Swatinem/rust-cache@v2

- name: Build with the declared MSRV
run: cargo build --all-targets --all-features
run: cargo build --workspace --all-targets --all-features

supply-chain:
name: Supply chain
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ jobs:
run: cargo fmt --all -- --check

- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
run: cargo clippy --workspace --all-targets --all-features -- -D warnings

- name: Build
run: cargo build --all-targets --all-features
run: cargo build --workspace --all-targets --all-features

- name: Test
run: cargo test --all-features
run: cargo test --workspace --all-features

- name: Require 90% line coverage in every source file
run: .github/scripts/check-file-coverage.sh 90 target/coverage.json

- name: Build documentation
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --no-deps --all-features
run: cargo doc --workspace --no-deps --all-features

- name: Compute next version
id: version
Expand All @@ -70,8 +70,8 @@ jobs:
set -euo pipefail

metadata="$(cargo metadata --format-version 1 --no-deps)"
crate_name="$(jq -r '.packages[0].name' <<< "$metadata")"
current_version="$(jq -r '.packages[0].version' <<< "$metadata")"
crate_name="$(jq -r '.packages[] | select(.name == "tinyhosts") | .name' <<< "$metadata")"
current_version="$(jq -r '.packages[] | select(.name == "tinyhosts") | .version' <<< "$metadata")"
if [[ -z "$crate_name" || "$crate_name" == "null" ]]; then
echo "Could not resolve the crate name" >&2
exit 1
Expand Down Expand Up @@ -140,7 +140,8 @@ jobs:
NEXT_VERSION: ${{ steps.version.outputs.next_version }}
run: |
set -euo pipefail
perl -0pi -e 's/(\[package\][\s\S]*?\nversion = ")[^"]+(")/$1$ENV{NEXT_VERSION}$2/' Cargo.toml
perl -0pi -e 's/(\[package\][\s\S]*?\nversion = ")[^"]+(")/$1$ENV{NEXT_VERSION}$2/' Cargo.toml crates/tinyhosts-bus/Cargo.toml
Comment thread
senamakel marked this conversation as resolved.
perl -0pi -e 's/(tinyhosts-bus = \{[^\n]*version = ")[^"]+(")/$1$ENV{NEXT_VERSION}$2/' Cargo.toml
cargo update -p "$CRATE_NAME" --precise "$NEXT_VERSION"

- name: Commit version bump and tag
Expand All @@ -151,7 +152,7 @@ jobs:
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Cargo.toml Cargo.lock
git add Cargo.toml crates/tinyhosts-bus/Cargo.toml Cargo.lock
git commit -m "Release ${RELEASE_TAG}"
git tag -a "${RELEASE_TAG}" -m "Release ${RELEASE_TAG}"
git push origin "HEAD:${GITHUB_REF_NAME}"
Expand Down
18 changes: 11 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ library and a TinyBus module: the `cdylib` is the same code behind a JSON method
```text
src/
├── lib.rs # crate docs + the entire public re-export surface
├── error/mod.rs # crate-wide `Error` and `Result<T>`
├── error/mod.rs # compatibility exports of contract `Error` and `Result<T>`
├── credentials/ # the API key: redacted, deserialize-only
├── host/ # the `Host` trait (mod.rs) and the unified vocabulary
│ └── types.rs # every provider-independent type
Expand All @@ -24,6 +24,7 @@ src/
│ # http.rs (status mapping), wire.rs (Vercel's shapes)
├── rpc/ # one JSON request in, one JSON result out
└── tinybus_module/ # TinyBus interface, ABI exports, and integration tests
crates/tinyhosts-bus/ # pure vocabulary, JSON envelopes and declarations
tests/ # integration tests against the public API only
examples/ # runnable, compiled-in-CI usage examples
vendor/tinybus/ # pinned TinyBus host types and module SDK
Expand Down Expand Up @@ -69,8 +70,10 @@ missing module. Prefer many small modules that each do one thing well over few
broad ones.

Keep public exports centralized in `src/lib.rs` so downstream users have one
predictable surface. Put shared error variants in `src/error/mod.rs` and return
the crate-wide `Result<T>` from fallible public APIs.
predictable surface. Shared wire error variants live in
`crates/tinyhosts-bus/src/error/mod.rs`; the implementation's `src/error/mod.rs`
re-exports that vocabulary for compatibility. Return the crate-wide `Result<T>`
from fallible public APIs.

### Provider adapters

Expand All @@ -91,9 +94,9 @@ runs exactly them, so a green local run should mean a green CI run.

```sh
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo build --all-targets --all-features
cargo test --all-features
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo build --workspace --all-targets --all-features
cargo test --workspace --all-features
```

Supporting commands:
Expand Down Expand Up @@ -128,7 +131,8 @@ Use standard `rustfmt` output and Rust 2024 idioms. Do not hand-format around

### Errors

- One crate-wide `Error` enum in `src/error/mod.rs`, built with `thiserror`.
- One shared `Error` enum in the contract's `src/error/mod.rs`, built with
`thiserror` and re-exported by the implementation's error module.
- Fallible public functions return `Result<T>`, the crate alias.
- Add a specific variant instead of stuffing context into a string; error
messages are lowercase, without trailing punctuation.
Expand Down
119 changes: 119 additions & 0 deletions Cargo.lock

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

Loading
Loading