Skip to content

Commit

Permalink
Merge remote-tracking branch 'lando-api-repo/main' into zeid/bug-1944…
Browse files Browse the repository at this point in the history
…562-merge-lando-api
  • Loading branch information
cgsheeh committed Feb 27, 2025
2 parents 4220b9a + d6af034 commit 7536c51
Show file tree
Hide file tree
Showing 37 changed files with 4,859 additions and 1,957 deletions.
502 changes: 502 additions & 0 deletions landoapi/spec/treestatus.yml

Large diffs are not rendered by default.

133 changes: 133 additions & 0 deletions migrations/versions/1dfc5aa9d1b2_add_treestatus_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
"""add treestatus models
Revision ID: 1dfc5aa9d1b2
Revises: 56c6748ee7cf
Create Date: 2023-11-29 01:48:07.449510
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "1dfc5aa9d1b2"
down_revision = "56c6748ee7cf"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"status_change",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("changed_by", sa.Text(), nullable=False),
sa.Column("reason", sa.Text(), nullable=False),
sa.Column(
"status",
sa.Enum("OPEN", "CLOSED", "APPROVAL_REQUIRED", name="treestatus"),
nullable=False,
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"tree",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("tree", sa.String(length=64), nullable=False),
sa.Column(
"status",
sa.Enum("OPEN", "CLOSED", "APPROVAL_REQUIRED", name="treestatus"),
nullable=False,
),
sa.Column("reason", sa.Text(), nullable=False),
sa.Column("message_of_the_day", sa.Text(), nullable=False),
sa.Column(
"category",
sa.Enum(
"DEVELOPMENT",
"RELEASE_STABILIZATION",
"TRY",
"COMM_REPOS",
"OTHER",
name="treecategory",
),
nullable=False,
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f("ix_tree_tree"), "tree", ["tree"], unique=True)
op.create_table(
"log",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("tree", sa.String(length=64), nullable=False),
sa.Column("changed_by", sa.Text(), nullable=False),
sa.Column(
"status",
sa.Enum("OPEN", "CLOSED", "APPROVAL_REQUIRED", name="treestatus"),
nullable=False,
),
sa.Column("reason", sa.Text(), nullable=False),
sa.Column(
"tags",
postgresql.JSONB(astext_type=sa.Text()),
nullable=False,
server_default="[]",
),
sa.ForeignKeyConstraint(
["tree"],
["tree.tree"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f("ix_log_tree"), "log", ["tree"], unique=False)
op.create_table(
"status_change_tree",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("stack_id", sa.Integer(), nullable=True),
sa.Column("tree", sa.String(length=64), nullable=False),
sa.Column(
"last_state", postgresql.JSONB(astext_type=sa.Text()), nullable=False
),
sa.ForeignKeyConstraint(
["stack_id"],
["status_change.id"],
),
sa.ForeignKeyConstraint(
["tree"],
["tree.tree"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_status_change_tree_stack_id"),
"status_change_tree",
["stack_id"],
unique=False,
)
op.create_index(
op.f("ix_status_change_tree_tree"), "status_change_tree", ["tree"], unique=False
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("ix_status_change_tree_tree"), table_name="status_change_tree")
op.drop_index(
op.f("ix_status_change_tree_stack_id"), table_name="status_change_tree"
)
op.drop_table("status_change_tree")
op.drop_index(op.f("ix_log_tree"), table_name="log")
op.drop_table("log")
op.drop_index(op.f("ix_tree_tree"), table_name="tree")
op.drop_table("tree")
op.drop_table("status_change")
# ### end Alembic commands ###
50 changes: 25 additions & 25 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ celery==5.4.0 \
--hash=sha256:369631eb580cf8c51a82721ec538684994f8277637edde2dfc0dacd73ed97f64 \
--hash=sha256:504a19140e8d3029d5acad88330c541d4c3f64c789d85f94756762d8bca7e706
# via lando (pyproject.toml)
certifi==2024.12.14 \
--hash=sha256:1275f7a45be9464efc1173084eaa30f866fe2e47d389406136d332ed4967ec56 \
--hash=sha256:b650d30f370c2b724812bee08008be0c4163b163ddaec3f2546c1caf65f191db
certifi==2025.1.31 \
--hash=sha256:3d5da6925056f6f18f119200434a4780a94263f10d1c21d032a6f6b2baa20651 \
--hash=sha256:ca78db4565a652026a4db2bcdf68f2fb589ea80d0be70e03929ed730746b84fe
# via
# requests
# sentry-sdk
Expand Down Expand Up @@ -722,9 +722,9 @@ google-cloud-core==2.4.1 \
--hash=sha256:9b7749272a812bde58fff28868d0c5e2f585b82f37e09a1f6ed2d4d10f134073 \
--hash=sha256:a9e6a4422b9ac5c29f79a0ede9485473338e2ce78d91f2370c01e730eab22e61
# via google-cloud-storage
google-cloud-storage==2.19.0 \
--hash=sha256:aeb971b5c29cf8ab98445082cbfe7b161a1f48ed275822f59ed3f1524ea54fba \
--hash=sha256:cd05e9e7191ba6cb68934d8eb76054d9be4562aa89dbc4236feee4d7d51342b2
google-cloud-storage==3.0.0 \
--hash=sha256:2accb3e828e584888beff1165e5f3ac61aa9088965eb0165794a82d8c7f95297 \
--hash=sha256:f85fd059650d2dbb0ac158a9a6b304b66143b35ed2419afec2905ca522eb2c6a
# via django-storages
google-crc32c==1.6.0 \
--hash=sha256:05e2d8c9a2f853ff116db9706b4a27350587f341eda835f46db3c0a8c8ce2f24 \
Expand Down Expand Up @@ -1528,25 +1528,25 @@ ruamel-yaml-clib==0.2.12 \
--hash=sha256:fc4b630cd3fa2cf7fce38afa91d7cfe844a9f75d7f0f36393fa98815e911d987 \
--hash=sha256:fd5415dded15c3822597455bc02bcd66e81ef8b7a48cb71a33628fc9fdde39df
# via ruamel-yaml
ruff==0.9.3 \
--hash=sha256:006e5de2621304c8810bcd2ee101587712fa93b4f955ed0985907a36c427e0c2 \
--hash=sha256:040ceb7f20791dfa0e78b4230ee9dce23da3b64dd5848e40e3bf3ab76468dcf4 \
--hash=sha256:2dc153c25e715be41bb228bc651c1e9b1a88d5c6e5ed0194fa0dfea02b026439 \
--hash=sha256:33866c3cc2a575cbd546f2cd02bdd466fed65118e4365ee538a3deffd6fcb730 \
--hash=sha256:5a5a46e09355695fbdbb30ed9889d6cf1c61b77b700a9fafc21b41f097bfbba4 \
--hash=sha256:646909a1e25e0dc28fbc529eab8eb7bb583079628e8cbe738192853dbbe43af5 \
--hash=sha256:7f39b879064c7d9670197d91124a75d118d00b0990586549949aae80cdc16624 \
--hash=sha256:800d773f6d4d33b0a3c60e2c6ae8f4c202ea2de056365acfa519aa48acf28e0b \
--hash=sha256:8293f89985a090ebc3ed1064df31f3b4b56320cdfcec8b60d3295bddb955c22a \
--hash=sha256:90230a6b8055ad47d3325e9ee8f8a9ae7e273078a66401ac66df68943ced029b \
--hash=sha256:96a87ec31dc1044d8c2da2ebbed1c456d9b561e7d087734336518181b26b3aa5 \
--hash=sha256:9bb7554aca6f842645022fe2d301c264e6925baa708b392867b7a62645304df4 \
--hash=sha256:a187171e7c09efa4b4cc30ee5d0d55a8d6c5311b3e1b74ac5cb96cc89bafc43c \
--hash=sha256:ba6eea4459dbd6b1be4e6bfc766079fb9b8dd2e5a35aff6baee4d9b1514ea519 \
--hash=sha256:c4bb09d2bbb394e3730d0918c00276e79b2de70ec2a5231cd4ebb51a57df9ba1 \
--hash=sha256:c59ab92f8e92d6725b7ded9d4a31be3ef42688a115c6d3da9457a5bda140e2b4 \
--hash=sha256:cabc332b7075a914ecea912cd1f3d4370489c8018f2c945a30bcc934e3bc06a6 \
--hash=sha256:eabe5eb2c19a42f4808c03b82bd313fc84d4e395133fb3fc1b1516170a31213c
ruff==0.9.4 \
--hash=sha256:05bebf4cdbe3ef75430d26c375773978950bbf4ee3c95ccb5448940dc092408e \
--hash=sha256:1d4c8772670aecf037d1bf7a07c39106574d143b26cfe5ed1787d2f31e800214 \
--hash=sha256:37c892540108314a6f01f105040b5106aeb829fa5fb0561d2dcaf71485021137 \
--hash=sha256:433dedf6ddfdec7f1ac7575ec1eb9844fa60c4c8c2f8887a070672b8d353d34c \
--hash=sha256:54499fb08408e32b57360f6f9de7157a5fec24ad79cb3f42ef2c3f3f728dfe2b \
--hash=sha256:56acd6c694da3695a7461cc55775f3a409c3815ac467279dfa126061d84b314b \
--hash=sha256:585792f1e81509e38ac5123492f8875fbc36f3ede8185af0a26df348e5154f41 \
--hash=sha256:64e73d25b954f71ff100bb70f39f1ee09e880728efb4250c632ceed4e4cdf706 \
--hash=sha256:6907ee3529244bb0ed066683e075f09285b38dd5b4039370df6ff06041ca19e7 \
--hash=sha256:6ce6743ed64d9afab4fafeaea70d3631b4d4b28b592db21a5c2d1f0ef52934bf \
--hash=sha256:87c90c32357c74f11deb7fbb065126d91771b207bf9bfaaee01277ca59b574ec \
--hash=sha256:a6c634fc6f5a0ceae1ab3e13c58183978185d131a29c425e4eaa9f40afe1e6d6 \
--hash=sha256:bfc5f1d7afeda8d5d37660eeca6d389b142d7f2b5a1ab659d9214ebd0e025231 \
--hash=sha256:d612dbd0f3a919a8cc1d12037168bfa536862066808960e0cc901404b77968f0 \
--hash=sha256:db1192ddda2200671f9ef61d9597fcef89d934f5d1705e571a93a67fb13a4402 \
--hash=sha256:de9edf2ce4b9ddf43fd93e20ef635a900e25f622f87ed6e3047a664d0e8f810e \
--hash=sha256:e0c93e7d47ed951b9394cf352d6695b31498e68fd5782d6cbc282425655f687a \
--hash=sha256:faa935fc00ae854d8b638c16a5f1ce881bc3f67446957dd6f2af440a5fc8526b
# via lando (pyproject.toml)
sentry-sdk==2.20.0 \
--hash=sha256:afa82713a92facf847df3c6f63cec71eb488d826a50965def3d7722aa6f0fdab \
Expand Down
40 changes: 27 additions & 13 deletions src/lando/api/legacy/api/stacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@
serialize_status,
)
from lando.api.legacy.stacks import (
RevisionStack,
build_stack_graph,
calculate_landable_subgraphs,
get_landable_repos_for_revision_data,
get_diffs_for_revision,
request_extended_revision_data,
)
from lando.api.legacy.transplants import get_blocker_checks
from lando.api.legacy.users import user_search
from lando.main.auth import require_phabricator_api_key
from lando.main.models import Repo
from lando.main.models.revision import Revision
from lando.utils.phabricator import PhabricatorClient
from lando.api.legacy.transplants import build_stack_assessment_state, run_landing_checks
from lando.api.legacy.users import user_search
from lando.api.legacy.validation import revision_id_to_int

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -71,24 +73,34 @@ def get(phab: PhabricatorClient, request: HttpRequest, revision_id: int):
if not release_managers:
raise Exception("Could not find `#release-managers` project on Phabricator.")

relman_group_phid = str(phab.expect(release_managers, "phid"))
data_policy_review_phid = get_data_policy_review_phid(phab)
if not data_policy_review_phid:
raise Exception(
"Could not find `#needs-data-classification` project on Phabricator."
)

other_checks = get_blocker_checks(
relman_group_phid=relman_group_phid,
repositories=supported_repos,
stack_data=stack_data,
)
relman_group_phid = str(phab.expect(release_managers, "phid"))

landable, blocked = calculate_landable_subgraphs(
stack_data, edges, landable_repos, other_checks=other_checks
stack = RevisionStack(set(stack_data.revisions.keys()), edges)
stack_state = build_stack_assessment_state(
phab,
supported_repos,
stack_data,
stack,
relman_group_phid,
data_policy_review_phid,
)
# Run landing checks and update the stack state.
run_landing_checks(stack_state)
landable = stack_state.landable_stack.landable_paths()
uplift_repos = [
name for name, repo in supported_repos.items() if repo.approval_required
]

involved_phids = set()
for revision in stack_data.revisions.values():
involved_phids.update(gather_involved_phids(revision))
revision_diffs = get_diffs_for_revision(revision, stack_data.diffs)
involved_phids.update(gather_involved_phids(revision, revision_diffs))

involved_phids = list(involved_phids)

Expand Down Expand Up @@ -154,12 +166,14 @@ def get(phab: PhabricatorClient, request: HttpRequest, revision_id: int):
)
author_response = serialize_author(phab.expect(fields, "authorPHID"), users)

blocked_reasons = stack_state.stack.nodes[revision_phid].get("blocked")

revisions_response.append(
{
"id": human_revision_id,
"phid": revision_phid,
"status": serialize_status(phab_revision),
"blocked_reason": blocked.get(revision_phid, ""),
"blocked_reasons": blocked_reasons,
"bug_id": bug_id,
"title": commit_description.title,
"url": revision_url,
Expand Down
Loading

0 comments on commit 7536c51

Please sign in to comment.