#!/usr/bin/env bash # worker — a repo that deploys a Cloudflare Worker keeps its logs and # keeps the worker off the workers.dev hostname. # # The wrangler file is found wherever the repo keeps it (the root, site/, # web/), as wrangler.toml or wrangler.jsonc. The five name patterns below # match the same files; each spelling gives its assertion its own id, so a # deviation entry waives one rule and not the others. . ../_lib.sh contract worker # why: a repo with no wrangler file deploys no worker, and nothing here governs it check_applies_when 'governs repos that deploy a Cloudflare Worker' 'wrangler.toml' 'wrangler.jsonc' # why: a worker deployed without the observability block keeps no request record to read when it misbehaves check_grep 'wrangler.toml' '^\[observability\]|"observability"[[:space:]]*:' 'wrangler.jsonc' # why: the logs table is what turns on persisted logs, separately from the sampled traces above it check_grep 'wrangler.[t]oml' '^\[observability\.logs\]|"logs"[[:space:]]*:' 'wrangler.jsonc' # why: a block left at enabled = false reads as configured and records nothing check_grep 'wrangler.t[o]ml' '^enabled = true|"enabled"[[:space:]]*:[[:space:]]*true' 'wrangler.jsonc' # why: without invocation logs a worker that threw before reaching its own logging leaves no trace check_grep 'wrangler.to[m]l' '^invocation_logs = true|"invocation_logs"[[:space:]]*:[[:space:]]*true' 'wrangler.jsonc' # why: left on, the worker answers on its workers.dev hostname beside its routed domain, an unmonitored second front check_grep 'wrangler.tom[l]' '^workers_dev = false|"workers_dev"[[:space:]]*:[[:space:]]*false' 'wrangler.jsonc' report