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

90 days stale pr #52

Merged
merged 3 commits into from
Oct 7, 2024
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 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
Loading