Skip to content

Commit dd2010e

Browse files
committed
ci: Move lints into xtask
Honestly just to reduce the code statistics; be nice to have zero shell script in the repo 😃 Signed-off-by: Colin Walters <[email protected]>
1 parent 7676574 commit dd2010e

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ jobs:
2121
container: quay.io/coreos-assembler/fcos-buildroot:testing-devel
2222
steps:
2323
- uses: actions/checkout@v3
24-
- name: Code lints
25-
run: ./ci/lints.sh
2624
- name: Install deps
2725
run: ./ci/installdeps.sh
2826
# xref containers/containers-image-proxy-rs
@@ -34,6 +32,8 @@ jobs:
3432
run: cargo test --no-run
3533
- name: Individual checks
3634
run: (cd cli && cargo check) && (cd lib && cargo check)
35+
- name: Lints
36+
run: cargo xtask custom-lints
3737
- name: Run tests
3838
run: cargo test -- --nocapture --quiet
3939
- name: Manpage generation

ci/lints.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

xtask/src/xtask.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::fs::File;
2-
use std::io::{BufRead, BufReader, BufWriter, Write};
2+
use std::io::{BufRead, BufReader, BufWriter, Cursor, Write};
33
use std::process::{Command, Stdio};
44

55
use anyhow::{Context, Result};
@@ -12,23 +12,25 @@ const VENDORPATH: &str = "target/vendor.tar.zstd";
1212

1313
fn main() {
1414
if let Err(e) = try_main() {
15-
eprintln!("{e:?}");
15+
eprintln!("error: {e:?}");
1616
std::process::exit(1);
1717
}
1818
}
1919

20-
const TASKS: &[(&'static str, fn(&Shell) -> Result<()>)] = &[
20+
#[allow(clippy::type_complexity)]
21+
const TASKS: &[(&str, fn(&Shell) -> Result<()>)] = &[
2122
("vendor", vendor),
2223
("package", package),
2324
("package-srpm", package_srpm),
25+
("custom-lints", custom_lints),
2426
];
2527

2628
fn try_main() -> Result<()> {
2729
let task = std::env::args().nth(1);
2830
let sh = xshell::Shell::new()?;
2931
if let Some(cmd) = task.as_deref() {
3032
let f = TASKS
31-
.into_iter()
33+
.iter()
3234
.find_map(|(k, f)| (*k == cmd).then_some(*f))
3335
.unwrap_or(print_help);
3436
f(&sh)?;
@@ -170,6 +172,18 @@ fn package_srpm(sh: &Shell) -> Result<()> {
170172
Ok(())
171173
}
172174

175+
fn custom_lints(sh: &Shell) -> Result<()> {
176+
// Verify there are no invocations of the dbg macro.
177+
let o = cmd!(sh, "git grep dbg\x21 *.rs").ignore_status().read()?;
178+
if !o.is_empty() {
179+
let mut stderr = std::io::stderr().lock();
180+
std::io::copy(&mut Cursor::new(o.as_bytes()), &mut stderr)?;
181+
eprintln!();
182+
anyhow::bail!("Found dbg\x21 macro");
183+
}
184+
Ok(())
185+
}
186+
173187
fn print_help(_sh: &Shell) -> Result<()> {
174188
println!("Tasks:");
175189
for (name, _) in TASKS {

0 commit comments

Comments
 (0)