action-validator icon indicating copy to clipboard operation
action-validator copied to clipboard

paths wildcard validation seems off

Open bplessis-swi opened this issue 2 years ago • 16 comments

Want to help get this issue implemented? Donate to the action-validator code fund.


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 image

Sample use

on:
  push:
    branches:
      - main
    paths:
      - '**.md'

Version

action-validator 0.3.0

bplessis-swi avatar Feb 08 '23 09:02 bplessis-swi

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.

mpalmer avatar Feb 08 '23 22:02 mpalmer

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.

bplessis-swi avatar Feb 09 '23 10:02 bplessis-swi

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 :-)

jhberges avatar Mar 02 '23 13:03 jhberges

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:

  • https://github.com/DawnbrandBots/yaml-yugi/blob/f55d872968ec5b400fa29a88aef2dd5865e97302/.github/workflows/validate-assignments.yaml#L5-L14
  • https://github.com/DawnbrandBots/yaml-yugi/blob/f55d872968ec5b400fa29a88aef2dd5865e97302/.github/workflows/validate-data.yaml#L16

kevinlul avatar Jul 21 '23 22:07 kevinlul

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

vitalii-buchyn-exa avatar Apr 03 '24 13:04 vitalii-buchyn-exa

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"!

mpalmer avatar Apr 03 '24 20:04 mpalmer

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",
        },
    ],
}

DilepDev avatar Apr 16 '24 07:04 DilepDev

IMO the right thing to do is disable glob validation until it can be made to match what GitHub uses.

dabrahams avatar Apr 30 '24 19:04 dabrahams