Skip to content

Commit

Permalink
Fix unused dependencies, add periodic workflow to monitor (#2433)
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave authored Jan 3, 2024
1 parent b9fc6a0 commit 95378c7
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 89 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/unused-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: unused-dependencies

on:
schedule:
- cron: "21 4 * * mon"
workflow_dispatch:

jobs:
cargo-udeps:
runs-on: ubuntu-latest
permissions:
contents: "read"
issues: "write"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-udeps
uses: taiki-e/install-action@cargo-udeps
- name: Run cargo-udeps, all features
run: cargo +nightly udeps --all-features | tee log_all_features.txt
- name: Run cargo-udeps, default features
if: success() || failure()
run: cargo +nightly udeps | tee log_default_features.txt
- name: Create issue
if: failure()
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const tryReadFile = (file) => {
try {
return fs.readFileSync(file, 'utf8').toString();
} catch (err) {
console.log(`${file}: ${err}`);
}
return '';
};
const logAllFeatures = tryReadFile('log_all_features.txt');
const logDefaultFeatures = tryReadFile('log_default_features.txt');
let output;
if (logAllFeatures.length == 0 && logDefaultFeatures == 0) {
output = `### Unused dependencies
An error was encountered when checking for unused dependencies.
`;
} else {
output = `### Unused dependencies
Unused dependencies were detected in the Cargo workspace.
`;
}
output += `#### Details
- Run URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- Git SHA: ${{ github.sha }}
`;
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Unused dependencies',
body: output,
});
110 changes: 37 additions & 73 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 95378c7

Please sign in to comment.