Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions tools/ci/commands/lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ edition.workspace = true
anyhow.workspace = true
clap.workspace = true
duct.workspace = true
regex.workspace = true
serde_json.workspace = true
ci-common = { path = "../../common" }
13 changes: 13 additions & 0 deletions tools/ci/commands/lint/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ use anyhow::{bail, Context, Result};
use ci_common::{ensure_repo_root, pnpm};
use clap::Parser;
use duct::cmd;
use regex::Regex;
use serde_json::Value;
use std::collections::BTreeSet;
use std::ffi::OsString;
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use std::sync::LazyLock;

/// Lints the codebase
///
Expand Down Expand Up @@ -104,6 +106,11 @@ fn npmrc_minimum_release_age(path: &Path, expected_minimum_release_age: u64) ->
})
}

fn workflow_installs_pnpm_with_npm(contents: &str) -> bool {
static NPM_INSTALL_PNPM: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"npm install.*pnpm").unwrap());
NPM_INSTALL_PNPM.is_match(contents)
}

fn check_pnpm_release_age_policy() -> Result<()> {
ensure_repo_root()?;

Expand Down Expand Up @@ -211,6 +218,12 @@ fn check_pnpm_release_age_policy() -> Result<()> {
workflow_path.display()
);
}
if workflow_installs_pnpm_with_npm(&contents) {
bail!(
"{} must use ./.github/actions/setup-pnpm instead of installing pnpm with npm",
workflow_path.display()
);
}
}

Ok(())
Expand Down
Loading