ci: add job stale-label

This commit is contained in:
Weihang Lo 2023-04-27 18:15:33 +01:00
parent 981282891f
commit 36653ab85a
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7
2 changed files with 15 additions and 6 deletions

View File

@ -36,6 +36,13 @@ jobs:
# TODO: check every members
- run: cargo clippy -p cargo --lib --no-deps -- -D warnings
stale-label:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update stable && rustup default stable
- run: cargo stale-label
# Ensure Cargo.lock is up-to-date
lockfile:
runs-on: ubuntu-latest

View File

@ -3,7 +3,7 @@
//! stale-label
//!
//! SYNOPSIS
//! stale-label [<FILE>]
//! stale-label
//!
//! DESCRIPTION
//! Detect stale paths in autolabel definitions in triagebot.toml.
@ -11,7 +11,6 @@
//! ```
use std::fmt::Write as _;
use std::path::Path;
use std::path::PathBuf;
use std::process;
use toml_edit::Document;
@ -19,9 +18,10 @@ use toml_edit::Document;
fn main() {
let pkg_root = std::env!("CARGO_MANIFEST_DIR");
let ws_root = PathBuf::from(format!("{pkg_root}/../.."));
let triagebot_toml = format!("{pkg_root}/../../triagebot.toml");
let path = std::env::args_os().nth(1).unwrap_or(triagebot_toml.into());
let path = Path::new(&path).canonicalize().unwrap_or(path.into());
let path = {
let path = ws_root.join("triagebot.toml");
path.canonicalize().unwrap_or(path)
};
eprintln!("Checking file {path:?}\n");
@ -85,5 +85,7 @@ fn main() {
let result = if failed == 0 { "ok" } else { "FAILED" };
eprintln!("test result: {result}. {passed} passed; {failed} failed;");
process::exit(failed as i32);
if failed > 0 {
process::exit(1);
}
}