From 131963ce6f106d0e3ecfc7b3374265ac691c113e Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Mon, 7 Oct 2024 11:15:57 +0100 Subject: [PATCH 1/3] MAINT: Change stale PR cut off to 90 days --- cloud-chatops/src/features/base_feature.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud-chatops/src/features/base_feature.py b/cloud-chatops/src/features/base_feature.py index 6fe3fc1..9c1ed30 100644 --- a/cloud-chatops/src/features/base_feature.py +++ b/cloud-chatops/src/features/base_feature.py @@ -143,7 +143,7 @@ def _construct_string(pr_data: PrData) -> str: message = [] if pr_data.old: - message.append("*This PR is older than 6 months. Consider closing it:*") + message.append("*This PR is older than 90 days. Consider closing it:*") message.append(f"Pull Request: <{pr_data.url}|{pr_data.pr_title}>") message.append(f"Author: {name}") return "\n".join(message) @@ -157,7 +157,7 @@ def _check_pr_age(time_created: str) -> bool: """ opened_date = datetime_parser.parse(time_created).replace(tzinfo=None) datetime_now = datetime.now().replace(tzinfo=None) - time_cutoff = datetime_now - timedelta(days=30 * 6) + time_cutoff = datetime_now - timedelta(days=90) return opened_date < time_cutoff def check_pr(self, info: PrData) -> PrData: From b88e954dab317dc608c5bc9ca0249f06670b4d2c Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Mon, 7 Oct 2024 11:16:52 +0100 Subject: [PATCH 2/3] MAINT: Bump version --- cloud-chatops/docker-compose.yaml | 2 +- cloud-chatops/version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud-chatops/docker-compose.yaml b/cloud-chatops/docker-compose.yaml index 0d3d353..ffe1148 100644 --- a/cloud-chatops/docker-compose.yaml +++ b/cloud-chatops/docker-compose.yaml @@ -1,5 +1,5 @@ services: cloud_chatops: - image: harbor.stfc.ac.uk/stfc-cloud/cloud-chatops:1.0.5 + image: harbor.stfc.ac.uk/stfc-cloud/cloud-chatops:1.0.6 volumes: - $HOME/cloud_chatops_secrets/:/usr/src/app/cloud_chatops_secrets/ diff --git a/cloud-chatops/version.txt b/cloud-chatops/version.txt index 90a27f9..af0b7dd 100644 --- a/cloud-chatops/version.txt +++ b/cloud-chatops/version.txt @@ -1 +1 @@ -1.0.5 +1.0.6 From 083f42a5578b6777bcea8d20b2522718091c1719 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Mon, 7 Oct 2024 11:26:29 +0100 Subject: [PATCH 3/3] TEST: Fixing unit tests from time cut off change --- cloud-chatops/tests/test_pr_message_builder.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cloud-chatops/tests/test_pr_message_builder.py b/cloud-chatops/tests/test_pr_message_builder.py index 7bd9fe4..037cedc 100644 --- a/cloud-chatops/tests/test_pr_message_builder.py +++ b/cloud-chatops/tests/test_pr_message_builder.py @@ -63,7 +63,7 @@ def test_construct_string_old(mock_web_client, mock_get_token, instance): res = instance._construct_string(mock_data) mock_web_client.assert_called_once_with(token=mock_get_token.return_value) expected = ( - "*This PR is older than 6 months. Consider closing it:*\n" + "*This PR is older than 90 days. Consider closing it:*\n" "Pull Request: \nAuthor: mock_real_name" ) assert res == expected @@ -81,7 +81,7 @@ def test_construct_string_fails_lookup(mock_web_client, _2, instance): mock_data.user = "mock_user" res = instance._construct_string(mock_data) expected = ( - "*This PR is older than 6 months. Consider closing it:*\n" + "*This PR is older than 90 days. Consider closing it:*\n" "Pull Request: \nAuthor: mock_user" ) assert res == expected @@ -96,14 +96,14 @@ def test_check_pr_age_not_old( ): """Test returns false since PR is not old""" mock_datetime_parser.parse.return_value.replace.return_value = 100 - mock_datetime.now.return_value.replace.return_value = 200 - mock_timedelta.return_value = 30 * 6 + mock_datetime.now.return_value.replace.return_value = 190 + mock_timedelta.return_value = 90 res = instance._check_pr_age(100) mock_datetime_parser.parse.assert_called_once_with(100) mock_datetime_parser.parse.return_value.replace.assert_called_once_with(tzinfo=None) mock_datetime.now.assert_called_once_with() mock_datetime.now.return_value.replace.assert_called_once_with(tzinfo=None) - mock_timedelta.assert_called_once_with(days=30 * 6) + mock_timedelta.assert_called_once_with(days=90) assert not res @@ -117,13 +117,13 @@ def test_check_pr_age_old( """Test returns false since PR is old""" mock_datetime_parser.parse.return_value.replace.return_value = 100 mock_datetime.now.return_value.replace.return_value = 300 - mock_timedelta.return_value = 30 * 6 + mock_timedelta.return_value = 90 res = instance._check_pr_age(100) mock_datetime_parser.parse.assert_called_once_with(100) mock_datetime_parser.parse.return_value.replace.assert_called_once_with(tzinfo=None) mock_datetime.now.assert_called_once_with() mock_datetime.now.return_value.replace.assert_called_once_with(tzinfo=None) - mock_timedelta.assert_called_once_with(days=30 * 6) + mock_timedelta.assert_called_once_with(days=90) assert res