Skip to content

Dependencies

Dependencies #199

Workflow file for this run

name: Dependencies
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
# Check for outdated dependencies weekly on Mondays at 8 AM UTC
- cron: '0 8 * * 1'
workflow_dispatch: # Allow manual trigger
jobs:
check-outdated:
name: Check Outdated Dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Check for outdated dependencies
id: outdated
run: |
echo "## 📦 Dependency Status Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Run cargo outdated and capture output
if nix shell nixpkgs#cargo-outdated -c cargo outdated --exit-code 1 --root-deps-only 2>/dev/null; then
echo "✅ All dependencies are up to date!" >> $GITHUB_STEP_SUMMARY
echo "status=current" >> $GITHUB_OUTPUT
else
echo "⚠️ **Outdated dependencies detected:**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
nix shell nixpkgs#cargo-outdated -c cargo outdated --root-deps-only 2>/dev/null >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Update Instructions" >> $GITHUB_STEP_SUMMARY
echo "- For compatible updates: \`nix develop -c cargo upgrade\`" >> $GITHUB_STEP_SUMMARY
echo "- For major version updates: Review changelogs and update manually" >> $GITHUB_STEP_SUMMARY
echo "status=outdated" >> $GITHUB_OUTPUT
fi
continue-on-error: true # Don't fail the workflow
- name: Generate detailed report
run: |
# Generate JSON report for further processing
nix shell nixpkgs#cargo-outdated -c cargo outdated --format json > outdated-report.json || true
# Generate full text report
echo "Full Dependency Report" > outdated-full-report.txt
echo "=====================" >> outdated-full-report.txt
echo "" >> outdated-full-report.txt
nix shell nixpkgs#cargo-outdated -c cargo outdated 2>/dev/null >> outdated-full-report.txt || true
continue-on-error: true
- name: Upload dependency reports
if: always()
uses: actions/upload-artifact@v7
with:
name: dependency-reports
path: |
outdated-report.json
outdated-full-report.txt
retention-days: 30
- name: Comment on PR (if outdated)
if: github.event_name == 'pull_request' && steps.outdated.outputs.status == 'outdated'
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const summary = fs.readFileSync(process.env.GITHUB_STEP_SUMMARY, 'utf8');
// Find or create comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' && comment.body.includes('📦 Dependency Status Report')
);
const body = `${summary}\n\n---\n*This is an informational check and does not block merging.*`;
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}
continue-on-error: true # Don't fail if commenting fails
check-compatible-updates:
name: Check Compatible Updates
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Check for compatible updates
run: |
echo "## 🔄 Compatible Updates Check" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Check what cargo upgrade would do
OUTPUT=$(nix shell nixpkgs#cargo-edit -c cargo upgrade --dry-run 2>&1 | grep -E "^[a-zA-Z0-9_-]+ +[0-9]" || true)
if [ -z "$OUTPUT" ]; then
echo "✅ No compatible updates available" >> $GITHUB_STEP_SUMMARY
else
echo "📌 **Compatible updates available:**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
nix shell nixpkgs#cargo-edit -c cargo upgrade --dry-run 2>&1 | grep -E "^(name|====|[a-zA-Z0-9_-]+ +[0-9])" | head -20 >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Run \`nix develop -c cargo upgrade\` to update these dependencies." >> $GITHUB_STEP_SUMMARY
fi
continue-on-error: true # Don't fail the workflow