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
55 changes: 26 additions & 29 deletions .github/scripts/check-file-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,48 @@ workspace_root="$(pwd -P)/"
# whole workspace. Vendored submodules and `worktrees/` sit outside it and are
# excluded by the same test.
source_root="${workspace_root}crates/"
# macOS deliberately does not exercise `clipboard-clear`: doing so would erase
# the developer's real pasteboard. Linux CI has no pasteboard and covers that
# branch, so omit only that file from a local Darwin report.
coverage_exclude=""
if [[ "$(uname -s)" == "Darwin" ]]; then
coverage_exclude="${source_root}tinydesktop/src/desktop/clipboard.rs"
fi

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

covered_files="$(jq --arg source_root "$source_root" '
[
.data[].files[]
| select(.filename | startswith($source_root))
| select(.summary.lines.count > 0)
]
| length
' "$report")"

if [[ "$covered_files" -eq 0 ]]; then
echo "coverage report contains no files with executable lines under crates/" >&2
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 coverage_exclude "$coverage_exclude" '
.data[].files[]
| select(.filename | startswith($source_root))
| select(.summary.lines.count > 0)
| select(.filename != $coverage_exclude)
# LLVM may emit the same source line from more than one monomorphization.
# Normalize its duplicated line denominator to unique source locations while
# retaining the LLVM covered-line count, capped at that normalized total.
| ([.segments[] | select(.[3] == true) | .[0]] | unique | length) as $count
| select($count > 0)
| ([.summary.lines.covered, $count] | min) as $covered
| [
(.filename | ltrimstr($workspace_root)),
(.summary.lines.percent | tostring),
(.summary.lines.covered | tostring),
(.summary.lines.count | tostring)
(($covered * 100 / $count) | tostring),
($covered | tostring),
($count | tostring)
]
| @tsv
' "$report")"

covered_files="$(printf '%s\n' "$summary" | awk 'NF { count += 1 } END { print count + 0 }')"
if [[ "$covered_files" -eq 0 ]]; then
echo "coverage report contains no files with executable lines under crates/" >&2
exit 1
fi

printf 'File\tLine coverage\tCovered lines\tCoverable lines\n'
while IFS=$'\t' read -r file percent covered count; do
printf '%s\t%.2f%%\t%s\t%s\n' "$file" "$percent" "$covered" "$count"
Expand All @@ -60,16 +66,7 @@ if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
} >> "$GITHUB_STEP_SUMMARY"
fi

failures="$(jq -r \
--arg workspace_root "$workspace_root" \
--arg source_root "$source_root" \
--argjson minimum "$minimum" '
.data[].files[]
| select(.filename | startswith($source_root))
| select(.summary.lines.count > 0)
| select(.summary.lines.percent < $minimum)
| "\(.filename | ltrimstr($workspace_root)): \(.summary.lines.percent)%"
' "$report")"
failures="$(awk -F $'\t' -v minimum="$minimum" '$2 + 0 < minimum { printf "%s: %s%%\n", $1, $2 }' <<< "$summary")"

if [[ -n "$failures" ]]; then
printf '\nFiles below %s%% line coverage:\n%s\n' "$minimum" "$failures" >&2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ jobs:
run: cargo test

# `cargo build --all-targets` only *compiles* an example. `AGENTS.md`
# promises `cargo run -p tinydesktop --example basic` works, and a compiled
# promises `cargo run -p tinydesktop-examples --bin basic` works, and a compiled
# example can still fail on its first line.
- name: Run the bundled example
run: cargo run -p tinydesktop --example basic
run: cargo run -p tinydesktop-examples --bin basic

# `crates/tinydesktop-bus` exists so a host can name the payload types
# without compiling the module. That promise is invisible in a diff,
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ jobs:
macOS) module="target/release/lib${library_name}.dylib" ;;
*) echo "unsupported Unix runner: ${RUNNER_OS}" >&2; exit 1 ;;
esac
cargo run --locked --package tinydesktop --example verify_module -- "$module"
cargo run --locked --package tinydesktop-examples --bin verify_module -- "$module"

- name: Verify Windows module through TinyBus loader
if: ${{ runner.os == 'Windows' }}
Expand Down Expand Up @@ -300,7 +300,7 @@ jobs:

$verifiedModule = Join-Path $verifyRoot "$libraryName.dll"
Copy-Item -LiteralPath $module -Destination $verifiedModule
cargo run --locked --package tinydesktop --example verify_module -- $verifiedModule
cargo run --locked --package tinydesktop-examples --bin verify_module -- $verifiedModule

- name: Assemble Unix module package
if: ${{ runner.os != 'Windows' }}
Expand Down Expand Up @@ -463,7 +463,7 @@ jobs:
verify_root="/opt/${CRATE_NAME}-module-verify"
install -d -m 700 "$verify_root"
install -m 755 "target/release/lib${library_name}.so" "$verify_root/"
cargo run --locked --package tinydesktop --example verify_module -- \
cargo run --locked --package tinydesktop-examples --bin verify_module -- \
"$verify_root/lib${library_name}.so"

- name: Assemble distribution module package
Expand Down Expand Up @@ -587,5 +587,5 @@ jobs:
cargo run --manifest-path vendor/tinybus/Cargo.toml --locked \
--package tinybus --all-features --example github_module_host -- \
"$release_url" "$archive" "$sha256"
cargo run --locked --package tinydesktop --example verify_github_release -- \
cargo run --locked --package tinydesktop-examples --bin verify_github_release -- \
"$release_url" "$archive" "$sha256"
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
[submodule "vendor/agent-desktop"]
path = vendor/agent-desktop
url = https://github.com/lahfir/agent-desktop
[submodule "vendor/tinyjevclient"]
Comment thread
senamakel marked this conversation as resolved.
Resolved
path = vendor/tinyjevclient
url = https://github.com/tinyhumansai/tinyjevclient
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ docs/
└── adr/ # immutable architecture decision records
```

### The two-crate split
### The crate split

`crates/tinydesktop-bus` holds every type that crosses the bus and the names of
the members that carry them. It has no transport, no runtime, no engine, and no
Expand Down Expand Up @@ -143,8 +143,8 @@ Supporting commands:
- `cargo fmt --all` — format before committing.
- `cargo test <filter>` — run a focused subset while iterating.
- `cargo test -p tinydesktop-bus` — run one crate's suite.
- `cargo run -p tinydesktop --example basic` — run the bundled example.
- `cargo run -p tinydesktop --example verify_module -- <path>` — load a built
- `cargo run -p tinydesktop-examples --bin basic` — run the bundled example.
- `cargo run -p tinydesktop-examples --bin verify_module -- <path>` — load a built
`cdylib` through the real TinyBus dynamic loader.
- `cargo doc --no-deps --all-features` — build the rustdoc CI also builds with
`RUSTDOCFLAGS="-D warnings"`.
Expand Down
Loading
Loading