-
Notifications
You must be signed in to change notification settings - Fork 0
fix(workflows): address CodeRabbit suggestions deferred from #87 #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -163,16 +163,57 @@ jobs: | |||||
|
|
||||||
| - name: Audit Cargo dependencies | ||||||
| run: | | ||||||
| # cargo audit operates on Cargo.lock at workspace root | ||||||
| # For workspaces, a single audit at root covers all crates | ||||||
| # cargo audit operates on Cargo.lock at workspace root, so for a | ||||||
| # workspace a single audit at the root covers every member crate. | ||||||
| # Iterating every Cargo.toml would re-audit the same lockfile N | ||||||
| # times in workspaces. | ||||||
| # | ||||||
| # Strategy: | ||||||
| # 1. Find every Cargo.toml that declares [workspace] — those | ||||||
| # are workspace roots; emit them. | ||||||
| # 2. Find every Cargo.toml that does NOT declare [workspace]; | ||||||
| # those are either standalone crates or workspace members. | ||||||
| # Emit them only if no parent dir is already a workspace | ||||||
| # root we found in step 1. | ||||||
| status=0 | ||||||
| while IFS= read -r dir; do | ||||||
|
|
||||||
| mapfile -t WORKSPACES < <( | ||||||
| find . -name Cargo.toml -not -path '*/target/*' -print0 \ | ||||||
| | xargs -0 grep -l '^\[workspace\]' 2>/dev/null \ | ||||||
| | xargs -n1 dirname 2>/dev/null \ | ||||||
| | sort -u | ||||||
| ) | ||||||
|
|
||||||
| mapfile -t NON_WORKSPACES < <( | ||||||
| find . -name Cargo.toml -not -path '*/target/*' -print0 \ | ||||||
| | xargs -0 grep -L '^\[workspace\]' 2>/dev/null \ | ||||||
| | xargs -n1 dirname 2>/dev/null \ | ||||||
| | sort -u | ||||||
| ) | ||||||
|
|
||||||
| # Standalone crates: those whose dir is not under any workspace root | ||||||
| STANDALONE=() | ||||||
| for dir in "${NON_WORKSPACES[@]}"; do | ||||||
| covered=0 | ||||||
| for ws in "${WORKSPACES[@]}"; do | ||||||
| # Trim trailing slash from $ws for accurate prefix match | ||||||
| ws_trim="${ws%/}" | ||||||
| case "$dir/" in | ||||||
| "$ws_trim/"*) covered=1; break ;; | ||||||
| esac | ||||||
| done | ||||||
| if [ "$covered" -eq 0 ]; then | ||||||
| STANDALONE+=("$dir") | ||||||
| fi | ||||||
| done | ||||||
|
|
||||||
| for dir in "${WORKSPACES[@]}" "${STANDALONE[@]}"; do | ||||||
| echo "::group::cargo audit $dir" | ||||||
| if ! (cd "$dir" && cargo generate-lockfile 2>/dev/null; cargo audit); then | ||||||
|
||||||
| if ! (cd "$dir" && cargo generate-lockfile 2>/dev/null; cargo audit); then | |
| if ! (cd "$dir" && { cargo generate-lockfile 2>/dev/null || true; } && cargo audit); then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workspace discovery pipelines convert NUL-delimited
find -print0output into newline/whitespace-delimited paths beforedirname(viagrepthenxargs -n1 dirname). That will mis-handle Cargo.toml paths containing spaces/tabs/newlines. Consider keeping NUL delimiters end-to-end (e.g.,grep -Z+xargs -0) or usingfind ... -exec sh -c ...to emit workspace/dir names without whitespace splitting.