Skip to content

Udeps Report

Udeps Report #73

Workflow file for this run

name: Udeps Report
on:
schedule:
- cron: '0 13 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
env:
ISSUE_TITLE: "ci: cargo-udeps findings"
permissions:
contents: read
issues: write
jobs:
udeps-report:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- uses: ./.github/actions/setup
with:
free-disk: "true"
toolchain: nightly
native-deps: "true"
mold: "true"
foundry: "true"
tools: cargo-udeps
rust-cache-shared-key: "nightly-udeps-report"
rust-cache-save: "true"
- name: Build test contracts
run: just build::contracts
- name: Run cargo udeps
id: udeps
env:
UDEPS_JSON: ${{ runner.temp }}/udeps.json
UDEPS_STDERR: ${{ runner.temp }}/udeps.stderr
ISSUE_BODY: ${{ runner.temp }}/udeps-issue.md
run: |
set +e
BASE_SUCCINCT_ELF_STUB=1 cargo +nightly udeps --locked --workspace --all-features --all-targets --output json >"$UDEPS_JSON" 2>"$UDEPS_STDERR"
status=$?
set -e
python3 etc/scripts/ci/udeps-report.py render \
--json-path "$UDEPS_JSON" \
--stderr-path "$UDEPS_STDERR" \
--issue-body-path "$ISSUE_BODY" \
--github-output "$GITHUB_OUTPUT" \
--status "$status" \
--server-url "$GITHUB_SERVER_URL" \
--repository "$GITHUB_REPOSITORY" \
--run-id "$GITHUB_RUN_ID"
- name: Create or update issue
id: issue
if: steps.udeps.outputs.has_findings == 'true'
env:
GH_TOKEN: ${{ github.token }}
ISSUE_BODY: ${{ runner.temp }}/udeps-issue.md
run: |
issue_number="$(gh issue list \
--repo "$GITHUB_REPOSITORY" \
--state open \
--search "\"$ISSUE_TITLE\" in:title" \
--json number,title \
--limit 20 | python3 etc/scripts/ci/udeps-report.py find-open-issue --title "$ISSUE_TITLE")"
if [[ -n "$issue_number" ]]; then
gh issue edit "$issue_number" \
--repo "$GITHUB_REPOSITORY" \
--body-file "$ISSUE_BODY"
else
issue_url="$(gh issue create \
--repo "$GITHUB_REPOSITORY" \
--title "$ISSUE_TITLE" \
--body-file "$ISSUE_BODY")"
issue_number="${issue_url##*/}"
fi
issue_url="$(gh issue view "$issue_number" --repo "$GITHUB_REPOSITORY" --json url --jq '.url')"
echo "number=$issue_number" >> "$GITHUB_OUTPUT"
echo "url=$issue_url" >> "$GITHUB_OUTPUT"
- name: Summary
env:
FINDINGS: ${{ steps.udeps.outputs.has_findings }}
FINDING_COUNT: ${{ steps.udeps.outputs.finding_count }}
COMMAND_FAILED: ${{ steps.udeps.outputs.command_failed }}
COMMAND_STATUS: ${{ steps.udeps.outputs.command_status }}
ISSUE_NUMBER: ${{ steps.issue.outputs.number }}
ISSUE_URL: ${{ steps.issue.outputs.url }}
run: |
echo "## Udeps Report" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "- Findings detected: \`${FINDINGS}\`" >> "$GITHUB_STEP_SUMMARY"
echo "- cargo-udeps command failed: \`${COMMAND_FAILED}\`" >> "$GITHUB_STEP_SUMMARY"
if [[ -n "$COMMAND_STATUS" ]]; then
echo "- cargo-udeps exit status: \`${COMMAND_STATUS}\`" >> "$GITHUB_STEP_SUMMARY"
fi
if [[ -n "$FINDING_COUNT" ]]; then
echo "- Packages with findings: \`${FINDING_COUNT}\`" >> "$GITHUB_STEP_SUMMARY"
fi
if [[ -n "$ISSUE_NUMBER" ]]; then
echo "- Open issue: #${ISSUE_NUMBER}" >> "$GITHUB_STEP_SUMMARY"
fi
if [[ -n "$ISSUE_URL" ]]; then
echo "- Issue URL: $ISSUE_URL" >> "$GITHUB_STEP_SUMMARY"
fi
- name: Fail on cargo udeps command error
if: steps.udeps.outputs.command_failed == 'true'
run: |
echo "cargo udeps exited with status ${{ steps.udeps.outputs.command_status }}" >&2
exit 1