@capagents/forgeqe 2.4.9 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs-site/architecture-map/index.html +1 -0
- package/dist/docs-site/docs/architecture/index.html +5 -5
- package/dist/docs-site/docs/containers/index.html +3 -3
- package/dist/docs-site/docs/cost-architecture/index.html +3 -3
- package/dist/docs-site/docs/desktop/index.html +3 -3
- package/dist/docs-site/docs/desktop-ci/index.html +3 -3
- package/dist/docs-site/docs/feature-test-prompts/index.html +3 -3
- package/dist/docs-site/docs/guardrails/index.html +3 -3
- package/dist/docs-site/docs/index.html +41 -77
- package/dist/docs-site/docs/mobile/index.html +32 -10
- package/dist/docs-site/docs/model-routing/index.html +3 -3
- package/dist/docs-site/docs/product-knowledge/index.html +3 -3
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/docs-site/docs/web-app/index.html +14 -6
- package/dist/docs-site/img/icons/mail.svg +1 -0
- package/dist/forgeqe.js +997 -987
- package/dist/web/assets/{Agent-DJMzvP5e.js → Agent-BMqCDZeZ.js} +1 -1
- package/dist/web/assets/{ApiTests-CatQogdX.js → ApiTests-CkxIx6sI.js} +2 -2
- package/dist/web/assets/{Chat-BnMf86ti.js → Chat-BT6yGqKW.js} +3 -3
- package/dist/web/assets/{Data-Dv1J1F3q.js → Data-BPtl_mUy.js} +4 -4
- package/dist/web/assets/{Features-BoUfO669.js → Features-DwHyOoJu.js} +1 -1
- package/dist/web/assets/Jobs-DW2uXMkv.js +3 -0
- package/dist/web/assets/Quality-BeuhtzZi.js +1 -0
- package/dist/web/assets/Record-EHgUTspl.js +1 -0
- package/dist/web/assets/{Regression-icTMw-63.js → Regression-BDq3BUP_.js} +2 -2
- package/dist/web/assets/Reports-Bapldq1A.js +2 -0
- package/dist/web/assets/{Response-DhcE4o_e.js → Response-Dh_kxnCt.js} +3 -3
- package/dist/web/assets/Runs-BOi2fP0o.js +2 -0
- package/dist/web/assets/{circle-dashed-DJoDKq93.js → circle-dashed-C84s5T0C.js} +1 -1
- package/dist/web/assets/frame-z3iL_6aL.js +3 -0
- package/dist/web/assets/index-BVw2ygO2.js +26 -0
- package/dist/web/assets/index-CBa29-yG.css +2 -0
- package/dist/web/assets/markdown-BtqKvAEi.js +10 -0
- package/dist/web/assets/{sticky-note-BHLEsD2N.js → sticky-note-C_NJNONZ.js} +1 -1
- package/dist/web/assets/{trending-up-DWgCJxJf.js → trending-up-DK1wDqic.js} +1 -1
- package/dist/web/index.html +3 -3
- package/docs/MOBILE.md +29 -7
- package/docs/WEB_APP.md +11 -1
- package/docs/user-guide.html +29 -7
- package/forgeqe.example.yaml +7 -0
- package/package.json +1 -1
- package/py/forgeqe_mobile/cli.py +9 -2
- package/py/forgeqe_mobile/hyperexecute.py +133 -19
- package/py/forgeqe_mobile/maestro.py +45 -3
- package/py/forgeqe_mobile/service.py +51 -14
- package/dist/web/assets/Jobs-DHLGBQQg.js +0 -3
- package/dist/web/assets/Quality-D0xYMvar.js +0 -1
- package/dist/web/assets/Record-Dnt4y9hn.js +0 -1
- package/dist/web/assets/Reports-C_IwjymA.js +0 -2
- package/dist/web/assets/Runs-5qNwwohN.js +0 -2
- package/dist/web/assets/external-link-Cu8-HMUj.js +0 -1
- package/dist/web/assets/frame-3JV5tjBP.js +0 -3
- package/dist/web/assets/index-C65qlV-q.css +0 -2
- package/dist/web/assets/index-XRjCGJfG.js +0 -26
- package/dist/web/assets/markdown-Bca_tHZ5.js +0 -10
package/docs/user-guide.html
CHANGED
|
@@ -2688,8 +2688,10 @@ no CI job tests it yet (it needs a macOS runner with a simulator).</p>
|
|
|
2688
2688
|
</section>
|
|
2689
2689
|
<section class="doc" id="doc-docs-mobile-use">
|
|
2690
2690
|
<h4>Use</h4>
|
|
2691
|
-
<div class="prose"><pre><code class="language-bash">forgeqe mobile doctor # does the Appium server answer, is maestro installed?
|
|
2691
|
+
<div class="prose"><pre><code class="language-bash">forgeqe mobile doctor # does the Appium server answer, is maestro installed? (or, with
|
|
2692
|
+
# mobile.maestro.testmu: is the hyperexecute CLI there, are the user and key set?)
|
|
2692
2693
|
forgeqe mobile apps # the mobile apps of the active environment
|
|
2694
|
+
forgeqe mobile devices --like "Pixel 8-14" # the devices TestMu or BrowserStack has, most like one first
|
|
2693
2695
|
forgeqe mobile explore "Sign in as the courier and accept the first delivery" --app courier
|
|
2694
2696
|
forgeqe mobile replay .forgeqe/reports/mobile-explore-…/workflow.yaml
|
|
2695
2697
|
forgeqe mobile replay workflow.yaml --driver maestro
|
|
@@ -2834,11 +2836,11 @@ the build (it must be inside the working folder), and saves the <code>lt://</cod
|
|
|
2834
2836
|
username_env: LT_USERNAME
|
|
2835
2837
|
access_key_env: LT_ACCESS_KEY
|
|
2836
2838
|
capabilities:
|
|
2837
|
-
"LT:Options": { w3c: true, isRealMobile: true, deviceName: "Pixel
|
|
2839
|
+
"LT:Options": { w3c: true, isRealMobile: true, deviceName: "Pixel 8", platformVersion: "14", build: nightly } # app: added from the app's own
|
|
2838
2840
|
maestro:
|
|
2839
2841
|
testmu: # Maestro on TestMu, through HyperExecute
|
|
2840
2842
|
cli: /opt/hyperexecute # TestMu's hyperexecute CLI
|
|
2841
|
-
devices: ["Pixel
|
|
2843
|
+
devices: ["Pixel 8-14"] # name-version, or a pattern such as ".*-.*"
|
|
2842
2844
|
real_device: true # false: TestMu's emulators
|
|
2843
2845
|
# username_env: LT_USERNAME # the defaults
|
|
2844
2846
|
# access_key_env: LT_ACCESS_KEY
|
|
@@ -2850,13 +2852,33 @@ The project holds the flows in their folder layout (so <code>runFlow</code> stil
|
|
|
2850
2852
|
the device's <code>appId</code>; a build file is uploaded with the project), a fixed setup script (Android platform tools 35.0.2
|
|
2851
2853
|
and Maestro 2.6.1 from its release, both checked against their SHA-256) and a fixed run script, and
|
|
2852
2854
|
<code>hyperexecute.yaml</code>. Team flows are checked against the allowlist first, as always. Flow file names may only use
|
|
2853
|
-
letters, digits and <code>_ . - /</code
|
|
2854
|
-
|
|
2855
|
-
result in the
|
|
2855
|
+
letters, digits and <code>_ . - /</code>, because HyperExecute's shell reads them, and no folder or file may be hidden except
|
|
2856
|
+
a top-level <code>.maestro/</code> (hidden files of the working folder never leave the machine). After the job, ForgeQE
|
|
2857
|
+
downloads its artifacts (Maestro's command results and JUnit reports), so each step gets its own result in the
|
|
2858
|
+
report. A job on several devices (more than one entry in <code>devices</code>, or a pattern) brings back one run per device:
|
|
2859
|
+
the steps show the first device that failed, or the first device when all passed, and the job's page has each one.
|
|
2860
|
+
The job's link is printed from either <code>hyperexecute.lambdatest.com</code> or <code>hyperexecute.testmu.ai</code>.</li>
|
|
2861
|
+
<li><strong>Devices are checked first.</strong> On TestMu (Appium or Maestro) and BrowserStack (Appium), <code>replay</code>, <code>maestro</code> and
|
|
2862
|
+
<code>explore</code> read the cloud's device list before they start (TestMu's list for the region, BrowserStack's
|
|
2863
|
+
<code>devices.json</code>) and check each configured device, exact or a pattern. A device the cloud does not have would wait
|
|
2864
|
+
in its queue and time out (<code>QUEUE_TIMEOUT_DEVICE_UNAVAILABLE</code>), so ForgeQE offers the devices most like it instead:
|
|
2865
|
+
the same model on other OS versions, then the same family. In a terminal you pick one for this run; without one it
|
|
2866
|
+
stops and names them. <code>--device "Pixel 8-13"</code> runs on another device this time (several, comma-separated, for
|
|
2867
|
+
Maestro), <code>--no-device-check</code> skips the check, and <code>forgeqe mobile devices</code> lists what the cloud has. The list
|
|
2868
|
+
says what a cloud offers in the region, not whether a device is free this minute. TestMu's emulators
|
|
2869
|
+
(<code>real_device: false</code>, <code>isRealMobile: false</code>) are not in it and are not checked.</li>
|
|
2870
|
+
<li><strong>Videos.</strong> TestMu records each Maestro flow as an App Automation session (its dashboard, not the HyperExecute job
|
|
2871
|
+
page, shows the video). Each run is its own build there, and after the job ForgeQE saves each flow's recording as
|
|
2872
|
+
<code>videos/<flow>.mp4</code> in the run folder, plays it in the report's Artifacts tab, and prints it with the session's
|
|
2873
|
+
TestMu page. A video TestMu has not finished is waited for briefly; a run never fails for want of one.</li>
|
|
2856
2874
|
<li><strong>Secrets on Maestro on TestMu:</strong> a workflow that types a secret is refused there for now (HyperExecute would need
|
|
2857
|
-
the value in its own vault). Replay it on TestMu with <code>--driver appium</code
|
|
2875
|
+
the value in its own vault). Replay it on TestMu with <code>--driver appium</code>. For the same reason, a team flow that reads
|
|
2876
|
+
a <code>${NAME}</code> variable its own <code>env:</code> blocks do not set is refused on TestMu (locally it could come from the
|
|
2877
|
+
environment); run it with a local <code>maestro</code>.</li>
|
|
2858
2878
|
<li>The access key is passed to the CLI as an argument. It is removed from the CLI's output and from every file in the
|
|
2859
2879
|
run folder. Neither the user name nor the key is passed to the flows' environment.</li>
|
|
2880
|
+
<li><code>maestro</code> and the <code>hyperexecute</code> CLI are started without ForgeQE's own secrets (the model's key, service tokens) in
|
|
2881
|
+
their environment; only the mobile engine itself holds them.</li>
|
|
2860
2882
|
<li>The <code>testmu</code> job of <code>.github/workflows/ci.yml</code> (Run workflow, job <code>testmu</code>) runs all three on TestMu (Appium, Maestro with a workflow, a team flow)
|
|
2861
2883
|
with TestMu's Wikipedia sample app, once the repository has the secrets <code>LT_USERNAME</code> and <code>LT_ACCESS_KEY</code>.</li>
|
|
2862
2884
|
</ul>
|
package/forgeqe.example.yaml
CHANGED
|
@@ -41,6 +41,13 @@ environments:
|
|
|
41
41
|
# maestro:
|
|
42
42
|
# command: [maestro]
|
|
43
43
|
# # device: emulator-5554
|
|
44
|
+
# # testmu: # run Maestro on TestMu AI's devices (HyperExecute) instead; docs/MOBILE.md
|
|
45
|
+
# # cli: ./hyperexecute # TestMu's hyperexecute program
|
|
46
|
+
# # devices: ["Pixel 8-14"] # name-version, or a pattern such as ".*-.*"
|
|
47
|
+
# # real_device: true # false: TestMu's emulators
|
|
48
|
+
# # region: us
|
|
49
|
+
# # username_env: LT_USERNAME # the user and key, as environment variable names
|
|
50
|
+
# # access_key_env: LT_ACCESS_KEY
|
|
44
51
|
# secrets: [COURIER_PASSWORD] # the only environment variables {{secret:…}} may read
|
|
45
52
|
# heal: true
|
|
46
53
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capagents/forgeqe",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "ForgeQE: a browser agent CLI that runs goals and test cases in local Chrome or Chromium, or BrowserStack and TestMu AI/LambdaTest when configured, and turns passing runs into tests in your repo",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
package/py/forgeqe_mobile/cli.py
CHANGED
|
@@ -15,7 +15,7 @@ from typing import List, Optional
|
|
|
15
15
|
from forgeqe_desktop.workflow import WorkflowError, load
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def doctor(appium_url: str, maestro: str) -> dict:
|
|
18
|
+
def doctor(appium_url: str, maestro: str, hyperexecute: Optional[str] = None) -> dict:
|
|
19
19
|
out: dict = {"appium_url": appium_url}
|
|
20
20
|
try:
|
|
21
21
|
req = urllib.request.Request(appium_url.rstrip("/") + "/status", method="GET")
|
|
@@ -30,6 +30,12 @@ def doctor(appium_url: str, maestro: str) -> dict:
|
|
|
30
30
|
out["maestro"] = bool(found)
|
|
31
31
|
if found:
|
|
32
32
|
out["maestro_path"] = found
|
|
33
|
+
if hyperexecute:
|
|
34
|
+
# Maestro on TestMu: TestMu's hyperexecute CLI, which runs the flows instead of a local maestro.
|
|
35
|
+
cli = shutil.which(hyperexecute)
|
|
36
|
+
out["hyperexecute"] = bool(cli)
|
|
37
|
+
if cli:
|
|
38
|
+
out["hyperexecute_path"] = cli
|
|
33
39
|
return out
|
|
34
40
|
|
|
35
41
|
|
|
@@ -47,6 +53,7 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
47
53
|
d = sub.add_parser("doctor", help="whether the Appium server and maestro answer, as JSON")
|
|
48
54
|
d.add_argument("--appium-url", default="http://127.0.0.1:4723")
|
|
49
55
|
d.add_argument("--maestro", default="maestro")
|
|
56
|
+
d.add_argument("--hyperexecute", help="mobile.maestro.testmu.cli, when Maestro runs on TestMu")
|
|
50
57
|
args = parser.parse_args(argv)
|
|
51
58
|
if args.command == "serve":
|
|
52
59
|
from .service import serve
|
|
@@ -64,7 +71,7 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
64
71
|
|
|
65
72
|
print(f"ok: {len(check_flow(args.flow, args.root))} flow files checked")
|
|
66
73
|
return 0
|
|
67
|
-
print(json.dumps(doctor(args.appium_url, args.maestro)))
|
|
74
|
+
print(json.dumps(doctor(args.appium_url, args.maestro, args.hyperexecute)))
|
|
68
75
|
return 0
|
|
69
76
|
except (WorkflowError, ValueError, OSError) as e:
|
|
70
77
|
print(f"error: {e}", file=sys.stderr)
|
|
@@ -14,10 +14,16 @@ argument list. The user and key come from the environment variables the config n
|
|
|
14
14
|
"""
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
+
import base64
|
|
18
|
+
import json
|
|
17
19
|
import os
|
|
18
20
|
import re
|
|
21
|
+
import secrets
|
|
19
22
|
import shutil
|
|
20
23
|
import subprocess
|
|
24
|
+
import time
|
|
25
|
+
import urllib.parse
|
|
26
|
+
import urllib.request
|
|
21
27
|
import zipfile
|
|
22
28
|
from pathlib import Path
|
|
23
29
|
from typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Tuple
|
|
@@ -26,21 +32,23 @@ import yaml
|
|
|
26
32
|
|
|
27
33
|
from forgeqe_desktop.workflow import WorkflowError
|
|
28
34
|
|
|
29
|
-
from .maestro import _junit,
|
|
35
|
+
from .maestro import _junit, command_runs
|
|
30
36
|
|
|
31
37
|
MAESTRO_ON_TESTMU = "2.6.1"
|
|
32
38
|
# The exact downloads TestMu's machine installs, checked before they are unpacked.
|
|
33
39
|
MAESTRO_SHA256 = "3440825f514f537c6a96bcf5de995780c2a4a7f83a43208fdc95d4f1fecfad3b"
|
|
34
40
|
PLATFORM_TOOLS = "35.0.2"
|
|
35
41
|
PLATFORM_TOOLS_SHA256 = "acfdcccb123a8718c46c46c059b2f621140194e5ec1ac9d81715be3d6ab6cd0a"
|
|
36
|
-
DEVICE = re.compile(r"^[A-Za-z0-9 ._*()+-]{1,60}
|
|
37
|
-
REGION = re.compile(r"^[a-z]{2,4}
|
|
38
|
-
LT_APP = re.compile(r"^lt://[A-Za-z0-9]{1,100}
|
|
42
|
+
DEVICE = re.compile(r"^[A-Za-z0-9 ._*()+-]{1,60}\Z")
|
|
43
|
+
REGION = re.compile(r"^[a-z]{2,4}\Z")
|
|
44
|
+
LT_APP = re.compile(r"^lt://[A-Za-z0-9]{1,100}\Z")
|
|
39
45
|
# Flow paths end up on HyperExecute's command line (./run.sh $test), which its shell reads: letters, digits, _ . - /.
|
|
40
|
-
#
|
|
41
|
-
|
|
46
|
+
# No part may be hidden (a name starting with a dot) except Maestro's usual .maestro/ folder at the top: hidden files of
|
|
47
|
+
# the working folder are never sent out of the machine.
|
|
48
|
+
SAFE_PATH = re.compile(r"^(?=.{1,210}\Z)(?!.*\.\.)(?:\.maestro/)?(?:[A-Za-z0-9_][A-Za-z0-9_.-]*/)*[A-Za-z0-9_][A-Za-z0-9_.-]*\.ya?ml\Z")
|
|
42
49
|
ARTIFACTS = "maestro-results"
|
|
43
|
-
|
|
50
|
+
# The job's page: on LambdaTest's domain, or TestMu AI's since the rename.
|
|
51
|
+
_JOB_LINK = re.compile(r"https://hyperexecute\.(?:lambdatest\.com|testmu\.ai)/[^\s'\"]+")
|
|
44
52
|
|
|
45
53
|
# TestMu's own setup for Maestro on HyperExecute (its sample, with Maestro taken from its release instead of an
|
|
46
54
|
# installer piped to a shell, and both downloads pinned to a version and checked against their SHA-256).
|
|
@@ -67,10 +75,12 @@ unzip -q -o maestro.zip
|
|
|
67
75
|
"""
|
|
68
76
|
|
|
69
77
|
RUN_SCRIPT = """#!/bin/bash
|
|
70
|
-
# One flow (its path from discover.txt), with Maestro's JUnit report for HyperExecute.
|
|
71
|
-
|
|
78
|
+
# One flow (its path from discover.txt), with Maestro's JUnit report for HyperExecute. What it prints is kept in
|
|
79
|
+
# MaestroLogs (uploaded with the results), so a run that stops before any command still says why.
|
|
80
|
+
set -o pipefail
|
|
72
81
|
name="$(basename "$1" .yaml)"
|
|
73
|
-
|
|
82
|
+
mkdir -p ./MaestroLogs
|
|
83
|
+
{ adb devices; "$HOME/maestro-cli/maestro/bin/maestro" test "$1" --debug-output ./MaestroLogs --format junit --output "./reports/$name.xml"; } 2>&1 | tee "./MaestroLogs/run-$name.log"
|
|
74
84
|
"""
|
|
75
85
|
|
|
76
86
|
|
|
@@ -114,6 +124,17 @@ def _app(app: Optional[str], project: Path) -> str:
|
|
|
114
124
|
return dest.name
|
|
115
125
|
|
|
116
126
|
|
|
127
|
+
def build_name(build: str) -> str:
|
|
128
|
+
"""The build name TestMu shows (and ForgeQE looks the run's videos up by): letters, digits, space _ . - only."""
|
|
129
|
+
return re.sub(r"[^A-Za-z0-9 _.-]", "_", build)[:100] or "forgeqe"
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def discover_command(windows: bool = os.name == "nt") -> str:
|
|
133
|
+
"""The test list for HyperExecute: its CLI runs this here, on this machine, and in static mode the tests are the
|
|
134
|
+
lines it prints (``value`` alone is not read). ``type`` on Windows (cmd and PowerShell), ``cat`` elsewhere."""
|
|
135
|
+
return "type discover.txt" if windows else "cat discover.txt"
|
|
136
|
+
|
|
137
|
+
|
|
117
138
|
def write_project(project: Path, files: Sequence[Tuple[Path, str]], tests: Sequence[str], app: Optional[str], platform: str, settings: Mapping[str, Any], build: str) -> Path:
|
|
118
139
|
"""
|
|
119
140
|
The HyperExecute project: ``files`` (source, path under flows/) keep their layout, so a flow's runFlow paths still
|
|
@@ -126,7 +147,7 @@ def write_project(project: Path, files: Sequence[Tuple[Path, str]], tests: Seque
|
|
|
126
147
|
(project / "flows").mkdir(parents=True)
|
|
127
148
|
for rel in [*(r for _, r in files), *tests]:
|
|
128
149
|
if not SAFE_PATH.match(rel):
|
|
129
|
-
raise WorkflowError(f"flow path {rel!r}: for TestMu, flow files are named with letters, digits, _ . - and / only")
|
|
150
|
+
raise WorkflowError(f"flow path {rel!r}: for TestMu, flow files are named with letters, digits, _ . - and / only, in no hidden folder but .maestro/")
|
|
130
151
|
for src, rel in files:
|
|
131
152
|
dest = (project / "flows" / rel).resolve()
|
|
132
153
|
if (project / "flows").resolve() not in dest.parents:
|
|
@@ -146,7 +167,7 @@ def write_project(project: Path, files: Sequence[Tuple[Path, str]], tests: Seque
|
|
|
146
167
|
"deviceLog": True,
|
|
147
168
|
# An upload's lt:// id is the device's appId; a build file in the project is uploaded by the CLI as appPath.
|
|
148
169
|
**({"appId": app_ref} if LT_APP.match(app_ref) else {"appPath": app_ref}),
|
|
149
|
-
"buildName":
|
|
170
|
+
"buildName": build_name(build),
|
|
150
171
|
"queueTimeout": 600,
|
|
151
172
|
"disableReleaseDevice": True,
|
|
152
173
|
"isRealMobile": bool(settings["real_device"]),
|
|
@@ -166,7 +187,7 @@ def write_project(project: Path, files: Sequence[Tuple[Path, str]], tests: Seque
|
|
|
166
187
|
"framework": {"name": "raw", "args": args},
|
|
167
188
|
"env": {"MAESTRO": True, "MAESTRO_LOGS_DIR": "MaestroLogs", "MAESTRO_CLI_NO_ANALYTICS": "1"},
|
|
168
189
|
"pre": ["chmod +x ./setup.sh ./run.sh", "./setup.sh"],
|
|
169
|
-
"testDiscovery": {"command":
|
|
190
|
+
"testDiscovery": {"command": discover_command(), "value": names, "mode": "static", "type": "raw"},
|
|
170
191
|
"testRunnerCommand": "./run.sh $test",
|
|
171
192
|
"frameworkStatusOnly": True,
|
|
172
193
|
"report": True,
|
|
@@ -202,6 +223,7 @@ def run_hyperexecute(
|
|
|
202
223
|
env: Mapping[str, str],
|
|
203
224
|
timeout: float = 5400,
|
|
204
225
|
run: Callable[..., Any] = subprocess.run,
|
|
226
|
+
fetch_videos: Optional[Callable[..., List[Dict[str, Any]]]] = None,
|
|
205
227
|
) -> Dict[str, Any]:
|
|
206
228
|
"""Run ``tests`` on TestMu through HyperExecute; ``{ok, flows, commands, job, log}`` like run_maestro. HyperExecute
|
|
207
229
|
reports the job as a whole, so each flow carries the job's result; its page has each flow's."""
|
|
@@ -210,6 +232,8 @@ def run_hyperexecute(
|
|
|
210
232
|
if not user or not key:
|
|
211
233
|
raise WorkflowError(f"Maestro on TestMu needs {settings['username_env']} and {settings['access_key_env']} set (your TestMu user name and access key)")
|
|
212
234
|
project = out_dir / "hyperexecute"
|
|
235
|
+
# Each run its own build on TestMu, so its sessions (one per flow, with the video) are found after the job.
|
|
236
|
+
build = build_name(f"{build[:70]} {time.strftime('%Y-%m-%d_%H-%M-%S')}-{secrets.token_hex(2)}")
|
|
213
237
|
cfg = write_project(project, files, tests, app, platform, settings, build)
|
|
214
238
|
args = [settings["cli"], "--user", user, "--key", key, "--config", cfg.name, "--download-artifacts", "--download-artifacts-path", "artifacts", "--force-clean-artifacts"]
|
|
215
239
|
child_env = {k: v for k, v in env.items() if k not in (settings["username_env"], settings["access_key_env"])}
|
|
@@ -226,20 +250,107 @@ def run_hyperexecute(
|
|
|
226
250
|
(out_dir / "hyperexecute.log").write_text(log, encoding="utf-8")
|
|
227
251
|
job = (_JOB_LINK.findall(log) or [""])[-1]
|
|
228
252
|
ok = proc.returncode == 0
|
|
229
|
-
cases, commands = job_results(project / "artifacts")
|
|
253
|
+
cases, commands, runs = job_results(project / "artifacts", with_runs=True)
|
|
230
254
|
flows = cases or [{"name": t, "ok": ok} for t in tests]
|
|
231
|
-
result: Dict[str, Any] = {"ok": ok and all(c["ok"] for c in flows), "flows": flows, "commands": commands, "log": log[-2000:], **({"job": job} if job else {})}
|
|
255
|
+
result: Dict[str, Any] = {"ok": ok and all(c["ok"] for c in flows), "flows": flows, "commands": commands, "log": log[-2000:], **({"job": job} if job else {}), **({"device_runs": runs} if runs > 1 else {})}
|
|
232
256
|
if not result["ok"]:
|
|
233
257
|
failed = [c for c in cases if not c["ok"] and c.get("error")]
|
|
234
258
|
last = [line for line in log.strip().splitlines() if line.strip()][-1:] or [""]
|
|
235
259
|
result["error"] = (failed[0]["error"] if failed else f"HyperExecute exited with {proc.returncode}: {last[0][:500]}") + (f" (job: {job})" if job else "")
|
|
260
|
+
if job:
|
|
261
|
+
try:
|
|
262
|
+
videos = (fetch_videos or job_videos)(build, out_dir, user, key)
|
|
263
|
+
except Exception as e: # noqa: BLE001 - the run's result stands without its recordings
|
|
264
|
+
videos, result["video_error"] = [], str(e).replace(key, "***")[:300]
|
|
265
|
+
if videos:
|
|
266
|
+
result["videos"] = videos
|
|
236
267
|
return result
|
|
237
268
|
|
|
238
269
|
|
|
239
|
-
|
|
240
|
-
|
|
270
|
+
TESTMU_API = "https://mobile-api.lambdatest.com/mobile-automation/api/v1"
|
|
271
|
+
# Where TestMu keeps a session's recording; a video link anywhere else is not fetched.
|
|
272
|
+
_VIDEO_LINK = re.compile(r"^https://[A-Za-z0-9.-]+\.lambdatest\.com/")
|
|
273
|
+
MAX_VIDEO_BYTES = 500 * 1024 * 1024
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def _testmu_get(url: str, user: str, key: str) -> Any:
|
|
277
|
+
token = base64.b64encode(f"{user}:{key}".encode()).decode()
|
|
278
|
+
req = urllib.request.Request(url, headers={"Authorization": f"Basic {token}", "Accept": "application/json"})
|
|
279
|
+
with urllib.request.urlopen(req, timeout=30) as r: # noqa: S310 - fixed https host
|
|
280
|
+
return json.loads(r.read().decode("utf-8", errors="replace"))
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def _download(url: str, dest: Path) -> None:
|
|
284
|
+
part = dest.with_suffix(".part")
|
|
285
|
+
size = 0
|
|
286
|
+
with urllib.request.urlopen(url, timeout=120) as r, open(part, "wb") as f: # noqa: S310 - checked by _VIDEO_LINK
|
|
287
|
+
while chunk := r.read(1 << 20):
|
|
288
|
+
size += len(chunk)
|
|
289
|
+
if size > MAX_VIDEO_BYTES:
|
|
290
|
+
raise ValueError(f"the video is larger than {MAX_VIDEO_BYTES >> 20} MB")
|
|
291
|
+
f.write(chunk)
|
|
292
|
+
part.replace(dest)
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def job_videos(
|
|
296
|
+
build: str,
|
|
297
|
+
out_dir: Path,
|
|
298
|
+
user: str,
|
|
299
|
+
key: str,
|
|
300
|
+
get: Callable[[str, str, str], Any] = _testmu_get,
|
|
301
|
+
download: Callable[[str, Path], None] = _download,
|
|
302
|
+
tries: int = 6,
|
|
303
|
+
pause: float = 5,
|
|
304
|
+
sleep: Callable[[float], None] = time.sleep,
|
|
305
|
+
) -> List[Dict[str, Any]]:
|
|
306
|
+
"""Each flow's recording from a finished job: TestMu keeps one App Automation session per flow and device, under
|
|
307
|
+
the job's build, with its video. Saved as videos/<flow>.mp4 in the run folder, with the session's TestMu page."""
|
|
308
|
+
sessions: List[Mapping[str, Any]] = []
|
|
309
|
+
for attempt in range(tries):
|
|
310
|
+
builds = get(f"{TESTMU_API}/builds?limit=20", user, key).get("data") or []
|
|
311
|
+
found = next((b for b in builds if isinstance(b, Mapping) and b.get("name") == build), None)
|
|
312
|
+
if found:
|
|
313
|
+
sessions = [s for s in get(f"{TESTMU_API}/sessions?build_id={int(found['build_id'])}&limit=50", user, key).get("data") or [] if isinstance(s, Mapping)]
|
|
314
|
+
# A video is ready a little after its session ends.
|
|
315
|
+
if sessions and all(s.get("video_url") for s in sessions):
|
|
316
|
+
break
|
|
317
|
+
if attempt < tries - 1:
|
|
318
|
+
sleep(pause)
|
|
319
|
+
folder = out_dir / "videos"
|
|
320
|
+
out: List[Dict[str, Any]] = []
|
|
321
|
+
used: set = set()
|
|
322
|
+
for s in sessions:
|
|
323
|
+
flow = str(s.get("name") or "flow")
|
|
324
|
+
device = str(s.get("device") or "")
|
|
325
|
+
base = re.sub(r"[^A-Za-z0-9_.-]", "_", Path(flow).stem).lstrip(".-")[:60] or "flow"
|
|
326
|
+
name = base if base not in used else re.sub(r"[^A-Za-z0-9_.-]", "_", f"{base}-{device}")[:80]
|
|
327
|
+
while name in used:
|
|
328
|
+
name += "_"
|
|
329
|
+
used.add(name)
|
|
330
|
+
test_id = str(s.get("test_id") or s.get("session_id") or "")
|
|
331
|
+
entry: Dict[str, Any] = {"flow": flow, "device": device, "status": str(s.get("status_ind") or "")}
|
|
332
|
+
if test_id:
|
|
333
|
+
entry["link"] = f"https://appautomation.lambdatest.com/test?testID={urllib.parse.quote(test_id)}"
|
|
334
|
+
url = s.get("video_url")
|
|
335
|
+
if isinstance(url, str) and _VIDEO_LINK.match(url):
|
|
336
|
+
folder.mkdir(parents=True, exist_ok=True)
|
|
337
|
+
try:
|
|
338
|
+
download(url, folder / f"{name}.mp4")
|
|
339
|
+
entry["file"] = f"videos/{name}.mp4"
|
|
340
|
+
except (OSError, ValueError) as e:
|
|
341
|
+
entry["error"] = str(e)[:200]
|
|
342
|
+
out.append(entry)
|
|
343
|
+
return out
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def job_results(artifacts: Path, with_runs: bool = False) -> Any:
|
|
347
|
+
"""The flows' JUnit results and Maestro's command results from a job's downloaded artifacts (zips unpacked).
|
|
348
|
+
|
|
349
|
+
A job on several devices brings back one run of Maestro per device. Their commands are not mixed: the first run
|
|
350
|
+
with a failed command gives the steps their results, else the first run. ``with_runs`` adds how many runs came back.
|
|
351
|
+
"""
|
|
241
352
|
if not artifacts.is_dir():
|
|
242
|
-
return [], []
|
|
353
|
+
return ([], [], 0) if with_runs else ([], [])
|
|
243
354
|
for z in list(artifacts.rglob("*.zip")):
|
|
244
355
|
target = z.with_suffix("")
|
|
245
356
|
try:
|
|
@@ -259,4 +370,7 @@ def job_results(artifacts: Path) -> Tuple[List[Dict[str, Any]], List[Dict[str, A
|
|
|
259
370
|
cases: List[Dict[str, Any]] = []
|
|
260
371
|
for xml in sorted(artifacts.rglob("*.xml")):
|
|
261
372
|
cases += _junit(xml)
|
|
262
|
-
|
|
373
|
+
runs = command_runs(artifacts)
|
|
374
|
+
failed = [r for r in runs if any(c.get("status") == "FAILED" for c in r)]
|
|
375
|
+
commands = (failed or runs or [[]])[0]
|
|
376
|
+
return (cases, commands, len(runs)) if with_runs else (cases, commands)
|
|
@@ -273,13 +273,25 @@ _INTERNAL_COMMANDS = frozenset({"applyConfigurationCommand", "defineVariablesCom
|
|
|
273
273
|
|
|
274
274
|
def command_results(debug_dir: Path) -> List[Dict[str, Any]]:
|
|
275
275
|
"""The status of each command Maestro ran (its debug output's commands-*.json), in order; [] when not written."""
|
|
276
|
-
|
|
276
|
+
return [c for run in command_runs(debug_dir) for c in run]
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def command_runs(debug_dir: Path) -> List[List[Dict[str, Any]]]:
|
|
280
|
+
"""Each Maestro run's command results, one list per folder of debug output: a job on several devices writes one
|
|
281
|
+
folder per device, so their commands are kept apart."""
|
|
282
|
+
runs: Dict[Path, List[Dict[str, Any]]] = {}
|
|
277
283
|
for f in sorted(debug_dir.rglob("commands-*.json")):
|
|
284
|
+
results = runs.setdefault(f.parent, [])
|
|
278
285
|
try:
|
|
279
286
|
doc = json.loads(f.read_text(encoding="utf-8", errors="replace"))
|
|
280
287
|
except ValueError:
|
|
281
288
|
continue
|
|
282
|
-
|
|
289
|
+
entries = doc if isinstance(doc, list) else []
|
|
290
|
+
# Maestro does not write the commands in the order they ran; each one's sequenceNumber gives it.
|
|
291
|
+
seqs = [((e.get("metadata") or {}) if isinstance(e, Mapping) else {}).get("sequenceNumber") for e in entries]
|
|
292
|
+
if entries and all(isinstance(s, int) for s in seqs):
|
|
293
|
+
entries = [e for _, e in sorted(zip(seqs, entries), key=lambda p: p[0])]
|
|
294
|
+
for entry in entries:
|
|
283
295
|
command = entry.get("command") if isinstance(entry, Mapping) else None
|
|
284
296
|
# Maestro's own bookkeeping (the flow's config, its env), not a command of the flow.
|
|
285
297
|
if isinstance(command, Mapping) and set(command) & _INTERNAL_COMMANDS:
|
|
@@ -288,7 +300,37 @@ def command_results(debug_dir: Path) -> List[Dict[str, Any]]:
|
|
|
288
300
|
status = str((meta or {}).get("status") or "").upper()
|
|
289
301
|
err = (meta or {}).get("error")
|
|
290
302
|
results.append({"status": status, **({"error": str(err.get("message") if isinstance(err, Mapping) else err)[:1000]} if err else {})})
|
|
291
|
-
return
|
|
303
|
+
return [r for r in runs.values() if r]
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
# The variables Maestro sets itself on every run: a flow reads them without an env: block.
|
|
307
|
+
MAESTRO_BUILTINS = frozenset({"MAESTRO_FILENAME", "MAESTRO_SHARD_ID", "MAESTRO_SHARD_INDEX", "MAESTRO_DEVICE_UDID"})
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def flow_variables(files: Iterable[str | os.PathLike]) -> Tuple[List[str], List[str]]:
|
|
311
|
+
"""``(used, defined)``: the ``${NAME}`` variables checked flows read, and those their own ``env:`` blocks set."""
|
|
312
|
+
used: List[str] = []
|
|
313
|
+
defined: set = set()
|
|
314
|
+
|
|
315
|
+
def walk(value: Any) -> None:
|
|
316
|
+
if isinstance(value, str):
|
|
317
|
+
for m in _JS_EXPR.finditer(value):
|
|
318
|
+
name = m.group(1).strip()
|
|
319
|
+
if name not in used:
|
|
320
|
+
used.append(name)
|
|
321
|
+
elif isinstance(value, Mapping):
|
|
322
|
+
for k, v in value.items():
|
|
323
|
+
if k == "env" and isinstance(v, Mapping):
|
|
324
|
+
defined.update(str(n) for n in v)
|
|
325
|
+
walk(v)
|
|
326
|
+
elif isinstance(value, list):
|
|
327
|
+
for v in value:
|
|
328
|
+
walk(v)
|
|
329
|
+
|
|
330
|
+
for f in files:
|
|
331
|
+
for doc in yaml.safe_load_all(Path(f).read_text(encoding="utf-8")):
|
|
332
|
+
walk(doc)
|
|
333
|
+
return used, sorted(defined)
|
|
292
334
|
|
|
293
335
|
|
|
294
336
|
def run_maestro(
|
|
@@ -18,7 +18,7 @@ import sys
|
|
|
18
18
|
import threading
|
|
19
19
|
import time
|
|
20
20
|
from pathlib import Path
|
|
21
|
-
from typing import IO, Any, Callable, Dict, List, Mapping, Optional
|
|
21
|
+
from typing import IO, Any, Callable, Dict, Iterable, List, Mapping, Optional
|
|
22
22
|
|
|
23
23
|
import yaml
|
|
24
24
|
|
|
@@ -29,7 +29,7 @@ from forgeqe_desktop.visual import image_checker
|
|
|
29
29
|
|
|
30
30
|
from .apps import load_mobile_apps
|
|
31
31
|
from .hyperexecute import run_hyperexecute, testmu_settings
|
|
32
|
-
from .maestro import check_flow, run_maestro, to_flow
|
|
32
|
+
from .maestro import MAESTRO_BUILTINS, check_flow, flow_variables, run_maestro, to_flow
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
def _mobile(req: Mapping[str, Any]) -> Dict[str, Any]:
|
|
@@ -69,10 +69,19 @@ def _maestro_command(mobile: Mapping[str, Any]) -> List[str]:
|
|
|
69
69
|
return list(cmd)
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
def
|
|
73
|
-
"""
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
def _child_env(req: Mapping[str, Any], keep: Iterable[str] = ()) -> Dict[str, str]:
|
|
73
|
+
"""This process's environment for a program it starts (maestro, hyperexecute), without ForgeQE's own secrets (the
|
|
74
|
+
model's key, service tokens: the request's private_env), except the names in ``keep``."""
|
|
75
|
+
private = req.get("private_env")
|
|
76
|
+
drop = {str(n) for n in private if isinstance(n, str)} if isinstance(private, list) else set()
|
|
77
|
+
drop -= set(keep)
|
|
78
|
+
return {k: v for k, v in os.environ.items() if k not in drop}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _maestro_env(req: Mapping[str, Any], names: List[str], secrets: Mapping[str, str]) -> Dict[str, str]:
|
|
82
|
+
"""The environment for maestro: system settings and listed secrets (not ForgeQE's own), with each secret as
|
|
83
|
+
MAESTRO_<NAME>, the only form a flow can read it in."""
|
|
84
|
+
env = _child_env(req)
|
|
76
85
|
for n in names:
|
|
77
86
|
if secrets.get(n) is not None:
|
|
78
87
|
env[f"MAESTRO_{n}"] = secrets[n]
|
|
@@ -108,14 +117,17 @@ def run_replay(req: Mapping[str, Any], events: Events, stop: threading.Event, dr
|
|
|
108
117
|
if used:
|
|
109
118
|
raise WorkflowError("this workflow types secrets, which Maestro on TestMu cannot be given safely yet; replay it on TestMu with --driver appium")
|
|
110
119
|
events.log(f"Running {wf['name'] or 'the workflow'} on Maestro on TestMu ({', '.join(testmu['devices'])}).")
|
|
111
|
-
res = (cloud_run or run_hyperexecute)([(flow_file, "flow.yaml")], ["flow.yaml"], spec.app, spec.platform, testmu, out, wf["name"] or wf["app"],
|
|
120
|
+
res = (cloud_run or run_hyperexecute)([(flow_file, "flow.yaml")], ["flow.yaml"], spec.app, spec.platform, testmu, out, wf["name"] or wf["app"], _testmu_env(req, testmu))
|
|
112
121
|
else:
|
|
113
122
|
events.log(f"Running {wf['name'] or 'the workflow'} on Maestro ({flow_file}).")
|
|
114
|
-
res = (maestro_run or run_maestro)(_maestro_command(mobile), [str(flow_file)], out, _maestro_env(used, secrets), device=m.get("device"))
|
|
123
|
+
res = (maestro_run or run_maestro)(_maestro_command(mobile), [str(flow_file)], out, _maestro_env(req, used, secrets), device=m.get("device"))
|
|
115
124
|
steps = _maestro_steps(wf, res.get("commands") or [], res["ok"])
|
|
116
125
|
for s in steps:
|
|
117
126
|
events.emit({"type": "step", **s})
|
|
118
|
-
|
|
127
|
+
_log_videos(events, res)
|
|
128
|
+
if res.get("device_runs"):
|
|
129
|
+
events.log(f"The job ran on {res['device_runs']} devices; the steps show {'the first that failed' if not res['ok'] else 'the first'}, the job's page has each device's.")
|
|
130
|
+
return {**base, "ok": res["ok"], "steps": steps, "heals": [], "flow": str(flow_file), **({"job": res["job"]} if res.get("job") else {}), **({"device_runs": res["device_runs"]} if res.get("device_runs") else {}), **({"videos": res["videos"]} if res.get("videos") else {}), **({"error": res["error"]} if res.get("error") else {})}
|
|
119
131
|
|
|
120
132
|
from forgeqe_desktop.heal import make_heal
|
|
121
133
|
from forgeqe_desktop.models import takes_images
|
|
@@ -164,8 +176,10 @@ def run_replay(req: Mapping[str, Any], events: Events, stop: threading.Event, dr
|
|
|
164
176
|
|
|
165
177
|
|
|
166
178
|
def _maestro_steps(wf: Mapping[str, Any], commands: List[Mapping[str, Any]], ok: bool) -> List[Dict[str, Any]]:
|
|
167
|
-
"""Each workflow step's result from Maestro's command results
|
|
168
|
-
|
|
179
|
+
"""Each workflow step's result from Maestro's command results, as to_flow writes them: a type step is three Maestro
|
|
180
|
+
commands, and a launch is launchApp then an optional tap for each dismiss target (which never fails the launch)."""
|
|
181
|
+
dismiss = len(wf.get("dismiss") or [])
|
|
182
|
+
per_step = [3 if s["op"] == "type" else 1 + dismiss if s["op"] == "launch" else 1 for s in wf["steps"]]
|
|
169
183
|
if not commands and not ok:
|
|
170
184
|
# No step's result is known (Maestro wrote none, or the job's results did not come back): the run's error says
|
|
171
185
|
# what failed, rather than a step that may have passed.
|
|
@@ -180,6 +194,8 @@ def _maestro_steps(wf: Mapping[str, Any], commands: List[Mapping[str, Any]], ok:
|
|
|
180
194
|
elif not chunk:
|
|
181
195
|
break # Maestro stopped before this step
|
|
182
196
|
else:
|
|
197
|
+
if step["op"] == "launch":
|
|
198
|
+
chunk = chunk[:1]
|
|
183
199
|
failed = [c for c in chunk if c.get("status") == "FAILED"]
|
|
184
200
|
status_ok = not failed and all(c.get("status") in ("COMPLETED", "SKIPPED", "WARNED") for c in chunk)
|
|
185
201
|
error = failed[0].get("error", "failed") if failed else ""
|
|
@@ -286,15 +302,36 @@ def run_flows(req: Mapping[str, Any], events: Events, maestro_run: Optional[Call
|
|
|
286
302
|
name = f"{len(flows)} Maestro flow{'' if len(flows) == 1 else 's'}"
|
|
287
303
|
if testmu:
|
|
288
304
|
spec = _app_of_flows(flows, load_mobile_apps(mobile))
|
|
305
|
+
used, defined = flow_variables(checked)
|
|
306
|
+
unset = [n for n in used if n not in defined and n not in MAESTRO_BUILTINS]
|
|
307
|
+
if unset:
|
|
308
|
+
# Locally a variable can come from the environment (MAESTRO_<NAME>); HyperExecute's machine has none of it.
|
|
309
|
+
raise WorkflowError(f"the flows read ${{{unset[0]}}}, which they do not set in an env: block; Maestro on TestMu cannot be given it yet, so run them with a local maestro")
|
|
289
310
|
events.log(f"Checked {len(checked)} flow file{'' if len(checked) == 1 else 's'}; running {len(flows)} on Maestro on TestMu.")
|
|
290
311
|
# A flow that runs another (runFlow) needs it in the project too: every checked file goes, in its layout.
|
|
291
312
|
real_root = Path(os.path.realpath(root))
|
|
292
313
|
rel = lambda f: Path(os.path.realpath(f)).relative_to(real_root).as_posix() # noqa: E731
|
|
293
|
-
res = (cloud_run or run_hyperexecute)([(Path(f), rel(f)) for f in checked], [rel(f) for f in flows], spec.app, spec.platform, testmu, out, name,
|
|
314
|
+
res = (cloud_run or run_hyperexecute)([(Path(f), rel(f)) for f in checked], [rel(f) for f in flows], spec.app, spec.platform, testmu, out, name, _testmu_env(req, testmu))
|
|
294
315
|
else:
|
|
295
316
|
events.log(f"Checked {len(checked)} flow file{'' if len(checked) == 1 else 's'}; running {len(flows)} on Maestro.")
|
|
296
|
-
res = (maestro_run or run_maestro)(_maestro_command(mobile), [str(Path(f).resolve()) for f in flows], out, _maestro_env(names, secrets), device=m.get("device"))
|
|
297
|
-
|
|
317
|
+
res = (maestro_run or run_maestro)(_maestro_command(mobile), [str(Path(f).resolve()) for f in flows], out, _maestro_env(req, names, secrets), device=m.get("device"))
|
|
318
|
+
_log_videos(events, res)
|
|
319
|
+
return {"mode": "maestro", "ok": res["ok"], "flows": res.get("flows") or [], "checked": checked, "name": name, **({"job": res["job"]} if res.get("job") else {}), **({"videos": res["videos"]} if res.get("videos") else {}), **({"error": res["error"]} if res.get("error") else {})}
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def _log_videos(events: Events, res: Mapping[str, Any]) -> None:
|
|
323
|
+
"""Where each flow's TestMu recording was saved (or why not), for the person running it."""
|
|
324
|
+
for v in res.get("videos") or []:
|
|
325
|
+
where = v.get("file") or f"not saved ({v.get('error') or 'TestMu had no video for it'})"
|
|
326
|
+
events.log(f"Video of {v.get('flow')} on {v.get('device') or 'the device'}: {where}{' · ' + v['link'] if v.get('link') else ''}")
|
|
327
|
+
if res.get("video_error"):
|
|
328
|
+
events.log(f"The job's videos could not be fetched from TestMu: {res['video_error']}")
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def _testmu_env(req: Mapping[str, Any], testmu: Mapping[str, Any]) -> Dict[str, str]:
|
|
332
|
+
"""The hyperexecute CLI's environment: no ForgeQE secrets, but TestMu's user and key, which run_hyperexecute reads
|
|
333
|
+
(and keeps out of the CLI's own environment)."""
|
|
334
|
+
return _child_env(req, keep=(testmu["username_env"], testmu["access_key_env"]))
|
|
298
335
|
|
|
299
336
|
|
|
300
337
|
def _app_of_flows(flows: List[str], apps: Mapping[str, Any]) -> Any:
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{$n as e,Ar as t,At as n,Cr as r,G as i,Ht as a,J as o,K as s,Nr as c,Ot as l,Rt as u,T as d,Wt as f,X as p,Y as m,Z as h,_r as g,_t as _,at as v,bn as y,bt as b,ct as x,dt as S,er as C,fn as w,in as T,ir as E,ot as D,qn as O,qt as k,r as A,st as j,t as ee,yt as M}from"./frame-3JV5tjBP.js";import{n as N,t as P}from"./markdown-Bca_tHZ5.js";import{t as te}from"./external-link-Cu8-HMUj.js";import{S as F,h as I,i as L,w as R}from"./index-XRjCGJfG.js";var z={name:`calendar-plus`,size:24,node:[[`path`,{d:`M16 18h6`,key:`987eiv`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M19 15v6`,key:`10aioa`}],[`path`,{d:`M21 11.5V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h8.3`,key:`jgwkxf`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}]]};z.node;var B=E(z),V={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};V.node;var ne=E(V),H={name:`search-check`,size:24,node:[[`path`,{d:`m8 11 2 2 4-4`,key:`1sed1v`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]};H.node;var U=E(H),W={name:`timer-off`,size:24,node:[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7`,key:`10he05`}],[`path`,{d:`M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2`,key:`15f7sh`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M12 12v-2`,key:`fwoke6`}]]};W.node;var G=E(W),K=c(t(),1),q=M(),J={monitor:`Monitor`,suite:`Suite`,run:`Browser run`,heal:`Heal`,"pr-tests":`PR tests`,pack:`Pack`,pipeline:`Pipeline watch`},Y={running:{label:`Running`,tone:`running`},passed:{label:`Passed`,tone:`pass`},failed:{label:`Failed`,tone:`fail`},stopped:{label:`Stopped`,tone:`neutral`},timed_out:{label:`Timed out`,tone:`fail`},interrupted:{label:`Interrupted`,tone:`warn`}},X=e=>{if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString([],{month:`short`,day:`numeric`,...t.getFullYear()===new Date().getFullYear()?{}:{year:`numeric`},hour:`numeric`,minute:`2-digit`})},Z=e=>{if(!e.endedAt)return``;let t=Math.max(0,Math.round((Date.parse(e.endedAt)-Date.parse(e.startedAt))/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`};function Q(e){return e.running?Y.running:e.enabled?e.last?Y[e.last.status]:{label:`Not run yet`,tone:`neutral`}:{label:`Disabled`,tone:`neutral`}}var re={pass:`bg-pass`,fail:`bg-fail`,warn:`bg-warn`,running:`bg-accent`,neutral:`bg-line`};function $({label:e,icon:t,children:n}){return(0,q.jsxs)(`div`,{className:`flex min-h-[48px] flex-wrap items-baseline gap-x-4 gap-y-1 border-t border-line-soft py-2.5`,children:[(0,q.jsxs)(`span`,{className:`flex w-[170px] flex-none items-center gap-2 text-sm text-muted`,children:[t&&(0,q.jsx)(_,{icon:t,size:16,className:`flex-none`}),e]}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 text-sm [overflow-wrap:anywhere]`,children:n})]})}function ie({m:e,rounds:t}){let[n,r]=(0,K.useState)(``);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsxs)(`h3`,{className:`m-0 mb-1 flex items-center gap-2 text-base font-semibold`,children:[(0,q.jsx)(_,{icon:w,size:18,className:`text-accent-fg`}),`Monitor`]}),(0,q.jsx)($,{icon:T,label:`Checks`,children:e.checks.length?(0,q.jsx)(N,{text:e.checks.map(e=>`\`${e.replace(/`/g,``)}\``).join(`, `),className:`text-sm [&_p]:my-0`}):`The checks in forgeqe.yaml (monitor.checks)`}),(0,q.jsxs)($,{icon:C,label:`Alerts after`,children:[e.failAfter,` failing round`,e.failAfter===1?``:`s`,` in a row`,e.remind?`, again every ${e.remind} while it keeps failing`:``]}),(0,q.jsx)($,{icon:u,label:`Alerts go to`,children:e.alerts.length?e.alerts.join(` and `):`Nowhere yet: add Teams or email in Settings, Monitor`}),(0,q.jsxs)($,{icon:f,label:`Each round`,children:[e.parallel,` check`,e.parallel===1?``:`s`,` at once; a recorded run `,e.replay===`trust`?`is trusted`:e.replay===`off`?`is not replayed`:`is verified with one model call`]}),(0,q.jsx)($,{icon:y,label:`Rounds kept in`,children:(0,q.jsx)(P,{path:e.outDir})}),(0,q.jsx)(`p`,{className:`m-0 border-t border-line-soft py-2.5 text-sm`,children:(0,q.jsx)(`a`,{href:h(`settings`,`monitor`),children:`Change the monitor in Settings`})}),(0,q.jsx)(`h4`,{className:`m-0 mt-3 mb-1 text-sm font-semibold`,children:`Latest rounds`}),n&&(0,q.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:n}),t.length===0?(0,q.jsx)(`p`,{className:`m-0 border-t border-line-soft py-3 text-sm text-muted`,children:`No rounds yet.`}):(0,q.jsx)(`ul`,{className:`m-0 list-none p-0`,children:t.slice(0,8).map(e=>(0,q.jsxs)(`li`,{className:`flex min-h-[48px] items-center gap-3 border-t border-line-soft py-2`,children:[(0,q.jsxs)(L,{tone:e.counts.failed?`fail`:`pass`,children:[e.counts.passed,`/`,e.counts.total,` passed`]}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:X(e.startedAt)}),e.report?(0,q.jsxs)(S,{size:`sm`,"aria-label":`Open the report of the round of ${X(e.startedAt)} in a new tab`,onClick:async()=>r(await m(e.report)),children:[(0,q.jsx)(te,{size:14,"aria-hidden":`true`}),`Open report`]}):(0,q.jsx)(P,{path:e.folder})]},e.key))})]})}function ae({jobId:e,run:t}){let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(``);(0,K.useEffect)(()=>{let n=!1;r(null);let i=()=>g.log(e,t.id).then(e=>!n&&r(e.lines),e=>!n&&a(e.message));i();let o=t.status===`running`?setInterval(i,2e3):void 0;return()=>{n=!0,o&&clearInterval(o)}},[e,t.id,t.status]);let o=Math.max(2,...(n||[]).map(e=>Math.max(0,...(e.match(/`+/g)||[]).map(e=>e.length)))),s="`".repeat(o+1),c=[`**${Y[t.status].label}**${t.endedAt?` after ${Z(t)}`:``}${t.exitCode!==void 0&&t.exitCode!==null?`, exit ${t.exitCode}`:``}. Started ${X(t.startedAt)}, ${t.reason===`asked`?`asked for`:`on schedule`}.`,...t.investigating?[``,`_Its failures are being investigated._`]:[],...t.findings?.length?[``,`**Investigated:**`,...t.findings.map(e=>`- ${e.verdict}: ${e.tests.map(e=>`\`${e.replace(/`/g,``)}\``).join(`, `)}${e.branch?` on branch \`${e.branch.replace(/`/g,``)}\``:``}`)]:[],...t.investigationNote?[``,t.investigationNote]:[],``,`${s}text`,...n||[],s].join(`
|
|
2
|
-
`);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[12px] border border-line-soft bg-surface-muted px-4 py-3`,children:[i&&(0,q.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:i}),!n&&!i?(0,q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading its output…`}):(0,q.jsx)(N,{text:c,className:`text-sm [&_pre]:max-h-[320px] [&_pre]:overflow-auto`})]})}function oe({job:t,rounds:r,busy:i,act:o}){let[s,c]=(0,K.useState)(null),[u,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(!1),h=`${t.running?.id}|${t.last?.id}|${t.last?.status}`;(0,K.useEffect)(()=>{let e=!1;return g.detail(t.id).then(t=>{e||(c(t.runs),f(e=>e??t.runs[0]?.id??null))},()=>{}),()=>{e=!0}},[t.id,h]),(0,K.useEffect)(()=>{f(null),m(!1)},[t.id]);let y=Q(t),b=s?.filter(e=>e.status===`passed`).length??0,x=s?.filter(e=>e.status!==`running`).length??0;return(0,q.jsxs)(`section`,{"aria-labelledby":`job-h`,className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_260px] flex-col gap-1`,children:[(0,q.jsx)(`h2`,{id:`job-h`,className:`m-0 text-[22px] font-semibold tracking-[-0.01em] [overflow-wrap:anywhere]`,children:t.name}),(0,q.jsxs)(`span`,{className:`text-sm text-muted`,children:[J[t.kind]||t.kind,` · `,t.schedule]})]}),(0,q.jsx)(L,{tone:y.tone,children:y.label}),t.running?(0,q.jsxs)(S,{disabled:i,onClick:()=>o(`stop`),children:[(0,q.jsx)(n,{size:14,fill:`currentColor`,"aria-hidden":`true`}),`Stop`]}):(0,q.jsxs)(S,{variant:`primary`,disabled:i,onClick:()=>o(`run`),children:[(0,q.jsx)(_,{icon:k,size:16}),`Run now`]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,q.jsx)(d,{icon:a,label:`Runs kept`,value:String(s?.length??`–`)}),(0,q.jsx)(d,{icon:R,label:`Passed`,value:x?`${Math.round(b/x*100)}%`:`–`,note:x?`${b} of ${x}`:void 0}),(0,q.jsx)(d,{icon:O,label:`Next run`,value:t.nextAt?new Date(t.nextAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`}):`–`,note:t.nextAt?X(t.nextAt):t.enabled?void 0:`Disabled`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)($,{icon:l,label:`Runs`,children:(0,q.jsx)(N,{text:`\`${t.command.replace(/`/g,``)}\``,className:`text-sm [&_p]:my-0`})}),(0,q.jsx)($,{icon:O,label:`When`,children:t.schedule}),(0,q.jsx)($,{icon:ne,label:`Enabled`,children:(0,q.jsx)(v,{checked:t.enabled,disabled:i,onChange:e=>o(e?`enable`:`disable`),label:`${t.name} enabled`})}),(0,q.jsxs)($,{icon:G,label:`Stopped after`,children:[t.timeoutMs?t.timeoutMs%36e5==0?`${t.timeoutMs/36e5} hour${t.timeoutMs===36e5?``:`s`}`:`${Math.round(t.timeoutMs/6e4)} minutes`:`the service's default`,` of running`]}),(0,q.jsx)($,{icon:e,label:`Tells the team`,children:t.notify?`When it fails, recovers or ends (the notify channels that take job events)`:t.kind===`monitor`?`The monitor sends its own alerts`:`No`}),(0,q.jsx)($,{icon:U,label:`Investigates failures`,children:t.investigate?`Yes, on branches of their own`:`No`}),(0,q.jsxs)($,{icon:B,label:`Added`,children:[X(t.createdAt),` `,t.by===`agent`?`by ForgeQE's agent, after you agreed`:`from the command line or here`]})]}),t.monitor&&(0,q.jsx)(ie,{m:t.monitor,rounds:r}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`h3`,{className:`m-0 mb-1 text-base font-semibold`,children:`Runs`}),s?s.length===0?(0,q.jsx)(`p`,{className:`m-0 border-t border-line-soft py-3 text-sm text-muted`,children:`No runs yet. Run now starts one.`}):(0,q.jsx)(`ul`,{className:`m-0 list-none p-0`,children:s.map(e=>(0,q.jsxs)(`li`,{className:`border-t border-line-soft`,children:[(0,q.jsxs)(`button`,{type:`button`,"aria-expanded":u===e.id,onClick:()=>f(u===e.id?null:e.id),className:`flex min-h-[52px] w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-1 py-2 text-left text-ink hover:bg-surface-muted`,children:[(0,q.jsx)(L,{tone:Y[e.status].tone,children:Y[e.status].label}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:[X(e.startedAt),(0,q.jsxs)(`span`,{className:`text-muted`,children:[` `,`· `,e.reason===`asked`?`asked for`:`scheduled`,Z(e)?` · ${Z(e)}`:``]})]}),e.summary?.length?(0,q.jsx)(`span`,{className:`hidden max-w-[40%] truncate text-[13px] text-muted sm:inline`,children:e.summary.at(-1)}):null]}),(0,q.jsx)(j,{open:u===e.id,children:(0,q.jsx)(`div`,{className:`pb-3`,children:(0,q.jsx)(ae,{jobId:t.id,run:e})})})]},e.id))}):(0,q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading…`})]}),(0,q.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-line-soft pt-4`,children:p?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`span`,{className:`text-sm text-ink-2`,children:[`Remove `,t.name,`? Its runs and logs go with it.`]}),(0,q.jsx)(S,{disabled:i,onClick:()=>o(`remove`),className:`border-fail text-fail hover:bg-fail-soft`,children:`Remove`}),(0,q.jsx)(S,{onClick:()=>m(!1),children:`Keep it`})]}):(0,q.jsxs)(S,{variant:`ghost`,onClick:()=>m(!0),className:`text-fail`,children:[(0,q.jsx)(I,{size:16,"aria-hidden":`true`}),`Remove this job`]})})]})}function se({open:e,onClose:t,commands:n,initial:r,onAdded:a}){let[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(`suite`),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)(`every`),[_,y]=(0,K.useState)(`30m`),[b,x]=(0,K.useState)(`0 2 * * 1-5`),[C,w]=(0,K.useState)(!0),[T,E]=(0,K.useState)(``),[D,O]=(0,K.useState)(!1);(0,K.useEffect)(()=>{e&&(l(r?.name??``),d(r?.command??`suite`),p(r?.args??``),h(`every`),y(r?.every??`30m`),w(r?.command!==`monitor`),E(``))},[e,r]);let k=async()=>{O(!0),E(``);try{a(await g.add({name:c.trim(),command:u,args:f,...m===`every`?{every:_}:m===`cron`?{cron:b}:{now:!0},notify:C}),c.trim())}catch(e){E(e.message)}finally{O(!1)}},A=`flex flex-col gap-1.5 py-3`;return(0,q.jsx)(o,{open:e,onClose:t,title:`Add a job`,description:`A ForgeQE command the jobs service runs on a schedule, or once now, in a process of its own; it keeps going with this page closed.`,footer:(0,q.jsxs)(q.Fragment,{children:[T&&(0,q.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-sm text-fail [overflow-wrap:anywhere]`,children:T}),(0,q.jsx)(S,{onClick:t,children:`Cancel`}),(0,q.jsx)(S,{variant:`primary`,disabled:D||!c.trim(),onClick:()=>void k(),children:D?`Adding…`:`Add job`})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col pt-3`,children:[(0,q.jsxs)(`div`,{className:A,children:[(0,q.jsx)(`label`,{htmlFor:`job-name`,className:`font-medium`,children:`Name`}),(0,q.jsx)(i,{id:`job-name`,value:c,spellCheck:!1,placeholder:`nightly-smoke`,onChange:e=>l(e.target.value)}),(0,q.jsx)(`span`,{className:`text-sm text-muted`,children:`Letters, digits and dashes.`})]}),(0,q.jsxs)(`div`,{className:A,children:[(0,q.jsx)(`label`,{htmlFor:`job-command`,className:`font-medium`,children:`Runs`}),(0,q.jsx)(s,{id:`job-command`,value:u,onChange:e=>d(e.target.value),children:n.map(e=>(0,q.jsxs)(`option`,{value:e,children:[`forgeqe `,e]},e))})]}),(0,q.jsxs)(`div`,{className:A,children:[(0,q.jsx)(`label`,{htmlFor:`job-args`,className:`font-medium`,children:`With`}),(0,q.jsx)(i,{id:`job-args`,value:f,spellCheck:!1,placeholder:u===`monitor`?`Empty: the checks in forgeqe.yaml`:`checks/smoke.yaml --parallel 2`,onChange:e=>p(e.target.value),className:`font-mono text-[13px]`}),(0,q.jsx)(`span`,{className:`text-sm text-muted`,children:`Test case sources and flags, as you would type them after the command. "…" keeps spaces in one. Nothing goes through a shell.`})]}),(0,q.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0 py-3`,children:[(0,q.jsx)(`legend`,{className:`mb-1 font-medium`,children:`When`}),[[`every`,`Every`],[`cron`,`On a schedule (cron, this machine's time)`],[`once`,`Once, now`]].map(([e,t])=>(0,q.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-3`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`job-when`,checked:m===e,onChange:()=>h(e),className:`size-4 accent-accent`}),(0,q.jsx)(`span`,{className:`flex-none`,children:t}),e===`every`&&m===`every`&&(0,q.jsx)(i,{"aria-label":`Every`,value:_,onChange:e=>y(e.target.value),placeholder:`30m`,className:`max-w-[120px] font-mono text-[13px]`}),e===`cron`&&m===`cron`&&(0,q.jsx)(i,{"aria-label":`Cron schedule`,value:b,onChange:e=>x(e.target.value),className:`max-w-[180px] font-mono text-[13px]`})]},e))]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-4 py-3`,children:[(0,q.jsxs)(`span`,{className:`flex flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`Tell the team`}),(0,q.jsx)(`span`,{className:`text-sm text-muted`,children:`When it fails, recovers or ends, on the notify channels that take job events. A monitor sends its own alerts.`})]}),(0,q.jsx)(v,{checked:C,onChange:w,label:`Tell the team`})]})]})})}function ce({sub:e}){let[t,n]=(0,K.useState)(null),[i,a]=(0,K.useState)([]),[o,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(null),f=(0,K.useCallback)(()=>{g.list().then(e=>{n(e),s(``)},e=>s(e.message))},[]);(0,K.useEffect)(f,[f]),(0,K.useEffect)(()=>{r.list().then(e=>a(e.rows.filter(e=>e.scope===`monitor`)),()=>{})},[t?.jobs.map(e=>e.last?.id).join()]);let m=t?.jobs.some(e=>e.running);(0,K.useEffect)(()=>{let e=setInterval(f,m?3e3:2e4);return()=>clearInterval(e)},[f,m]);let v=e?decodeURIComponent(e):``,y=t?.jobs.find(e=>e.id===v)||t?.jobs[0],C=(0,K.useMemo)(()=>t?.jobs.filter(e=>e.kind===`monitor`)??[],[t]),T=(0,K.useMemo)(()=>t?.jobs.filter(e=>e.kind!==`monitor`)??[],[t]),E=async e=>{if(y){l(!0),s(``);try{n(e===`remove`?await g.remove(y.id):await g.act(y.id,e)),e===`remove`&&(location.hash=h(`jobs`))}catch(e){s(e.message)}finally{l(!1)}}},k=e=>{let t=Q(e),n=y?.id===e.id;return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`a`,{href:h(`jobs`,encodeURIComponent(e.id)),"aria-current":n?`page`:void 0,className:b(`flex min-h-[60px] items-center gap-3 rounded-[12px] px-3 py-2 text-ink no-underline`,n?`bg-surface-strong hover:text-ink`:`hover:bg-surface-muted hover:text-ink`),children:[e.running?(0,q.jsx)(x,{label:t.label,px:16}):(0,q.jsx)(`span`,{"aria-label":t.label,className:b(`size-2.5 flex-none rounded-full`,re[t.tone])}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`truncate text-[15px] font-medium`,children:e.name}),(0,q.jsx)(`span`,{className:`truncate text-[13px] text-muted`,children:[t.label,e.schedule,e.nextAt&&e.enabled?`next ${X(e.nextAt)}`:``].filter(Boolean).join(` · `)})]})]})},e.id)};return(0,q.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,q.jsx)(A,{}),(0,q.jsxs)(`main`,{className:b(ee,`@container flex-auto gap-4`),children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,q.jsx)(D,{pixel:p.jobs,size:`lg`}),(0,q.jsx)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:`Jobs`}),t&&(0,q.jsx)(L,{tone:t.service.running?`pass`:`neutral`,children:t.service.running?`Service running since ${X(t.service.startedAt)}`:`Service stopped: jobs wait until it starts`}),(0,q.jsx)(`div`,{className:`flex-auto`}),(0,q.jsxs)(S,{variant:`primary`,disabled:!t,onClick:()=>d({}),children:[(0,q.jsx)(F,{size:16,"aria-hidden":`true`}),`Add a job`]})]}),(0,q.jsx)(`p`,{className:`m-0 max-w-[70ch] text-sm leading-relaxed text-muted`,children:`ForgeQE commands that run on a schedule, or once, in a service of their own, so they keep going while you work on something else or with this page closed: monitors, suites, packs and pipeline watches.`}),o&&(0,q.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:o}),!t&&!o&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),t?.monitor&&!t.monitor.scheduled&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3 rounded-[14px] border border-accent-line bg-accent-soft px-4 py-3`,children:[(0,q.jsx)(_,{icon:w,size:20,className:`flex-none text-accent-fg`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_300px] flex-col gap-0.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`The monitor in forgeqe.yaml is not scheduled`}),(0,q.jsxs)(`span`,{className:`text-ink-2`,children:[t.monitor.checks.length,` check`,t.monitor.checks.length===1?``:`s`,`, every `,t.monitor.every,`. As a job it runs a round each time, with this page closed.`]})]}),(0,q.jsx)(S,{onClick:()=>d({name:`monitor`,command:`monitor`,args:``,every:t.monitor.every}),children:`Schedule it`})]}),t&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 @2xl:flex-row @2xl:items-start @2xl:gap-8`,children:[(0,q.jsxs)(`nav`,{"aria-label":`Jobs`,className:`flex min-w-0 flex-col gap-4 @2xl:sticky @2xl:top-6 @2xl:w-[250px] @2xl:flex-none`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-2 px-3 text-[13px] font-medium text-muted`,children:[(0,q.jsx)(_,{icon:w,size:14}),`Monitoring (`,C.length,`)`]}),C.length?(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:C.map(k)}):(0,q.jsx)(`p`,{className:`m-0 px-3 py-2 text-sm text-muted`,children:`No monitor jobs.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-2 px-3 text-[13px] font-medium text-muted`,children:[(0,q.jsx)(_,{icon:O,size:14}),`Other jobs (`,T.length,`)`]}),T.length?(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:T.map(k)}):(0,q.jsx)(`p`,{className:`m-0 px-3 py-2 text-sm text-muted`,children:`None.`})]}),t.events.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`px-3 text-[13px] font-medium text-muted`,children:`Recent activity`}),(0,q.jsx)(N,{text:t.events.slice(0,12).map(e=>`- \`${X(e.at)}\` ${e.text.replace(/([\\`*_[\]<>#|~!])/g,`\\$1`)}`).join(`
|
|
3
|
-
`),className:`px-3 text-[13px] text-ink-2 [&_li]:my-1 [&_ul]:my-0 [&_ul]:pl-4`})]})]}),y?(0,q.jsx)(oe,{job:y,rounds:i,busy:c,act:E}):(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-3 rounded-[18px] border border-line p-6`,children:[(0,q.jsx)(_,{icon:O,size:24,className:`text-muted`}),(0,q.jsx)(`p`,{className:`m-0 max-w-[60ch] leading-relaxed text-ink-2`,children:`No jobs yet. Add one to run a suite every night, a monitor every 15 minutes, or watch a CI pipeline.`}),(0,q.jsx)(S,{onClick:()=>d({}),children:`Add a job`})]})]})]}),(0,q.jsx)(se,{open:!!u,onClose:()=>d(null),commands:t?.commands??[],initial:u??void 0,onAdded:(e,t)=>{n(e),d(null);let r=e.jobs.find(e=>e.name===t);r&&(location.hash=h(`jobs`,encodeURIComponent(r.id)))}})]})}export{ce as Jobs};
|