Skip to content

Commit

Permalink
feat: improve parse error slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
woodruffw committed Jan 22, 2025
1 parent 01f76fc commit 138507d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ impl InputRegistry {
Err(we) => match Action::from_file(path, prefix) {
Ok(action) => self.register_input(action.into()),
Err(ae) => Err(anyhow!("failed to register input as workflow or action"))
.with_context(|| we)
.with_context(|| ae),
.with_context(|| format!("{ae:?}"))
.with_context(|| format!("{we:?}")),
},
}
}
Expand Down
11 changes: 11 additions & 0 deletions tests/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ fn test_conflicting_online_options() -> Result<()> {
Ok(())
}

#[test]
fn test_invalid_inputs() -> Result<()> {
insta::assert_snapshot!(zizmor()
.output(OutputMode::Stderr)
.offline(true)
.workflow(workflow_under_test("invalid/invalid-workflow.yml"))
.run()?);

Ok(())
}

#[test]
fn artipacked() -> Result<()> {
insta::assert_snapshot!(zizmor()
Expand Down
17 changes: 17 additions & 0 deletions tests/snapshots/snapshot__invalid_inputs.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
source: tests/snapshot.rs
expression: "zizmor().output(OutputMode::Stderr).offline(true).workflow(workflow_under_test(\"invalid/invalid-workflow.yml\")).run()?"
snapshot_kind: text
---
failed to register input: @@INPUT@@

Caused by:
0: invalid GitHub Actions workflow: file://@@INPUT@@

Caused by:
jobs: data did not match any variant of untagged enum Job at line 10 column 3
1: invalid GitHub Actions definition: file://@@INPUT@@

Caused by:
missing field `runs`
2: failed to register input as workflow or action
14 changes: 14 additions & 0 deletions tests/test-data/invalid/invalid-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "invalid-workflow"

on:
repository_dispatch:

permissions:
contents: read

jobs:
invalid:
name: "invalid"

steps:
- run: echo hello

0 comments on commit 138507d

Please sign in to comment.