IvanFon / super-labeler-action

A superpowered issue and pull request labeler for Github Actions.
GNU General Public License v3.0
22 stars 12 forks source link

Syntax for complex combinations of conditions #7

Open IvanFon opened 4 years ago

IvanFon commented 4 years ago

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.

jayu commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

jayu commented 4 years ago

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 commented 4 years ago

+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 commented 3 years ago

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