You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2025/04/03 15:09:08 UTC
(tooling-trusted-release) branch main updated: Send vote announcements to an actual test email list
This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git
The following commit(s) were added to refs/heads/main by this push:
new 51c1c0e Send vote announcements to an actual test email list
51c1c0e is described below
commit 51c1c0ec8983d6d2803d2b7b95b57901d7300d00
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Thu Apr 3 16:08:47 2025 +0100
Send vote announcements to an actual test email list
---
atr/routes/candidate.py | 25 ++++++++++++++++++++++++-
atr/tasks/vote.py | 23 +++++++++++------------
atr/templates/candidate-resolve.html | 7 ++++++-
atr/templates/candidate-vote-project.html | 4 ++--
4 files changed, 43 insertions(+), 16 deletions(-)
diff --git a/atr/routes/candidate.py b/atr/routes/candidate.py
index 563801d..dc49ab9 100644
--- a/atr/routes/candidate.py
+++ b/atr/routes/candidate.py
@@ -17,6 +17,8 @@
"""candidate.py"""
+import json
+
import aiofiles.os
import aioshutil
import asfquart
@@ -332,11 +334,32 @@ async def _resolve_get(session: routes.CommitterSession) -> str:
# Find the most recent VOTE_INITIATE task for this release
# TODO: Make this a proper query
latest_vote_task = None
+ task_mid = None
for task in sorted(candidate.tasks, key=lambda t: t.added, reverse=True):
if task.task_type == models.TaskType.VOTE_INITIATE:
latest_vote_task = task
break
- candidate_vote_tasks[candidate.name] = latest_vote_task
+
+ if latest_vote_task and (latest_vote_task.status == models.TaskStatus.COMPLETED) and latest_vote_task.result:
+ try:
+ # Result is stored as a JSON string
+ # Handle that defensively
+ if isinstance(latest_vote_task.result, str):
+ parsed_result = json.loads(latest_vote_task.result)
+ elif isinstance(latest_vote_task.result, dict):
+ parsed_result = latest_vote_task.result
+ else:
+ parsed_result = {}
+
+ if isinstance(parsed_result, dict):
+ task_mid = parsed_result.get("mid", "(mid not found in result)")
+ else:
+ task_mid = "(no result)"
+
+ except (json.JSONDecodeError, TypeError):
+ task_mid = "(malformed result)"
+
+ candidate_vote_tasks[candidate.name] = (latest_vote_task, task_mid)
return await quart.render_template(
"candidate-resolve.html",
diff --git a/atr/tasks/vote.py b/atr/tasks/vote.py
index 7174b52..1494fbd 100644
--- a/atr/tasks/vote.py
+++ b/atr/tasks/vote.py
@@ -16,6 +16,7 @@
# under the License.
import datetime
+import json
import logging
import os
from typing import Any, Final
@@ -54,10 +55,7 @@ async def initiate(args: Initiate) -> str | None:
"""Initiate a vote for a release."""
try:
result_data = await _initiate_core_logic(args)
- success_message = result_data.get("message", "Vote initiated successfully, but message missing")
- if not isinstance(success_message, str):
- raise VoteInitiationError("Success message is not a string")
- return success_message
+ return json.dumps(result_data)
except VoteInitiationError as e:
_LOGGER.error(f"Vote initiation failed: {e}")
@@ -69,7 +67,7 @@ async def initiate(args: Initiate) -> str | None:
async def _initiate_core_logic(args: Initiate) -> dict[str, Any]:
"""Get arguments, create an email, and then send it to the recipient."""
- test_recipients = ["sbp"]
+ tooling_test_recipients = ["user-tests"]
_LOGGER.info("Starting initiate_core")
async with db.session() as data:
@@ -121,29 +119,30 @@ async def _initiate_core_logic(args: Initiate) -> dict[str, Any]:
# Store the original recipient for logging
original_recipient = args.email_to
# Only one test recipient is required for now
- test_recipient = test_recipients[0] + "@apache.org"
- _LOGGER.info(f"TEMPORARY: Overriding recipient from {original_recipient} to {test_recipient}")
+ tooling_test_recipient = tooling_test_recipients[0] + "@tooling.apache.org"
+ _LOGGER.info(f"TEMPORARY: Overriding recipient from {original_recipient} to {tooling_test_recipient}")
# Create mail event with test recipient
# Use test account instead of actual PMC list
event = mail.VoteEvent(
release_name=args.release_name,
- email_recipient=test_recipient,
+ email_recipient=tooling_test_recipient,
subject=subject,
body=body,
vote_end=vote_end,
)
# Send the email
- await mail.send(event)
+ mid = await mail.send(event)
_LOGGER.info(
- f"Vote email sent successfully to test account {test_recipient} (would have been {original_recipient})"
+ f"Vote email sent successfully to test account {tooling_test_recipient} (would have been {original_recipient})"
)
return {
- "message": "Vote initiated successfully (sent to test account)",
+ "message": "Vote initiated successfully, and sent to test account",
"original_email_to": original_recipient,
- "actual_email_to": test_recipient,
+ "actual_email_to": tooling_test_recipient,
"vote_end": vote_end_str,
"subject": subject,
+ "mid": mid,
}
diff --git a/atr/templates/candidate-resolve.html b/atr/templates/candidate-resolve.html
index f417c0e..d9ab0c1 100644
--- a/atr/templates/candidate-resolve.html
+++ b/atr/templates/candidate-resolve.html
@@ -41,13 +41,18 @@
<span class="atr-candidate-meta-item">Created: {{ candidate.created.strftime("%Y-%m-%d %H:%M:%S UTC") }}</span>
</div>
- {% set vote_task = candidate_vote_tasks[candidate.name] %}
+ {% set vote_task, task_mid = candidate_vote_tasks[candidate.name] %}
<div class="mt-2 p-3 border rounded bg-white mb-3">
{% if vote_task %}
{% if vote_task.status.value == "completed" %}
<p class="mb-0 text-success fw-semibold">
<i class="bi bi-check-circle-fill me-1"></i> Vote email sent: {{ vote_task.completed.strftime("%Y-%m-%d %H:%M:%S UTC") }}
</p>
+ {% if task_mid %}
+ <p class="mb-0 small text-muted ps-4">
+ Message-ID: <code class="user-select-all">{{ task_mid }}</code>
+ </p>
+ {% endif %}
{% elif vote_task.status.value == "failed" %}
<p class="mb-1 text-danger fw-semibold">
<i class="bi bi-x-octagon-fill me-1"></i> Vote email failed: {{ vote_task.completed.strftime("%Y-%m-%d %H:%M:%S UTC") }}
diff --git a/atr/templates/candidate-vote-project.html b/atr/templates/candidate-vote-project.html
index 30314b9..e51115e 100644
--- a/atr/templates/candidate-vote-project.html
+++ b/atr/templates/candidate-vote-project.html
@@ -22,7 +22,7 @@
</div>
<div class="p-3 mb-4 bg-warning-subtle border border-warning rounded">
- <strong>Note:</strong> This feature is currently in development. The form below only sends email to a test account.
+ <strong>Note:</strong> This feature is currently in development. The form below only sends email to a test account, not the email addresses listed in the form.
</div>
{% if form.errors %}
@@ -45,7 +45,7 @@
<div class="mb-4">
<div class="row mb-3 pb-3 border-bottom{% if form.mailing_list.errors %} has-danger{% endif %}">
- <div class="col-md-3 text-md-end fw-medium pt-2">{{ form.mailing_list.label }}</div>
+ <div class="col-md-3 text-md-end fw-medium">{{ form.mailing_list.label }}</div>
<div class="col-md-9">
<div class="d-flex gap-4">
{% for subfield in form.mailing_list %}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org