Skip to main content

CI, Logging and a Human Fallback

Why This Matters

Tests on your laptop protect only you. An automation that books orders runs every day, unattended. It needs three things: tests that run automatically on every change, logs that tell an operator what happened, and a way for humans to take over.

Tests on every change

The project runs its tests on GitHub Actions, in .github/workflows/tests.yml:

on:
  pull_request:
  push:
    branches: [main]

jobs:
  pytest:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.10", "3.13"]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          cache: pip
      - run: pip install -r requirements-dev.txt
      - run: python -m pytest -v

On every pull request, all tests run on the oldest and newest Python the project supports. A red check means: do not merge.

Logs an operator can use

The pipeline logs one line per decision, with the reason:

INFO    order PO-20417 booked as ERP-1001 (total 2848.80)
WARNING order PO-20418 needs review: BAG-30L: price 71.00 differs 10% from catalog 64.50
ERROR   extraction failed: Could not read the LLM answer as an order: ...

Good automation logs answer three questions without opening the code: which message, what was decided, and why. Never log secrets such as API keys, and think twice about personal data in emails.

A human fallback

Production needs answers to these questions, written down before go-live:

QuestionFor Order Intake Bot
Where do needs_review orders go?A queue or mailbox the purchasing team checks daily
Who is alerted on failed?The process owner, by e-mail or chat, with the log line
What if the bot is down for a day?The team books by hand, as before; nothing is lost because the emails stay in the inbox
Who changes a rule?The process owner decides; a developer changes validate.py with a test
How do we know it still works?CI on every change, and a weekly check of booked versus reviewed orders

Where to go next

Exercise

  1. Fork the project on GitHub, enable Actions, and open a pull request that breaks the price rule (as in lesson 8, Testing Business Rules: Boundaries and Breaking It on Purpose). Watch CI turn red, read the log, fix it, and watch it turn green.
  2. Write the fallback table for the automation you mapped in lesson 4, From a Process to Code.
  3. Decide which three log lines an operator of your automation would need most, and check that your design produces them.

Key Takeaways

  • Run the tests on every change, on the Python versions you support.
  • Log every decision with its reason, never secrets.
  • Agree before go-live where reviews go, who is alerted and what happens when the bot is down.
  • Automation is only finished when people can trust it and take over when needed.