From f6ba9c1513f324545da3243d04f39546c1eebea0 Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: Thu, 16 Jan 2020 17:41:24 +0100 Subject: [PATCH] Make trigger_on_issue True by default --- README.md | 2 +- release-conf.yaml | 3 --- release_bot/configuration.py | 5 +++-- tests/test_bot.py | 4 ++-- tests/test_github.py | 1 - tests/test_load_release_conf.py | 3 +-- 6 files changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 75ffd7e..dee969c 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/release-conf.yaml b/release-conf.yaml index 2dbb423..466362f 100644 --- a/release-conf.yaml +++ b/release-conf.yaml @@ -1,6 +1,3 @@ -# whether to allow bot to make PRs based on issues -trigger_on_issue: true - labels: - bot - release-bot diff --git a/release_bot/configuration.py b/release_bot/configuration.py index ad7bf5a..2f06040 100644 --- a/release_bot/configuration.py +++ b/release_bot/configuration.py @@ -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']: @@ -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): diff --git a/tests/test_bot.py b/tests/test_bot.py index e1fd6c5..dd0bb87 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -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")) diff --git a/tests/test_github.py b/tests/test_github.py index b57bb97..e9d470e 100644 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -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}" diff --git a/tests/test_load_release_conf.py b/tests/test_load_release_conf.py index a24ff61..bd3771b 100644 --- a/tests/test_load_release_conf.py +++ b/tests/test_load_release_conf.py @@ -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