Skip to content

Commit

Permalink
fix regex, improve prdoc generation inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
mordamax committed Oct 4, 2024
1 parent 111b244 commit f5e3ad7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
15 changes: 7 additions & 8 deletions .github/scripts/generate-prdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
This will delete any prdoc that already exists for the PR if `--force` is passed.
Usage:
python generate-prdoc.py --pr 1234 --audience "TODO" --bump "TODO"
python generate-prdoc.py --pr 1234 --audience "Node Dev" --bump "patch"
"""

import argparse
Expand Down Expand Up @@ -111,21 +111,20 @@ def yaml_multiline_string_presenter(dumper, data):

# parse_args is also used by cmd/cmd.py
def setup_parser(parser=None):
allowed_audiences = ["Runtime Dev", "Runtime User", "Node Dev", "Node Operator"]
if parser is None:
parser = argparse.ArgumentParser()
parser.add_argument("--pr", type=int, required=True, help="The PR number to generate the PrDoc for." )
parser.add_argument("--audience", type=str, default="TODO", help="The audience of whom the changes may concern.")
parser.add_argument("--bump", type=str, default="TODO", help="A default bump level for all crates.")
parser.add_argument("--force", type=str, help="Whether to overwrite any existing PrDoc.")

parser.add_argument("--audience", type=str, nargs='*', choices=allowed_audiences, default=["TODO"], help="The audience of whom the changes may concern. Example: --audience \"Runtime Dev\" \"Node Dev\"")
parser.add_argument("--bump", type=str, default="major", choices=["patch", "minor", "major", "silent", "ignore", "no change"], help="A default bump level for all crates. Example: --bump \"patch\"")
parser.add_argument("--force", action="store_true", help="Whether to overwrite any existing PrDoc.")
return parser

def main(args):
force = True if (args.force or "false").lower() == "true" else False
print(f"Args: {args}, force: {force}")
print(f"Args: {args}, force: {args.force}")
setup_yaml()
try:
from_pr_number(args.pr, args.audience, args.bump, force)
from_pr_number(args.pr, args.audience, args.bump, args.force)
return 0
except Exception as e:
print(f"Error generating prdoc: {e}")
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
id: get-pr-comment
with:
text: ${{ github.event.comment.body }}
regex: '^(\/cmd )([-\/\s\w.=:]+)$' # see explanation in docs/contributor/commands-readme.md#examples
regex: "^(\\/cmd )([-\\/\\s\\w.=:'\"]+)$" # see explanation in docs/contributor/commands-readme.md#examples

- name: Save output of help
id: help
Expand Down Expand Up @@ -291,7 +291,7 @@ jobs:
id: get-pr-comment
with:
text: ${{ github.event.comment.body }}
regex: '^(\/cmd )([-\/\s\w.=:]+)$' # see explanation in docs/contributor/commands-readme.md#examples
regex: "^(\\/cmd )([-\\/\\s\\w.=:'\"]+)$" # see explanation in docs/contributor/commands-readme.md#examples

- name: Build workflow link
if: ${{ !contains(github.event.comment.body, '--quiet') }}
Expand Down
3 changes: 2 additions & 1 deletion docs/contributor/commands-readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ the default branch.

### Examples

The regex in cmd.yml is: `^(\/cmd )([-\/\s\w.=:]+)$` accepts only alphanumeric, space, "-", "/", "=", ":", "." chars.
The regex in cmd.yml is: `^(\/cmd )([-\/\s\w.=:'"]+)$` accepts only alphanumeric, space, "-", "/", "=", ":", ".", '"' chars.

`/cmd bench --runtime bridge-hub-westend --pallet=pallet_name`
`/cmd prdoc --pr 5924 --audience "Node Dev" "Node Operator" --bump "patch"`
`/cmd update-ui --image=docker.io/paritytech/ci-unified:bullseye-1.77.0-2024-04-10-v202407161507 --clean`

0 comments on commit f5e3ad7

Please sign in to comment.