Skip to content

Commit 82bafb1

Browse files
committed
Use cargo publish instead cargo tree to check breaking deps
1 parent 1c7a149 commit 82bafb1

1 file changed

Lines changed: 63 additions & 14 deletions

File tree

.github/workflows/release-proposal-dispatch.yml

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -493,41 +493,78 @@ jobs:
493493
branch_name: ${{ steps.proposal-branch.outputs.branch_name }}
494494
ephemeral_branch: ${{ steps.ephemeral-branch.outputs.ephemeral_branch }}
495495

496-
check-breaking-deps:
496+
publish-dry-run-check:
497497
needs: cargo-release
498498
runs-on: ubuntu-latest
499499
steps:
500500
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
501501
with:
502502
ref: ${{ needs.cargo-release.outputs.branch_name }}
503503

504+
- uses: dtolnay/rust-toolchain@stable
505+
with:
506+
toolchain: 1.92.0
507+
504508
- name: Download release data
505509
uses: actions/download-artifact@v4
506510
with:
507511
name: release-dispatch-data
508512
path: /tmp
509513

510-
- name: Check breaking deps
514+
- name: Cargo publish dry-run (crates.io resolution)
515+
id: publish-dry-run
511516
run: |
512-
echo "Checking breaking deps..."
513-
HAS_DUPLICATED_DEPS=false
517+
set -euo pipefail
518+
HAS_ISSUES=false
519+
: > /tmp/publish-dry-run-issues-body.md
514520
515-
# check if the crates in /tmp/api-changes.json have duplicated and conflicting dependencies
521+
# Simulates publishing each release crate; resolves deps from the registry like crates.io, not path deps.
516522
while read -r crate; do
517523
NAME=$(echo "$crate" | jq -r '.name')
518-
DEP_TREE=$(cargo tree -d -p "$NAME" -e no-dev --prefix none | grep "libdd-" | grep -vF '(*)' | sort -u | cut -d' ' -f1 | sort | uniq -d)
519-
if [ -n "$DEP_TREE" ]; then
520-
echo "Crate $NAME has duplicated and conflicting dependencies: $DEP_TREE"
521-
HAS_DUPLICATED_DEPS=true
524+
LOG=$(mktemp)
525+
echo "Running: cargo publish -p $NAME --dry-run --all-features --locked"
526+
if ! cargo publish -p "$NAME" --dry-run --all-features --locked --color never 2>&1 | tee "$LOG"; then
527+
HAS_ISSUES=true
528+
{
529+
echo "### \`$NAME\`"
530+
echo ""
531+
echo '```text'
532+
tail -n 120 "$LOG"
533+
echo '```'
534+
echo ""
535+
} >> /tmp/publish-dry-run-issues-body.md
536+
echo "FAILED: $NAME (see summary artifact for PR)"
537+
else
538+
echo "OK: $NAME"
522539
fi
540+
rm -f "$LOG"
523541
done < <(jq -c '.[]' /tmp/api-changes.json)
524542
525-
if [ "$HAS_DUPLICATED_DEPS" = "false" ]; then
526-
echo "No duplicated dependencies found in release crates."
543+
if [ "$HAS_ISSUES" = "true" ]; then
544+
{
545+
echo "## Cargo publish dry-run failures"
546+
echo ""
547+
echo "These crates did not pass \`cargo publish --dry-run --all-features --locked\` (dependencies are resolved **as on crates.io**, not via workspace path dependencies)."
548+
echo ""
549+
cat /tmp/publish-dry-run-issues-body.md
550+
} > /tmp/publish-dry-run-summary.md
551+
echo "has_issues=true" >> "$GITHUB_OUTPUT"
552+
echo "Publish dry-run found issues; PR will include a summary section."
553+
else
554+
echo "has_issues=false" >> "$GITHUB_OUTPUT"
555+
echo "All publish dry-runs succeeded."
527556
fi
557+
558+
- name: Upload publish dry-run summary for PR body
559+
if: steps.publish-dry-run.outputs.has_issues == 'true'
560+
uses: actions/upload-artifact@v4
561+
with:
562+
name: publish-dry-run-summary
563+
path: /tmp/publish-dry-run-summary.md
564+
retention-days: 1
528565

529566
create-pr:
530-
needs: cargo-release
567+
needs: [cargo-release, publish-dry-run-check]
531568
runs-on: ubuntu-latest
532569
permissions:
533570
id-token: write # Enable OIDC
@@ -544,6 +581,12 @@ jobs:
544581
name: release-dispatch-data
545582
path: /tmp
546583

584+
- name: Download publish dry-run summary (if any failures)
585+
continue-on-error: true
586+
uses: actions/download-artifact@v4
587+
with:
588+
name: publish-dry-run-summary
589+
path: /tmp
547590

548591
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
549592
id: octo-sts
@@ -585,14 +628,20 @@ jobs:
585628
This PR contains version bumps based on public API changes and commits since last release.
586629
587630
${PR_BODY}"
631+
632+
PUBLISH_SUMMARY_FILE="/tmp/publish-dry-run-summary.md"
633+
if [ -f "$PUBLISH_SUMMARY_FILE" ]; then
634+
PR_BODY="${PR_BODY}"$'\n\n'"$(cat "$PUBLISH_SUMMARY_FILE")"
635+
fi
588636
589-
echo "PR_BODY: $PR_BODY"
637+
echo "$PR_BODY" > /tmp/pr-body.md
638+
echo "PR body written to /tmp/pr-body.md (length: $(wc -c < /tmp/pr-body.md) bytes)"
590639
591640
# NOTE: the PR title is used to filter gitlab CI jobs. If you change it, you need to update the gitlab CI job filter.
592641
gh pr create \
593642
--head "$BRANCH_NAME" \
594643
--title "chore(release): proposal for ${{ inputs.crate }}" \
595-
--body "$PR_BODY" \
644+
--body-file /tmp/pr-body.md \
596645
--label "release-proposal" \
597646
--label "skip-metadata-check" \
598647
--label "skip-changelog-check" \

0 commit comments

Comments
 (0)