labeler icon indicating copy to clipboard operation
labeler copied to clipboard

Issue of the label configuration file ".github/labeler.yml"

Open BrightRan opened this issue 3 years ago • 10 comments

Associated GitHub Community ticket: https://github.community/t/labeler-typeerror-glob-pattern-string-required/133467

According to the README of this action, the following configurations in the label configuration file should work:

label-1:
  - any: ['list', 'of', 'globs']
    all: ['list', 'of', 'globs']

label-2:
  - example1/*
  - example2/**/*

I tested with two label configuration files in my repository (see here).

  • .github/labeler-01.yml
    common:
      - any: ['./*', './src/**']
    
    workflow:
      - any: ['.github/workflows/**']
    
  • .github/labeler-02.yml
    repo:
      - './*'
      - './src/**'
    
    GHA:
      - '.github/**'
    

And my workflow looks like this (see here):

name: CI

on: pull_request

jobs:
  job1:
    runs-on: ubuntu-latest
    steps:         
      - name: PR Labeler
        uses: actions/[email protected]
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          configuration-path: .github/labeler-01.yml

  job2:
    runs-on: ubuntu-latest
    steps:         
      - name: PR Labeler
        uses: actions/[email protected]
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          configuration-path: .github/labeler-02.yml

I changed the following files:

  • ./.github/workflows/ci.yml
  • ./test.txt
  • ./src/test.txt

However, finally only the GHA label was added successfully, the other three should also be added but not (see the example PR).

When using '.github/labeler-01.yml', the actions always fails with the error (see job1):

##[error]TypeError: glob pattern string required
##[error]glob pattern string required

When using '.github/labeler-02.yml', the action displays as success, but only the GHA label is added (see job2).

BrightRan avatar Sep 23 '20 03:09 BrightRan

I also spotted this. It happens if I have more than one entry in the any specifier.

hauleth avatar Sep 25 '20 10:09 hauleth

Ok, I have found what is the culprit there. The meaning of any and all is poorly defined. The issue there is that

- any: ['./*', './src/*']

and

- ./*
- ./src/*

Have different meaning. The list in any mean that any file in the PR must match all globs in the list. With all it mean that all files in the PR must match all globs in the list. So to have the same behaviour with any you need to use:

- any: ['./*']
- any: ['./src/*']

hauleth avatar Sep 27 '20 08:09 hauleth

Have different meaning. The list in any mean that any file in the PR must match all globs in the list. With all it mean that all files in the PR must match all globs in the list. So to have the same behaviour with any you need to use.

Nope. Still don't get it 😅

mittalyashu avatar Sep 28 '20 00:09 mittalyashu

@mittalyashu assume that you have such definition any: ['src/*', '*/test/*']. Then it will apply the tag if any of the files matches all globs. So for example if your PR changes files:

  • examples/foo
  • src/test/foo

Then it will apply, as src/test/foo matches both of the globs. However if list of files would look like:

  • examples/test/foo

Then it will not match, because while */test/* matches, the src/* doesn't, so whole filter fails.

You can think of it like (using Ruby syntax):

  • any - changed_files.any? { |file| matches.all? { |match| file.matches(match) } }
  • all - changed_files.all? { |file| matches.all? { |match| file.matches(match) } }

hauleth avatar Sep 28 '20 09:09 hauleth

Oh! I see.

Well, seems like the docs were not clear.

I was thinking that in the any filter, it will match any globs listed in the array.


In that case, doesn't that means any and all both plays the same role?

mittalyashu avatar Sep 29 '20 01:09 mittalyashu

Not quite. all will check if all modified paths matches while any will check if any modified patch matches.

hauleth avatar Sep 29 '20 08:09 hauleth

Another user has the similar problem: https://github.community/t/labler-action-error-typeerror-glob-pattern-string-required-glob-pattern-string-required/140738

He gets the same error message:

##[error]TypeError: glob pattern string required
##[error]glob pattern string required

BrightRan avatar Nov 03 '20 03:11 BrightRan

Hi team,

Could anyone take a look at this issue?

BrightRan avatar Nov 03 '20 03:11 BrightRan

I'm also running into this issue. I'm unable to use any configuration that has any in it on 2.2.0.

kbendick avatar Nov 04 '20 01:11 kbendick

Hit this error just now:

  • https://github.com/OpenISS/OpenISS/blob/master/.github/labeler.yml
  • https://github.com/OpenISS/OpenISS/pull/86
  • https://github.com/OpenISS/OpenISS/runs/4811417470

It appears to have labeled two things correctly before barfing out.

smokhov avatar Jan 14 '22 01:01 smokhov

Hello everyone! We have released a new major version of the action. The behaviour of the any selector was changed to match ANY file against ANY glob pattern so it became more intuitive. Please find more details in the release notes.

Could you please use the new version and provide us with your feedback?

MaksimZhukov avatar Jun 06 '23 16:06 MaksimZhukov

Hello everyone! We've released a new beta version of the action. The configuration file structure was changed to provide more flexibility and readability. For more information, see the release notes.

If you have any questions, ideas or concerns, please share them in this issue.

MaksimZhukov avatar Sep 20 '23 14:09 MaksimZhukov

Hello everyone! We have released the new major version of the action, which contains a new, more intuitive and flexible configuration file structure. Please read the action documentation to find out how to adapt your configuration files and workflows for use with the new action version.

Thank you all for your patience! Do not hesitate to contact us if you have any questions!

MaksimZhukov avatar Dec 05 '23 20:12 MaksimZhukov