mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
nixosTests.forgejo{,-lts}: simplify workflow subtest
This is substantially less hacky and less fragile than the previous approach that used htmlq to parse the raw html returned by the frontend and then compared the extracted status against a hardcoded list of known translated statuses. Back when this subtest was added, there simply was no API endpoint to gather this information yet. I had this in my out of tree variant of Forgejo for a while now. Requires Forgejo v8.0.0+
This commit is contained in:
parent
439e0a2445
commit
1c8cb24d42
1 changed files with 10 additions and 16 deletions
|
@ -60,7 +60,6 @@ let
|
||||||
pkgs.gnupg
|
pkgs.gnupg
|
||||||
pkgs.jq
|
pkgs.jq
|
||||||
pkgs.file
|
pkgs.file
|
||||||
pkgs.htmlq
|
|
||||||
];
|
];
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
|
|
||||||
|
@ -253,27 +252,22 @@ let
|
||||||
client.succeed("git -C /tmp/repo push origin main")
|
client.succeed("git -C /tmp/repo push origin main")
|
||||||
|
|
||||||
def poll_workflow_action_status(_) -> bool:
|
def poll_workflow_action_status(_) -> bool:
|
||||||
output = server.succeed(
|
try:
|
||||||
"curl --fail http://localhost:3000/test/repo/actions | "
|
response = server.succeed("curl --fail http://localhost:3000/api/v1/repos/test/repo/actions/tasks")
|
||||||
+ 'htmlq ".flex-item-leading span" --attribute "data-tooltip-content"'
|
status = json.loads(response).get("workflow_runs")[0].get("status")
|
||||||
).strip()
|
|
||||||
|
|
||||||
# values taken from https://codeberg.org/forgejo/forgejo/src/commit/af47c583b4fb3190fa4c4c414500f9941cc02389/options/locale/locale_en-US.ini#L3649-L3661
|
except IndexError:
|
||||||
if output in [ "Failure", "Canceled", "Skipped", "Blocked" ]:
|
status = "???"
|
||||||
raise Exception(f"Workflow status is '{output}', which we consider failed.")
|
|
||||||
server.log(f"Command returned '{output}', which we consider failed.")
|
|
||||||
|
|
||||||
elif output in [ "Unknown", "Waiting", "Running", "" ]:
|
server.log(f"Workflow status: {status}")
|
||||||
server.log(f"Workflow status is '{output}'. Waiting some more...")
|
|
||||||
return False
|
|
||||||
|
|
||||||
elif output in [ "Success" ]:
|
if status == "failure":
|
||||||
return True
|
raise Exception("Workflow failed")
|
||||||
|
|
||||||
raise Exception(f"Workflow status is '{output}', which we don't know. Value mappings likely need updating.")
|
return status == "success"
|
||||||
|
|
||||||
with server.nested("Waiting for the workflow run to be successful"):
|
with server.nested("Waiting for the workflow run to be successful"):
|
||||||
retry(poll_workflow_action_status)
|
retry(poll_workflow_action_status, 60)
|
||||||
|
|
||||||
with subtest("Testing backup service"):
|
with subtest("Testing backup service"):
|
||||||
server.succeed("${serverSystem}/specialisation/dump/bin/switch-to-configuration test")
|
server.succeed("${serverSystem}/specialisation/dump/bin/switch-to-configuration test")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue