Skip to content

Commit

Permalink
ci: add job stale-label
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Apr 28, 2023
1 parent 9812828 commit 36653ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions crates/xtask-stale-label/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
//! stale-label
//!
//! SYNOPSIS
//! stale-label [<FILE>]
//! stale-label
//!
//! DESCRIPTION
//! Detect stale paths in autolabel definitions in triagebot.toml.
//! Probably autofix them in the future.
//! ```

use std::fmt::Write as _;
use std::path::Path;
use std::path::PathBuf;
use std::process;
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");

Expand Down Expand Up @@ -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);
}
}

0 comments on commit 36653ab

Please sign in to comment.