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

Update Group Config Parsing #25

Merged
merged 2 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ and renders the changelog according to users config. Then the changes are commit
To use this Action The pull **request title** must match with the default ``regex``
or the user provided ``regex`` from the config file.

**Default title regex:** ``^(?i)release`` (title must start with the word "release" (case insensitive))
**Default title regex:** ``^(?i:release)`` (title must start with the word "release" (case insensitive))

**Default version number regex:** This follows [``SemVer``](https://regex101.com/r/Ly7O1x/3/) (Semantic Versioning) pattern.
e.g. ``1.0.0``, ``1.0``, ``v1.0.1`` etc.
Expand Down
43 changes: 27 additions & 16 deletions scripts/changelog-ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,32 +377,43 @@ def parse_config(config):
if not group_config or not isinstance(group_config, list):
logger.warning(
'``group_config`` was not provided or not valid '
'Falling back to default regex.'
'Falling back to default group config.'
)
# if the group_config is not not available
# fallback to default group_config
config.update({
"group_config": DEFAULT_GROUP_CONFIG
})
else:
# Check if all the group configs match the schema
for config in group_config:
if not isinstance(config, dict):
raise TypeError(
'group_config items must have key, '
'value pairs of title and labels'
)
title = config.get('title')
labels = config.get('labels')
try:
# Check if all the group configs match the schema
for config in group_config:
if not isinstance(config, dict):
raise TypeError(
'group_config items must have key, '
'value pairs of title and labels'
)
title = config.get('title')
labels = config.get('labels')

if not title:
raise KeyError('group_config item must contain title')

if not title:
raise KeyError('group_config item must contain title')
if not labels:
raise KeyError('group_config item must contain labels')

if not labels:
raise KeyError('group_config item must contain labels')
if not isinstance(labels, list):
raise TypeError('group_config labels must be an Array')

if not isinstance(labels, list):
raise TypeError('group_config labels must be an Array')
except Exception as e:
logger.warning(
'An error occurred while parsing ``group_config``. Error: %s'
'Falling back to default group config.', e
)
# Fallback to default group_config
config.update({
"group_config": DEFAULT_GROUP_CONFIG
})


if __name__ == '__main__':
Expand Down