Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paths wildcard validation seems off #27

Open
bplessis-swi opened this issue Feb 8, 2023 · 8 comments
Open

paths wildcard validation seems off #27

bplessis-swi opened this issue Feb 8, 2023 · 8 comments
Labels
pr-welcome This would be a good fix/feature, but the maintainer isn't planning on doing the work

Comments

@bplessis-swi
Copy link

bplessis-swi commented Feb 8, 2023

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

@mpalmer
Copy link
Owner

mpalmer commented Feb 8, 2023

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.

@bplessis-swi
Copy link
Author

bplessis-swi commented Feb 9, 2023

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.

@mpalmer mpalmer mentioned this issue Feb 16, 2023
5 tasks
@jhberges
Copy link

jhberges commented Mar 2, 2023

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

@mpalmer mpalmer added the pr-welcome This would be a good fix/feature, but the maintainer isn't planning on doing the work label Nov 24, 2023
@vitalii-buchyn-exa
Copy link

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

@mpalmer
Copy link
Owner

mpalmer commented Apr 3, 2024

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

@DilepDev
Copy link

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

@dabrahams
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-welcome This would be a good fix/feature, but the maintainer isn't planning on doing the work
Projects
None yet
Development

No branches or pull requests

7 participants