Files
jaredandClaude Opus 5.5 8e57233f92
CI / Lint (PHP 8.4, phpcs, eslint) (pull_request) Successful in 1m17s
CI / Scan (secrets, workflows, shell, patterns) (pull_request) Successful in 1m58s
CI / API and MCP (PHP 8.4, MariaDB) (pull_request) Successful in 1m56s
CI / UI (playwright) (pull_request) Successful in 2m10s
CI / Security (composer and npm audit) (pull_request) Successful in 1m42s
CI / Deploy (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 5m3s
CI: one pipeline to the CI standard: PHP 8.4 lint, audits, scans, API and MCP tests (#136)
Replaces lint.yml and security.yml with .gitea/workflows/ci.yml, following
the shared CI standard (wiki: Infrastructure/ci-standard, modelled on
Pulse and Thor). Deploys now wait for every check.

Jobs:
- Lint: php -l on every file and scripts/check_requirements.php under
  PHP 8.4 (node:22-trixie, Debian 13's packages, as on CT 132); phpcs
  4.0.4 pinned with SHA-256 (was the abandoned squizlabs build, unpinned);
  eslint 8.57.1 from tests/lint/ (lockfile, was `npm install eslint@8`)
  with --max-warnings=66, today's count, so warnings can only go down.
- Security: composer validate --strict, composer audit --locked
  --abandoned=fail, npm audit (high) and audit signatures for the test
  tooling. The audit found symfony/http-client advisories (fixed by the
  lock bump, #137) and mcp/sdk GHSA-f4rf-6ghj-mhr6, ignored with its
  reason in composer.json until #138 (Tinker uses neither affected
  middleware).
- Scan: gitleaks over the full history (#134; the five findings in 527
  commits were the YOUR_API_KEY placeholder on the API keys page,
  allowlisted for that file only in .gitleaks.toml), actionlint,
  shellcheck, zizmor, and semgrep with p/javascript, p/secrets and
  p/security-audit added to the existing packs (no new findings).
- API and MCP: fresh MariaDB, migrations, seed, fixtures; then
  tests/api/mcp_test.php (MCP comment and link tools, 30 checks) and
  tests/api/test_api.py (the Bearer API contract automated reporters
  rely on, 132 checks: dedup by key and title, escalation, the reopen
  window under three Workflow Designer setups, recurrence chains,
  concurrent creates, lookup by dedup_key, source filter, link API).
  These were the local checks of #124/#131 and #121/#124.
- UI and UI screenshots as before (#120).
- API and UI fail on any PHP warning, notice or deprecation in the
  server log (tests/ci/php-warnings.sh): #130's warnings logged while
  every page still rendered.
- Every job has a timeout; runs are grouped per ref; deploys queue and
  are never cancelled; the weekly run re-audits and re-scans.
- Notify: Matrix alert on any failure on a deploy branch or in the
  weekly run, and on every deploy (was: lint failures only).

tests/ui/setup.sh moves to tests/ci/setup.sh (the lint, audit and API
jobs use it too) and takes WITH_DB=0 and EXTRA_PKGS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 00:20:16 -05:00

116 lines
4.2 KiB
PHP

<?php
/**
* Synthetic seed data for the UI tests and before/after screenshots.
*
* CLI only, and only into a database whose name starts with tinker_ui:
*
* DB_NAME=tinker_ui php tests/ui/seed.php
*
* Connects as the throwaway tinker_ui user (tests/ci/setup.sh), never with the
* app's .env credentials. Replaces only the tickets it owns (ids 1000000xx),
* so it can be re-run. Every value here is made up.
*/
if (php_sapi_name() !== 'cli') {
http_response_code(404);
exit;
}
$dbName = (string)getenv('DB_NAME');
if (!str_starts_with($dbName, 'tinker_ui')) {
fwrite(STDERR, "refusing: DB_NAME must start with tinker_ui\n");
exit(2);
}
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$db = new mysqli('127.0.0.1', 'tinker_ui', 'ci-only', $dbName);
$db->set_charset('utf8mb4');
// Fixed times, so before/after screenshots match (screenshots.js pins the
// browser clock to the day after).
$db->query("SET time_zone = '+00:00'");
$created = '2026-11-20 09:00:00';
// A manual or MCP ticket written in markdown: everything #114 renders.
$markdown = <<<'MD'
## Goal
Replace the shared NAS backup target with the new **PBS datastore** on `storage-02`, so nightly jobs stop competing with Ceph recovery traffic.
## Plan
- [x] Create datastore `pbs-main` (ZFS mirror, 2 x 8 TB)
- [x] Add the datastore to all six nodes
- [ ] Move the nightly jobs to the new target
- [ ] Remove the old NFS export
## Sizing
| Dataset | Used | Growth / month |
|---|---|---|
| VM disks | 2.1 TB | 40 GB |
| LXC rootfs | 310 GB | 6 GB |
| Config backups | 2 GB | under 1 GB |
## Commands
```bash
proxmox-backup-manager datastore create pbs-main /mnt/datastore/pbs-main
pvesm add pbs pbs-main --server 10.0.0.20 --datastore pbs-main
```
See the runbook at https://wiki.example.invalid/backups and the related ticket #100000002.
Escaping check: <script>window.__seedXss = 1</script> and [a bad link](javascript:window.__seedXss=1) must stay inert.
MD;
// A Gandalf-style alert: identifiers with underscores must stay literal.
$gandalf = <<<'MD'
## Network Interface Alert
- **Host:** node-03
- **Interface:** `enp5s0`
- **Detected:** 2026-11-20 06:09:05 UTC
- **Consecutive check failures:** 2
Interface enp5s0 on node-03 was up and is now reporting link-down via node_exporter (node_network_up is 0). node-03 itself is still reporting, so it may be reachable over its other interfaces.
### What to check
1. Check the switch port: is it down on the switch side too?
2. Reseat or swap the cable or DAC; for an optic, check the module for a fault.
3. On node-03, check `ip link show enp5s0` and `dmesg` for NIC or driver errors.
_Opened automatically by Gandalf._
MD;
// A plain-text ticket with no markdown at all.
$plain = "The label printer in the rack room jams on every second label.\n"
. "Tried a new roll, same result.\n\nNot urgent, the spare printer works.";
$tickets = [
['100000001', '[backup][manual][storage] Move nightly backups to the new PBS datastore', $markdown, 'Task', 3],
['100000002', '[node-03][auto][network] Interface enp5s0 link-down', $gandalf, 'Issue', 2],
['100000003', 'Label printer jams on every second label', $plain, 'Issue', 4],
];
$comment = "Datastore is up. **Next:** move the jobs.\n\n"
. "- verify `snake_case_job` still runs\n- check the verify_jobs list after the move";
$ids = implode(',', array_map(fn($t) => "'" . $t[0] . "'", $tickets));
$db->query("DELETE FROM ticket_comments WHERE ticket_id IN ($ids)");
$db->query("DELETE FROM tickets WHERE ticket_id IN ($ids)");
$insert = $db->prepare(
"INSERT INTO tickets (ticket_id, title, description, status, priority, category, type, hash, created_at, updated_at)
VALUES (?, ?, ?, 'Open', ?, 'Hardware', ?, ?, ?, ?)"
);
foreach ($tickets as [$id, $title, $description, $type, $priority]) {
$hash = hash('sha256', 'tinker-ui-seed-' . $id);
$insert->bind_param('sssissss', $id, $title, $description, $priority, $type, $hash, $created, $created);
$insert->execute();
}
$addComment = $db->prepare(
"INSERT INTO ticket_comments (ticket_id, user_name, comment_text, markdown_enabled, created_at)
VALUES ('100000001', 'Seed User', ?, 1, ?)"
);
$addComment->bind_param('ss', $comment, $created);
$addComment->execute();
echo 'seeded ' . count($tickets) . " tickets into $dbName\n";