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

Syntax for complex combinations of conditions #7

Open
IvanFon opened this issue Mar 30, 2020 · 6 comments · Fixed by Resnovas/smartcloud#57
Open

Syntax for complex combinations of conditions #7

IvanFon opened this issue Mar 30, 2020 · 6 comments · Fixed by Resnovas/smartcloud#57
Labels
enhancement New feature or request proposal A proposed feature open for discussion.

Comments

@IvanFon
Copy link
Owner

IvanFon commented Mar 30, 2020

Currently, when you want to match multiple conditions, you can only specify how many need to match. A different syntax could allow you to specify more complex combinations using and, or, not, etc. operators.

I'm not sure what this would look like, and I'm not sure what it would look. It may not be useful enough to warrant the complexity.

@IvanFon IvanFon added enhancement New feature or request proposal A proposed feature open for discussion. labels Mar 30, 2020
@jbinda jbinda mentioned this issue Mar 30, 2020
9 tasks
@jayu
Copy link

jayu commented Mar 30, 2020

We could support syntax similar to MongoDB query operators https://docs.mongodb.com/manual/reference/operator/query/
Maybe not all of them, but the appropriate subset.
So eg. if an expression is defined as

{
  "type": "SOME_TYPE",
  "pattern": "SOME_PATTERN"
}

We could use following syntax

{
  "pr": {
    "bugfix": {
      "requires": 1,
      "conditions": {
        "$and": [
          {
            "type": "branchMatches",
            "pattern": "^bugfix"
          },
          {
            "$or": [
              {
                "type": "titleMatches",
                "pattern": "bugfix"
              },
              {
                "$not": {
                  "type": "titleMatches",
                  "pattern": "feature"
                }
              }
            ]
          }
        ]
      }
    }
  }
}

For backwards compatibility we could support conditions to be [] or {}
It is good to have [] option to use with more simple matches

@IvanFon
Copy link
Owner Author

IvanFon commented Mar 30, 2020

That's a good idea! Do you have any use cases for this already? I think I'm going to backlog this one until users needs it.

@jayu
Copy link

jayu commented Mar 31, 2020

I don't have a use case yet, but I didn't start using this action. We will see soon :D

@jayu
Copy link

jayu commented Apr 1, 2020

Ok I thing I see a use case for that, for Not and And operator. In Linaria https://github.com/callstack/linaria/ we support different bundlers like webpack, rollup.
I would like to label the issues based on with which bunder it is related. But if someone type
"it works in webpack, but crashes in rollup" I cannot determine to which bundler it Is related just by checking for the presence of rollup and webpack words. I could use Not and And to ensure that I add a label only if one of there words is present.

@TGTGamer
Copy link

+1 would love to have. for instance I've got the following check which I would love to override by using a simple $or so if one of my admins confirm the bug, it gets the label, otherwise, all the other conditions are required:

{
    "issue": {
        "confirmed": {
            "requires": 1,
            "conditions": {
                "$or": [
                    {
                        "$and": [
                            {
                            "type": "descriptionMatches",
                            "pattern": "/^- \\[x\\] bug Confirmed by (@.*& .*){4,}/im"
                            },
                            {
                            "type": "descriptionMatches",
                            "pattern": "/^- \\[x\\] have reproduced on my application version/im"
                            },
                            {
                            "type": "descriptionMatches",
                            "pattern": "/^- \\[x\\] have reproduced on clean installation/im"
                            },
                            {
                            "type": "descriptionMatches",
                            "pattern": "/^- \\[x\\] have reproduced on development build/im"
                            },
                            {
                            "type": "descriptionMatches",
                            "pattern": "/^- \\[x\\] have included logs or screenshots/im"
                            },
                            {
                            "type": "descriptionMatches",
                            "pattern": "/^- \\[x\\] have contacted support/im"
                            },
                            {
                            "type": "descriptionMatches",
                            "pattern": "/^- \\[x\\] have asked the community/im"
                            },
                            {
                            "type": "descriptionMatches",
                            "pattern": "/^- \\[x\\] have linked any related/im"
                            }
                        ]
                    },
                    {
                        "type": "descriptionMatches",
                        "pattern": "/^- \\[x\\] bug Confirmed by (@.*& )*@(tgtgamer|videndum\\/.*)/im"
                    }
                ]
            }
        }
    }
}

@TGTGamer
Copy link

Finally got round to adding this to my version of the labelled. Will soon push to #24 so people can use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request proposal A proposed feature open for discussion.
Projects
None yet
3 participants