labeler
labeler copied to clipboard
Issue of the label configuration file ".github/labeler.yml"
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).
I also spotted this. It happens if I have more than one entry in the any
specifier.
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/*']
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 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) } }
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?
Not quite. all
will check if all modified paths matches while any
will check if any modified patch matches.
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
Hi team,
Could anyone take a look at this issue?
I'm also running into this issue. I'm unable to use any configuration that has any
in it on 2.2.0.
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.
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?
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.
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!