Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
Make trigger_on_issue True by default
Browse files Browse the repository at this point in the history
  • Loading branch information
jpopelka committed Jan 16, 2020
1 parent 888113e commit f6ba9c1
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Here are possible options:
| `author_email`| Author email for changelog. If not set, author of the merge commit is used | No |
| `pypi` | Whether to release on pypi. True by default | No |
| `pypi_project`| Name of your PyPI repository | No |
| `trigger_on_issue`| Whether to allow bot to make PRs based on issues. False by default. | No |
| `trigger_on_issue`| Whether to allow bot to make PRs based on issues. True by default. | No |
| `labels` | List of labels that bot will put on issues and PRs | No |

Sample config named [release-conf-example.yaml](release-conf-example.yaml) can be found in this repository.
Expand Down
3 changes: 0 additions & 3 deletions release-conf.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# whether to allow bot to make PRs based on issues
trigger_on_issue: true

labels:
- bot
- release-bot
Expand Down
5 changes: 3 additions & 2 deletions release_bot/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def load_release_conf(self, conf):
sys.exit(1)

parsed_conf = yaml.safe_load(conf) or {}
# If pypi option is not specified in release-conf.yaml,
# it defaults to true.
# Set defaults for options not specified in release-conf.yaml
parsed_conf.setdefault('pypi', True)
parsed_conf.setdefault('trigger_on_issue', True)

parsed_conf = {k: v for (k, v) in parsed_conf.items() if v}
for item in self.REQUIRED_ITEMS['release-conf']:
Expand All @@ -152,6 +152,7 @@ def load_release_conf(self, conf):
self.logger.warning(msg)
parsed_conf['trigger_on_issue'] = False

self.logger.debug(f"Config: {parsed_conf}")
return parsed_conf

def set_pypi_project(self, parsed_conf, setup_cfg=None):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ def test_pypi_release(self, mock_upload, github_release, mock_get_latest_version
def test_run_once(self):
"""Test that the bot runs only once and exits."""
flexmock(self.release_bot.conf, refresh_interval=None)

(flexmock(self.release_bot.project) # make sure it interes the loop
flexmock(self.release_bot.github, comment=["foo", "bar"])
(flexmock(self.release_bot.project) # make sure it walks through the loop
.should_receive('pr_comment')
.once()
.and_return(PRComment("Fake comment", "FakeAuthor"))
Expand Down
1 change: 0 additions & 1 deletion tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def setup_method(self):
configuration.repository_name = self.g_utils.repo
configuration.github_username = self.g_utils.github_user
configuration.clone_url = f"https://github.com/{self.g_utils.github_user}/{self.g_utils.repo}.git"
configuration.refresh_interval = 1
configuration.project = configuration.get_project()

repo_url = f"https://github.com/{self.g_utils.github_user}/{self.g_utils.repo}"
Expand Down
3 changes: 1 addition & 2 deletions tests/test_load_release_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ def test_non_exiting_conf(self, non_existing_conf):

def test_missing_required_items(self, missing_items_conf):
backup = configuration.REQUIRED_ITEMS['release-conf']
# set trigger_on_issue as required
configuration.REQUIRED_ITEMS['release-conf'] = ['trigger_on_issue']
configuration.REQUIRED_ITEMS['release-conf'] = ['foo']
with pytest.raises(SystemExit) as error:
configuration.load_release_conf(missing_items_conf)
assert error.type == SystemExit
Expand Down

0 comments on commit f6ba9c1

Please sign in to comment.