Scripts UI — Script editor and runner¶
Role in the stack¶
Scripts UI is a web interface embedded in PerfShop that lets students edit, manage, and run their test scripts directly from the browser — with no command line, no SSH access, no local IDE.
perfshop-scripts-ui ← Node.js :3008
├── CodeMirror editor (.robot and .py) — 100% local dependencies
├── File tree with drag & drop upload and move
├── Launching robot / pytest directly from the UI
├── Real-time results (1.5s polling)
├── Runs tab — persistent execution history
├── Publish to Forgejo
└── Pull from Forgejo (git pull → /scripts)
Access¶
| Environment | URL | Login |
|---|---|---|
| NAS prod | https://perfshop-scripts.perfshop.io |
admin@perfshop.fr / perfshop |
| Docker Desktop / local build | http://localhost:3008 |
admin@perfshop.fr / perfshop |
Features¶
| Feature | Description |
|---|---|
| File tree | Navigation in the script folders with expand/collapse |
| Drag & drop in the tree | Move a file to a folder via drag-and-drop |
| CodeMirror editor | Robot Framework and Python syntax highlighting — local dependencies |
| New file | Creation with a .robot or .py template |
| New folder | Subfolder creation (automatic .gitkeep) |
| Upload | Drag & drop or click — choice of target folder |
| Download | Export a script locally |
| Move / Rename | Move via modal or drag & drop in the tree |
| Delete | File or folder deletion (recursive) |
| Run | Execute .robot via robot or .py via pytest — button grayed out on other extensions |
| Live results | Polling every 1.5s during execution |
| Runs tab | Execution history persisted on disk — click → detail in the Result tab |
| Publish | Push the current script to Forgejo (with SHA) |
| ⬇️ Pull Forgejo | git pull from Forgejo to /scripts |
| History | Display of the latest Forgejo commits |
Technical architecture¶
perfshop-scripts-ui:
build:
context: . ← repository root: the image embeds shared-node (B0)
dockerfile: scripts-ui/Dockerfile
volumes:
- docker-relay-scripts-ui:/run/docker-relay:ro ← Docker relay socket (commands in test-runner only)
- forgejo-token-data:/token:ro ← Forgejo API token, written by perfshop-forgejo-seed
- ./test-runner/logs:/rf-logs ← run persistence, shared with test-runner
- scripts-ui-sessions:/app/sessions ← login sessions
- training-secret:/training:ro ← technical accounts, written by perfshop-app
environment:
- FORGEJO_INTERNAL_URL=http://perfshop-forgejo:3000
- FORGEJO_REPO=perfshop-tests
- TEST_RUNNER_CONTAINER=perfshop-test-runner
- DOCKER_SOCKET=/run/docker-relay/docker.sock ← the relay's socket, not the daemon's
- SESSION_SECRET=${SESSION_SECRET} ← session secret, read from the .env (see .env.example)
- RUNS_DIR=/rf-logs/runs ← persistence folder (optional, default value)
In the shipped compose files (docker-compose.desktop.yml, docker-compose.build.yml), Scripts UI does not mount the
Docker daemon socket: it talks to the perfshop-docker-relay relay, which grants it only the state of
perfshop-test-runner and commands in that container. See
Docker socket: the relay.
Script execution flow¶
Student clicks "▶ Run"
│
▼
scripts-ui checks the extension (.robot / .py only)
│
▼
scripts-ui checks that perfshop-test-runner is UP (docker inspect)
│
▼
docker exec perfshop-test-runner robot /scripts/my-script.robot
(or pytest /scripts/my-script.py --junit-xml=...)
│
▼
Polling every 1.5s → real-time stdout display
│
▼
Result in the bottom panel: PASS, SKIP (no test executed), FAIL or ERR + counters
│
▼
Persistence: /rf-logs/runs/<runId>/ (meta.json, output.txt, reports, screenshots)
Concurrency limit
A maximum of 3 scripts can run simultaneously (MAX_CONCURRENT_RUNS = 3).
Beyond that, the UI returns an HTTP 429 error.
Runs tab — execution persistence¶
Each finished run is persisted on disk in its own directory of /rf-logs/runs/, with its status:
| Status | Badge | Meaning |
|---|---|---|
passed |
✅ PASS | at least one test executed, no failure |
skipped |
⏭ SKIP | no test executed: all skipped (Skip, script launched without its Squash data set…). This is not a success, even though Robot and pytest exit with 0 |
failed |
❌ FAIL | at least one failed test |
error |
⚠ ERR | the infrastructure could not run the test (300 s timeout, runner unreachable…) |
The Result panel also shows the counters (passed · failed · skipped), read from the run's report.
/rf-logs/runs/
run-1790709517794-92cdc041/
├── meta.json ← script, startedAt, endedAt, status, rc, stats, artifacts, trainingUser
├── output.txt ← complete run output
├── output.xml, log.html, report.html ← Robot Framework (pytest: pytest.xml)
└── *.png ← screenshots of the run (Capture Page Screenshot)
Retention: 30 days and 2 GB — export the evidence first
Runs are not kept forever. When Scripts UI starts, then every hour, runs older than 30 days are deleted and, if the directory exceeds 2 GB, the oldest ones go until it is back under that cap. A run in progress is never deleted; every purge is logged (docker logs perfshop-scripts-ui 2>&1 | grep retention).
Instructor: a run to be kept (disputed grade, exam file) must be copied out of test-runner/logs/runs/ before the deadline. To change the rule: RUNS_RETENTION_DAYS and RUNS_RETENTION_MAX_MB in the service environment (0 = disabled), then recreate the container. Details: Scripts UI — run retention.
The 🏃 Runs tab lists the last 50 runs sorted by descending date. Clicking a row switches to the 📋 Result tab with the full detail and the links to the artifacts: the log and the report open in a new tab (served in a sandbox, through a read link valid for 2 h), with their screenshots; each screenshot is also listed (🖼) and downloadable.
Required volume
The ./test-runner/logs:/rf-logs volume must be mounted on perfshop-scripts-ui
without :ro. A docker compose stop + up is required (not a simple restart)
for Docker to pick up this new mount.
Publication flow to Forgejo¶
Student clicks "Publish"
│
▼
scripts-ui reads the token from /token/forgejo_token
│
▼
GET /api/v1/repos/perfshop-ci/perfshop-tests/contents/{file}
→ retrieves the SHA if the file already exists
│
▼
PUT (update) or POST (create) with the base64 content
│
▼
Forgejo commits on main: "feat: update {file}"
Server API routes¶
| Method | Route | Description |
|---|---|---|
GET |
/api/tree |
Forgejo file tree (.robot / .py) |
GET |
/api/file?path= |
File contents |
GET |
/api/download?path= |
Raw download |
PUT |
/api/file |
Publish (create / update) |
DELETE |
/api/file |
Delete a file |
POST |
/api/upload |
Upload from the browser |
POST |
/api/mkdir |
Create a folder (.gitkeep) |
POST |
/api/move |
Move / rename |
GET |
/api/commits |
Last 15 commits |
POST |
/api/sync |
git pull Forgejo → /scripts |
POST |
/api/run |
Launch a test |
GET |
/api/run/:id |
Status of a live run (polling) |
GET |
/api/runs |
List of the last 50 persisted runs |
GET |
/api/runs/:id |
Detail of a persisted run (meta + output + read link) |
GET |
/api/runs/:id/artifact?name= |
One artifact of the run (reports, .png screenshots) |
GET |
/api/runs/:id/view/<token>/<name> |
Signed read link of the HTML reports (2 h, this run only) |
GET |
/api/runner-status |
test-runner container state |
Security¶
| Measure | Detail |
|---|---|
| Authentication | Express session cookie (PerfShop login) |
| Forgejo token | Injected via volume, never in the URL |
| XSS | File tree and table built 100% with DOM API — zero innerHTML with data |
| Event delegation | Admin account emails read from a JS Map — never from an HTML attribute |
| File validation | [\w\-.] only + mandatory .robot / .py extension |
| Run id validation | Strict regex ^run-\d+-[a-f0-9]+$ — path traversal protection |
| HTML reports | Served in a CSP sandbox (the report's scripts are isolated from the session), through a signed read link |
| Runs directory | Also written by the runner (students' code): regular files only, symbolic links never followed |
| Tree depth | Max 4 folder levels |
| Memory cleanup | In-memory runs purged after 1h (every 15 min) |
| Concurrency | Max 3 simultaneous runs — HTTP 429 beyond |
Inter-service dependencies¶
perfshop-scripts-ui
├── depends_on: perfshop-app (auth session)
├── depends_on: perfshop-forgejo (healthcheck) ← Git sync + Publish
└── depends_on: perfshop-test-runner (Run scripts)
Useful commands¶
# Real-time logs
docker compose logs -f perfshop-scripts-ui
# Restart after a code change
# (a volume added to the service is picked up by "up -d", which recreates this container only;
# never "docker compose down", which stops the whole stack)
docker compose stop perfshop-scripts-ui
docker compose up -d perfshop-scripts-ui
# Check that the Forgejo token is present (without printing it: it is a secret)
docker exec perfshop-scripts-ui test -s /token/forgejo_token && echo "token present"
# Check run persistence and the retention rule applied at startup
ls -la /volume4/docker-speed/perfshop/test-runner/logs/runs/
docker logs perfshop-scripts-ui 2>&1 | grep retention