Skip to content
Open
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
7 changes: 6 additions & 1 deletion crates/zizmor/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ impl Config {
return Ok(Self::default());
}

let config = match &app.config {
let app_config = app
.config
.as_ref()
.filter(|config| !config.as_str().is_empty());

let config = match app_config {
Some(path) => serde_yaml::from_str(&fs::read_to_string(path)?)?,
None => {
// If the user didn't pass a config path explicitly with
Expand Down
6 changes: 5 additions & 1 deletion crates/zizmor/tests/integration/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ impl Zizmor {
self
}

pub fn has_config_set_from_env(&self) -> bool {
self.cmd.get_envs().any(|(key, _)| key == "ZIZMOR_CONFIG")
}

pub fn run(mut self) -> Result<String> {
if self.offline {
self.cmd.arg("--offline");
Expand All @@ -115,7 +119,7 @@ impl Zizmor {

if let Some(config) = self.config {
self.cmd.arg("--config").arg(config);
} else {
} else if !self.has_config_set_from_env() {
self.cmd.arg("--no-config");
}

Expand Down
20 changes: 20 additions & 0 deletions crates/zizmor/tests/integration/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,26 @@ fn invalid_config_file() -> Result<()> {
Ok(())
}

#[test]
fn empty_config_env_var() -> Result<()> {
zizmor()
.setenv("ZIZMOR_CONFIG", "")
.input(input_under_test("e2e-menagerie"))
.run()?;

Ok(())
}

#[test]
fn empty_config_arg() -> Result<()> {
zizmor()
.config("")
.input(input_under_test("e2e-menagerie"))
.run()?;

Ok(())
}

#[test]
fn invalid_inputs() -> Result<()> {
for workflow_tc in [
Expand Down