-
Notifications
You must be signed in to change notification settings - Fork 3
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
Rerun artefact test executions #173
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,12 @@ | |
are_all_test_executions_approved, | ||
is_there_a_rejected_test_execution, | ||
) | ||
from .models import ArtefactBuildDTO, ArtefactDTO, ArtefactPatch | ||
from .models import ( | ||
ArtefactBuildDTO, | ||
ArtefactDTO, | ||
ArtefactPatch, | ||
RerunArtefactTestExecutionsRequest, | ||
) | ||
|
||
router = APIRouter(tags=["artefacts"]) | ||
|
||
|
@@ -145,12 +150,22 @@ def get_artefact_builds(artefact_id: int, db: Session = Depends(get_db)): | |
|
||
@router.post("/{artefact_id}/reruns") | ||
def rerun_artefact_test_executions( | ||
request: RerunArtefactTestExecutionsRequest | None = None, | ||
artefact: Artefact = Depends(_get_artefact_from_db), | ||
db: Session = Depends(get_db), | ||
): | ||
latest_builds = db.scalars( | ||
queries.latest_artefact_builds.where(ArtefactBuild.artefact_id == artefact.id) | ||
) | ||
for ab in latest_builds: | ||
for te in ab.test_executions: | ||
get_or_create(db, TestExecutionRerunRequest, {"test_execution_id": te.id}) | ||
test_executions = (te for ab in latest_builds for te in ab.test_executions) | ||
|
||
if request: | ||
if status := request.test_execution_status: | ||
test_executions = (te for te in test_executions if te.status == status) | ||
if (decision := request.test_execution_review_decision) is not None: | ||
test_executions = ( | ||
te for te in test_executions if te.review_decision == decision | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't define the review decision as a set maybe here we should do set comparison instead of list as the order doesn't really matter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah very good point |
||
) | ||
|
||
for te in test_executions: | ||
get_or_create(db, TestExecutionRerunRequest, {"test_execution_id": te.id}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,3 +93,8 @@ class ArtefactBuildDTO(BaseModel): | |
|
||
class ArtefactPatch(BaseModel): | ||
status: ArtefactStatus | ||
|
||
|
||
class RerunArtefactTestExecutionsRequest(BaseModel): | ||
test_execution_status: TestExecutionStatus | None = None | ||
test_execution_review_decision: list[TestExecutionReviewDecision] | None = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the tag here 😄