paths wildcard validation seems off
bplessis-swi opened this issue · comments
Hi,
Sorry if i missed something but when following the "filter pattern cheat cheet" of github action, the validator fail the file with the following message:
Glob "**.md" in on.push.paths is invalid: Pattern syntax error near position 2: recursive wildcards must form a single path component
Documentation source
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#patterns-to-match-file-paths
Sample use
on:
push:
branches:
- main
paths:
- '**.md'
Version
action-validator 0.3.0
Thanks for this solid report. I'd say this comes down to a difference of opinion between the globbing library that action-validator uses, and what GitHub specifies. Might not be trivial to solve, but I'll get it figured out one way or another.
Yeah the rust glob() function seem more "limited" in it's patterns, the equivalent of '**.md' seem to be '**/*.md' (that apparently github also understand apparently, given the 'docs/**/*.md' sample a few lines down in the same documentation.
FWIW: The tool will also error on exclusion patterns.
Example:
on:
push:
branches:
- main
paths:
- '!generated/**'
Adding the extra /*
(that is '!generated/**/*'
) does not work around this.
I like the idea though :-)
I encountered this behaviour as well: https://github.com/DawnbrandBots/yaml-yugi/actions/runs/5626963939/job/15248759792
Claims the directory/**
pattern is invalid, but these workflows trigger and run just fine:
Hey guys,
Experiencing a similar issue with somedir/**
path.
Error example:
errors: [
NoFilesMatchingGlob {
code: "glob_not_matched",
detail: Some(
"Glob \"terraform/dev/**\" in /on/pull_request/paths does not match any files",
),
path: "/on/pull_request/paths",
title: "Glob does not match any files",
},
],
Any workaround for that?
Thanks.
action-validator version 0.5.4
installed using asdf-vm/actions/install@v3
No workaround available, action-validator
needs to be modified to use a different glob expansion mechanism in order to support these patterns. I don't have the available time to fix it myself, so as the tag says, "PR welcome"!
Experiencing a similar issue for below ci.yml
name: CI Workflow
on:
push:
paths-ignore:
- '.gitattributes'
- '**.MD'
- '.devcontainer/**'
Treating ci.yml as a Workflow definition
Fatal error validating .github/workflows/ci.yml
Validation failed: ValidationState {
action_type: Some(
Workflow,
),
file_path: Some(
".github/workflows/ci.yml",
),
errors: [
InvalidGlob {
code: "invalid_glob",
detail: Some(
"Glob \"**.MD\" in /on/push/paths-ignore is invalid: Pattern syntax error near position 2: recursive wildcards must form a single path component",
),
path: "/on/push/paths-ignore",
title: "Glob does not match any files",
},
NoFilesMatchingGlob {
code: "glob_not_matched",
detail: Some(
"Glob \".devcontainer/**\" in /on/push/paths-ignore does not match any files",
),
path: "/on/push/paths-ignore",
title: "Glob does not match any files",
},
],
}
But when .devcontainer/**
is replaced with .github/**
glob_not_matched
error related to this disappears
name: CI Workflow
on:
push:
paths-ignore:
- '.gitattributes'
- '**.MD'
- '.github/**'
Treating ci.yml as a Workflow definition
Fatal error validating .github/workflows/ci.yml
Validation failed: ValidationState {
action_type: Some(
Workflow,
),
file_path: Some(
".github/workflows/ci.yml",
),
errors: [
InvalidGlob {
code: "invalid_glob",
detail: Some(
"Glob \"**.MD\" in /on/push/paths-ignore is invalid: Pattern syntax error near position 2: recursive wildcards must form a single path component",
),
path: "/on/push/paths-ignore",
title: "Glob does not match any files",
},
],
}
IMO the right thing to do is disable glob validation until it can be made to match what GitHub uses.