Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/docker/build-push-…
Browse files Browse the repository at this point in the history
…action-6
  • Loading branch information
GabDug authored Sep 27, 2024
2 parents 8988219 + 9b3c720 commit 4c4b6d4
Show file tree
Hide file tree
Showing 19 changed files with 329 additions and 61 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ ENABLE_RAID=False

RAID_DEFAULT_JIRA_QRAFT_USER_ID="XXXXXXXX" #gitleaks:allow
RAID_JIRA_PROJECT_KEY="T2"
RAID_TOOLBOX_URL=https://toolbox.mycompany.com/login

FF_SLACK_SKIP_CHECKS=true
# Disable SSO redirect for local dev by setting to true. When SSO is disabled, go to /admin/ to login
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ jobs:
pdm run collectstatic
pdm run tests-cov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests

- name: Type check with mypy
run: |
pdm run lint-mypy
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# This configuration file is for the **development** setup.
# It will launch Postgres and Redis containers, not the app itself.

version: "3.1"

services:
db:
container_name: ff-db
Expand Down
9 changes: 4 additions & 5 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies = [
"django-htmx>=1.17.2",
"django-simple-menu>=2.1.3",
"markdown>=3.5.1",
"jira>=3.5.2",
"jira>=3.5.2,<3.6.0", # 3.6.0 stop accepting user id for add_watcher, see https://github.com/pycontribs/jira/issues/1855
"drf-standardized-errors>=0.12.6",
"aiohttp>=3.9.1", # Transitive dependency of slack_sdk
"nh3>=0.2.15",
Expand Down
3 changes: 3 additions & 0 deletions src/firefighter/firefighter/settings/components/raid.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@

RAID_JIRA_USER_IDS: dict[str, str] = {}
"Mapping of domain to default Jira user ID"

RAID_TOOLBOX_URL: str = config("RAID_TOOLBOX_URL")
"Toolbox URL"
33 changes: 33 additions & 0 deletions src/firefighter/incidents/forms/edit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from __future__ import annotations

from django import forms

from firefighter.incidents.models import Environment


def initial_environments() -> Environment:
return Environment.objects.get(default=True)


class EditMetaForm(forms.Form):
title = forms.CharField(
label="Title",
max_length=128,
min_length=10,
widget=forms.TextInput(attrs={"placeholder": "What's going on?"}),
)
description = forms.CharField(
label="Summary",
widget=forms.Textarea(
attrs={
"placeholder": "Help people responding to the incident. This will be posted to #tech-incidents and on our internal status page.\nThis description can be edited later."
}
),
min_length=10,
max_length=1200,
)
environment = forms.ModelChoiceField(
label="Environment",
queryset=Environment.objects.all(),
initial=initial_environments,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.2.14 on 2024-09-27 10:06

from django.db import migrations, models

import firefighter.incidents.models.environment


class Migration(migrations.Migration):

dependencies = [
("incidents", "0003_delete_featureteam"),
]

operations = [
migrations.AddField(
model_name="incidentupdate",
name="environment",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=models.SET(
firefighter.incidents.models.environment.Environment.get_default
),
to="incidents.environment",
),
),
]
35 changes: 22 additions & 13 deletions src/firefighter/incidents/models/incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,27 @@ def can_be_closed(self) -> tuple[bool, list[tuple[str, str]]]:
return True, []
if self.needs_postmortem:
if self.status.value != IncidentStatus.POST_MORTEM:
cant_closed_reasons.append((
"STATUS_NOT_POST_MORTEM",
f"Incident is not in PostMortem status, and needs one because of its priority and environment ({self.priority.name}/{self.environment.value}).",
))
cant_closed_reasons.append(
(
"STATUS_NOT_POST_MORTEM",
f"Incident is not in PostMortem status, and needs one because of its priority and environment ({self.priority.name}/{self.environment.value}).",
)
)
elif self.status.value < IncidentStatus.FIXED:
cant_closed_reasons.append((
"STATUS_NOT_MITIGATED",
f"Incident is not in {IncidentStatus.FIXED.label} status (currently {self.status.label}).",
))
cant_closed_reasons.append(
(
"STATUS_NOT_MITIGATED",
f"Incident is not in {IncidentStatus.FIXED.label} status (currently {self.status.label}).",
)
)
missing_milestones = self.missing_milestones()
if len(missing_milestones) > 0:
cant_closed_reasons.append((
"MISSING_REQUIRED_KEY_EVENTS",
f"Missing key events: {', '.join(missing_milestones)}",
))
cant_closed_reasons.append(
(
"MISSING_REQUIRED_KEY_EVENTS",
f"Missing key events: {', '.join(missing_milestones)}",
)
)

if len(cant_closed_reasons) > 0:
return False, cant_closed_reasons
Expand Down Expand Up @@ -534,7 +540,7 @@ def update_roles(

return incident_update

def create_incident_update(
def create_incident_update( # noqa: PLR0913
self: Incident,
message: str | None = None,
status: int | None = None,
Expand All @@ -544,6 +550,7 @@ def create_incident_update(
event_type: str | None = None,
title: str | None = None,
description: str | None = None,
environment_id: str | None = None,
event_ts: datetime | None = None,
) -> IncidentUpdate:
updated_fields: list[str] = []
Expand All @@ -560,6 +567,7 @@ def _update_incident_field(
_update_incident_field(self, "component_id", component_id, updated_fields)
_update_incident_field(self, "title", title, updated_fields)
_update_incident_field(self, "description", description, updated_fields)
_update_incident_field(self, "environment_id", environment_id, updated_fields)

old_priority = self.priority if priority_id is not None else None

Expand All @@ -573,6 +581,7 @@ def _update_incident_field(
incident=self,
status=status, # type: ignore
priority_id=priority_id,
environment_id=environment_id,
component_id=component_id,
message=message,
created_by=created_by,
Expand Down
7 changes: 7 additions & 0 deletions src/firefighter/incidents/models/incident_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from firefighter.incidents.enums import IncidentStatus
from firefighter.incidents.models.component import Component
from firefighter.incidents.models.environment import Environment
from firefighter.incidents.models.priority import Priority
from firefighter.incidents.models.severity import Severity
from firefighter.incidents.models.user import User
Expand Down Expand Up @@ -65,6 +66,12 @@ class IncidentUpdate(models.Model):
priority = models.ForeignKey[Priority | None, Priority | None](
Priority, null=True, blank=True, on_delete=models.SET(Priority.get_default)
)
environment = models.ForeignKey[Environment | None, Environment | None](
Environment,
null=True,
blank=True,
on_delete=models.SET(Environment.get_default),
)
incident = models.ForeignKey["Incident", "Incident"](
"Incident", on_delete=models.CASCADE
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@
</div>
</div>
<div class="text-neutral-600 dark:text-neutral-100">
{% if incident_update.title %}
<p class="mt-0.5">
Title update
</p>
<p class="pl-2 mt-0.5 text-sm text-neutral-500 dark:text-neutral-300">
Title changed to: {{ incident_update.title }}
</p>
{% endif %}
{% if incident_update.description or incident_update.description|length > 0 %}
<p class="mt-0.5">
Description update
</p>
<div
class="pb-2"
>
<div class="text-sm flex flex-col border-b border-neutral-200 py-1 p-4 text-left sm:border-0 sm:border-l-4 break-words">
{{ incident_update.description | urlize | linebreaksbr}}
</div>
</div>
{% endif %}
{% if incident_update.event_type or incident_update.event_type|length > 0 %}
<p class="mt-0.5">
Key event: {{ incident_update.event_type|title }}
Expand All @@ -65,6 +85,17 @@
{% include "./status_pill.html" with status=incident_update.status IncidentStatus=IncidentStatus only %}
</p>
{% endif %}
{% if incident_update.environment %}
<p class="mt-0.5">
Environment update
</p>
{% endif %}
{% if incident_update.environment or incident_update.environment|length > 0 %}
<p class="pl-2 mt-0.5 text-sm text-neutral-500 dark:text-neutral-300">
Environment changed to:
{% include "./environment_pill.html" with environment=incident_update.environment only %}
</p>
{% endif %}
{% if incident_update.severity %}
<p class="mt-0.5">
Severity update
Expand All @@ -84,8 +115,6 @@
<p class="mt-0.5">
Component update
</p>
{% endif %}
{% if incident_update.component %}
<p class="pl-2 mt-0.5 text-sm text-neutral-500 dark:text-neutral-300">
Component impacted changed to:
{{ incident_update.component}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ <h4 class="text-center font-medium text-sm text-neutral-500 dark:text-neutral-10
{% fill "card_content" %}
{% for role in incident.roles_set.all %}
<span class="ff-tooltip">
{% include "../layouts/partials/user_card.html" with user=role.user title=role.role.name only %}
{% include "../layouts/partials/user_card.html" with user=role.user title=role.role_type.name only %}
{% include "../layouts/partials/user_tooltip.html" with user=role.user only %}
</span>
{% endfor %}
Expand All @@ -207,6 +207,12 @@ <h3 class="flex-auto truncate text-sm font-semibold leading-6 text-neutral-900 d
<p class="mt-2 truncate text-sm text-neutral-500 dark:text-neutral-300">{{impact.impact_level.value_label}}: {{impact.impact_level.name}}</p>
</li>
</ul>
{% empty %}
<div class="px-4 py-5 sm:px-6 col-span-2">
<h4 class="text-center font-medium text-sm text-neutral-500 dark:text-neutral-100">
No impacts defined at the moment.
</h4>
</div>
{% endfor %}
{% endfill %}
{% endcomponent %}
Expand Down
3 changes: 2 additions & 1 deletion src/firefighter/raid/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
logger = logging.getLogger(__name__)

RAID_JIRA_PROJECT_KEY: Final[str] = settings.RAID_JIRA_PROJECT_KEY
TOOLBOX_URL: Final[str] = settings.RAID_TOOLBOX_URL
# XXX Do not hardcode this, it should be a setting or fetched from Jira
RAID_JIRA_WORKFLOW_NAME: Final[str] = "Incident workflow - v2023.03.13"
TARGET_STATUS_NAME: Final[str] = "Closed"
Expand Down Expand Up @@ -75,7 +76,7 @@ def create_issue( # noqa: PLR0912, PLR0913, C901, PLR0917
extra_args["customfield_10895"] = str(zendesk_ticket_id)
if seller_contract_id:
description_addendum.append(
f"Seller link to BO: https://bo.monechelle.com/provider/catalog/listproducts?provider_id={seller_contract_id}"
f"Seller link to TOOLBOX: {TOOLBOX_URL}?seller_id={seller_contract_id}"
)
extra_args["customfield_10908"] = str(seller_contract_id)
if is_seller_in_golden_list:
Expand Down
7 changes: 3 additions & 4 deletions src/firefighter/raid/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import textwrap
from typing import TYPE_CHECKING

from django.conf import settings
from slack_sdk.models.blocks.basic_components import MarkdownTextObject
from slack_sdk.models.blocks.blocks import (
Block,
Expand All @@ -13,12 +14,10 @@
from firefighter.slack.messages.base import SlackMessageSurface
from firefighter.slack.slack_templating import user_slack_handle_or_name

if TYPE_CHECKING:
from django.conf import settings
RAID_JIRA_API_URL: str = settings.RAID_JIRA_API_URL

if TYPE_CHECKING:
from firefighter.incidents.models.user import User

RAID_JIRA_API_URL: str = settings.RAID_JIRA_API_URL
from firefighter.raid.models import JiraTicket


Expand Down
Loading

0 comments on commit 4c4b6d4

Please sign in to comment.