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

73 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
# Starts one Tinker Tickets instance for the UI tests on a fresh database:
#
# tests/ui/stack.sh <checkout-dir> <port> <db-name>
#
# Creates the database, writes the checkout's .env (throwaway values only),
# applies the checkout's migrations, loads the synthetic seed
# data and serves the checkout with PHP's built-in server. The seed and router
# always come from this script's directory, so the same data goes into the
# base branch's checkout for before/after screenshots.
#
# Needs a MariaDB on 127.0.0.1 with a 'tinker_ui' user (tests/ci/setup.sh in
# CI) and root access to it over the local socket. Logs go to
# <checkout>/.ui-stack/server.log.
set -euo pipefail
CHECKOUT=$(cd "${1:?checkout dir}" && pwd)
PORT=${2:?port}
DB=${3:?database name}
HERE=$(cd "$(dirname "$0")" && pwd)
case "$DB" in
tinker_ui*) ;;
*) echo "refusing: database name must start with tinker_ui" >&2; exit 2 ;;
esac
mariadb -e "DROP DATABASE IF EXISTS \`$DB\`; CREATE DATABASE \`$DB\`;
GRANT ALL ON \`$DB\`.* TO 'tinker_ui'@'127.0.0.1';"
if [ -e "$CHECKOUT/.env" ] && ! grep -q "^; tinker-ui-stack" "$CHECKOUT/.env"; then
echo "refusing: $CHECKOUT/.env exists and was not written by this script" >&2
exit 2
fi
cat > "$CHECKOUT/.env" <<EOF
; tinker-ui-stack: throwaway UI test settings, safe to delete
DB_HOST=127.0.0.1
DB_USER=tinker_ui
DB_PASS=ci-only
DB_NAME=$DB
LDAP_ENABLED=false
TIMEZONE=UTC
; One client IP makes every request in a test run; the default limits would
; turn later pages into 429s.
RATE_LIMIT_DEFAULT=100000
RATE_LIMIT_API=100000
RATE_LIMIT_IP=100000
RATE_LIMIT_IP_API=100000
EOF
# This branch's migration runner, run from inside the checkout so it reads
# that checkout's config and migrations: a base branch with an older runner
# (before the comment fix) still gets its schema.
cp "$HERE/../../migrations/migrate.php" "$CHECKOUT/migrations/.ui-migrate.php"
php "$CHECKOUT/migrations/.ui-migrate.php"
rm -f "$CHECKOUT/migrations/.ui-migrate.php"
DB_NAME=$DB php "$HERE/seed.php"
mkdir -p "$CHECKOUT/.ui-stack"
(cd "$CHECKOUT" && setsid php -S "127.0.0.1:$PORT" -t . "$HERE/router.php" \
> "$CHECKOUT/.ui-stack/server.log" 2>&1 &)
for _ in $(seq 1 30); do
code=$(curl -s -o /dev/null -w '%{http_code}' -H 'Remote-User: ci.tester' -H 'Remote-Name: CI Tester' \
-H 'Remote-Email: [email protected]' -H 'Remote-Groups: admin' "http://127.0.0.1:$PORT/" || true)
if [ "$code" = 200 ]; then
echo "Tinker Tickets ($CHECKOUT) on http://127.0.0.1:$PORT, database $DB"
exit 0
fi
sleep 1
done
echo "::error::Tinker Tickets did not answer on port $PORT (last HTTP ${code:-none})"
tail -n 50 "$CHECKOUT/.ui-stack/server.log" || true
exit 1