Skip to content

Commit

Permalink
Merge pull request #52 from stfc/90_days_stale_pr
Browse files Browse the repository at this point in the history
90 days stale pr
  • Loading branch information
jacob-ward authored Oct 7, 2024
2 parents 79a8cff + 083f42a commit 595893f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cloud-chatops/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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/
4 changes: 2 additions & 2 deletions cloud-chatops/src/features/base_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions cloud-chatops/tests/test_pr_message_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: <mock_url|mock_title>\nAuthor: mock_real_name"
)
assert res == expected
Expand All @@ -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: <mock_url|mock_title>\nAuthor: mock_user"
)
assert res == expected
Expand All @@ -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


Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion cloud-chatops/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.5
1.0.6

0 comments on commit 595893f

Please sign in to comment.