-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unused dependencies, add periodic workflow to monitor (#2433)
- Loading branch information
1 parent
b9fc6a0
commit 95378c7
Showing
8 changed files
with
127 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.