Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit d935279

Browse files
authored
fix: allow reusable workflow calls to be unpinned (#30)
1 parent 40b4fa2 commit d935279

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/common.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,10 @@ where
358358
let uses = step_uses(de)?;
359359

360360
match uses {
361-
Uses::Local(local) if local.git_ref.is_none() => Err(de::Error::custom(
362-
"local action must have `@<ref>` in reusable workflow",
363-
)),
364361
Uses::Repository(repo) if repo.git_ref.is_none() => Err(de::Error::custom(
365362
"repo action must have `@<ref> in reusable workflow",
366363
)),
364+
// NOTE: local reusable workflows do not have to be pinned.
367365
Uses::Local(_) => Ok(uses),
368366
Uses::Repository(_) => Ok(uses),
369367
// `docker://` is never valid in reusable workflow uses.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# see https://github.com/woodruffw/zizmor/issues/431
2+
3+
name: "reusable-workflow-unpinned"
4+
5+
on:
6+
push:
7+
8+
jobs:
9+
testcase:
10+
name: "testcase"
11+
uses: ./.github/workflows/reusable.yml

tests/test_workflow.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ fn load_workflow(name: &str) -> Workflow {
2424
fn test_load_all() {
2525
let sample_workflows = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/sample-workflows");
2626

27-
for sample_action in std::fs::read_dir(sample_workflows).unwrap() {
28-
let sample_workflow = sample_action.unwrap().path();
29-
let workflow_contents = std::fs::read_to_string(sample_workflow).unwrap();
30-
serde_yaml::from_str::<Workflow>(&workflow_contents).unwrap();
27+
for sample_workflow in std::fs::read_dir(sample_workflows).unwrap() {
28+
let sample_workflow = sample_workflow.unwrap().path();
29+
let workflow_contents = std::fs::read_to_string(&sample_workflow).unwrap();
30+
31+
let wf = serde_yaml::from_str::<Workflow>(&workflow_contents);
32+
assert!(wf.is_ok(), "failed to parse {sample_workflow:?}");
3133
}
3234
}
3335

0 commit comments

Comments
 (0)