Lesson 6 of 9 · 24m
Testing, Linting, and Single-Binary Builds
Build a reliable Deno delivery pipeline with permission-aware tests, static checks, cross-compilation, and artifact verification.
Deno's toolchain makes CI look deceptively small. The danger is that teams stop after deno test because the command exists and exits zero. Production quality comes from permission-aware tests, type checking, dependency freezing, artifact validation, and knowing exactly what a compiled binary still depends on.
Tests should mirror runtime permissions
A useful test command is explicit:
deno test --allow-read=test/fixtures --allow-net=127.0.0.1:5432 --allow-env=DATABASE_URL --coverage=coverageDo not run the entire suite with broad permissions because one integration test needs them. Split unit and integration tasks when necessary. Broad test permissions hide accidental filesystem or network use in code that should have stayed pure.
Static checks are part of runtime truth
CI should normally include:
deno fmt --check
deno lint
deno check main.ts
deno cache --frozen main.ts
deno test --frozenEach catches a different class of failure. Formatting protects review quality. Lint catches suspicious patterns. Type checking catches invalid assumptions. Frozen caching catches dependency drift. Tests catch behavior, if your tests are good enough.
deno compile is packaging, not magic isolation
deno compile --output dist/image-service --allow-read=/var/lib/images --allow-net=metadata.internal:443 main.tsThe binary embeds the runtime and application graph, but it is not a container. It still runs with the operating system user's ambient authority outside Deno's permission model. It also does not automatically include every file you read dynamically. Embedded assets and runtime-discovered paths are different things; test the binary from a clean directory.
Cross-compilation needs realistic validation
deno compile --target x86_64-unknown-linux-gnu --output dist/service-linux main.tsCompilation succeeds more often than production execution. Validate on the target OS, CPU architecture, libc environment, permission flags, and filesystem layout. Native npm dependencies complicate this because compatibility is determined by the runtime environment, not merely the compile target.
Make artifact verification part of the pipeline
Record version metadata and smoke-test the artifact:
./dist/service-linux --version
./dist/service-linux --check-config
sha256sum dist/service-linux > dist/service-linux.sha256If configuration loading, TLS roots, timezone data, or asset resolution fail only in production, your pipeline verified the wrong thing.
Field notes
- Split unit and integration permissions; broad test permissions conceal coupling.
deno compiledoes not sandbox memory, CPU, syscalls, or user-level file access.- Dynamic file reads may need real runtime files even if compilation succeeds.
- Keep the exact Deno version used for compiled releases reproducible.
- Coverage is evidence of execution, not proof of correctness; use it to find untested seams, not to chase ceremony.
Was this lesson helpful?