CDX-301c · Module 2
Style Enforcement & Test Generation
3 min read
Style enforcement via Codex fills the gap between what linters catch and what code reviewers comment on. Linters enforce syntax rules (semicolons, quotes, spacing). Codex enforces semantic style rules (consistent error handling patterns, naming conventions for domain concepts, import organization by category). These semantic rules are too complex for AST-based linters but straightforward for a language model that understands context.
Test generation is the highest-ROI CI automation pattern. When a PR adds new code without tests, Codex can generate test stubs that cover the happy path, error cases, and edge cases. The generated tests are not production-ready — they need human review — but they eliminate the blank-page problem and enforce the team standard that every PR includes tests. The key is generating test skeletons (describe/it blocks with assertions) rather than complete tests, so the author fills in the domain-specific details.
name: Codex Test Generation
on:
pull_request:
types: [opened, synchronize]
jobs:
suggest-tests:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install -g @openai/codex
- name: Check for untested code
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
# Find new/modified source files without corresponding test files
CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD \
| grep -E '\.(ts|tsx)