An AI-written function can look convincing and still charge delivery on the one order that should be free. GitHub Actions gives you a place to run the same checks whenever code changes. The useful result is a test log tied to a particular revision of your code.

We will use a fictional bakery’s online checkout: delivery costs 50 baht below 500 baht and becomes free at 500 baht. There is no real customer data, payment service or deployment in this exercise.

What was verified: our Python 3.12 exercise was run locally: the starter fails one of eight tests, and the corrected version passes all eight. We deliberately inserted the starter’s boundary mistake; this is not a measurement of how often an AI makes errors. The GitHub screens below come from one continuous official demonstration, which creates an issue-labeling workflow and checks its real output. We have not run the bakery workflow on GitHub-hosted runners.

Find the workflow controls

You need a GitHub account, a practice repository you can edit, and Actions enabled for it. Sign in and open the repository’s Actions tab. If workflows already exist, choose New workflow. The Python application template is available through the workflow search. You can also create a YAML file yourself. Use a practice branch so you can review the changes.

GitHub’s recorded walkthrough: choose a workflow or start your own.
GitHub’s recorded walkthrough: choose a workflow or start your own. GitHub · 1:59

Our example needs no AI API key and no Python packages to install. Check the account’s GitHub billing and usage controls before starting hosted jobs, especially in a private repository. Included compute and extra charges depend on the plan and runner; this guide does not promise unlimited free runs. The sales channel for those charges is your GitHub billing account, not the AI assistant used to write the code.

Follow a real workflow from input to checked output

GitHub’s video offers a short interface tour. Follow the same demonstration through these stages: create the YAML file, define an issue-opened trigger, supply a new issue, then open the result and the job details. The example adds a label; our bakery exercise later replaces that operation with a test command.

The same walkthrough: begin a YAML file inside .github/workflows.
The same walkthrough: begin a YAML file inside .github/workflows. GitHub · 3:34
The completed issue-labeling configuration. Its write permission is for adding labels; our test exercise only reads repository contents.
The completed issue-labeling configuration. Its write permission is for adding labels; our test exercise only reads repository contents. GitHub · 5:50
Supply the first real input: create the demonstration issue.
Supply the first real input: create the demonstration issue. GitHub · 6:30
Open the resulting issue and check that the triage label actually appeared.
Open the resulting issue and check that the triage label actually appeared. GitHub · 6:36

The important habit is to inspect the result itself. A label appearing on the issue proves that particular action took effect. For tests, the equivalent evidence is the test names, count and outcome in the job log.

Open Actions and choose the relevant workflow run; queued is not completed.
Open Actions and choose the relevant workflow run; queued is not completed. GitHub · 6:49
Open the job and inspect its completed steps. This is GitHub’s label-issues job, not a bakery test run.
Open the job and inspect its completed steps. This is GitHub’s label-issues job, not a bakery test run. GitHub · 6:56

Give the AI a rule you can independently check

Start with a small request. Here is a reusable prompt; compare an assistant’s response against the rule, rather than accepting the tests just because the same assistant wrote them.

Write delivery.py for a fictional bakery's online checkout. Accept only a non-negative integer amount in Thai baht; reject bool, strings and fractional amounts. Delivery costs 50 baht below 500 baht and is free at 500 baht or more. Write eight unittest tests covering 0, 499, 500, 501, -1, "500", 499.5 and True. Use only Python's standard library. Explain which business rule each test checks. Do not change the tests to hide a failure. Provide a minimal GitHub Actions workflow that runs the tests on pushes and pull requests, with read-only repository permissions and no secrets or deployment.

The three values around the threshold do most of the teaching:

Cart total Expected fee Why check it?
499 baht 50 baht Just below free delivery
500 baht 0 baht The exact boundary
501 baht 0 baht Just above the boundary

The remaining cases cover zero and four invalid inputs. This simplified function accepts whole-baht totals only. A real checkout that accepts satang needs a different amount representation and more tests.

Run the practice files, then add the workflow

Download the starter, corrected version, bilingual prompts and actual local test logs. Unzip it. Inside starter, run the command below in a terminal. Use python3 if that is your local Python command.

python -m unittest discover -s tests -v

The starter intentionally uses > 500, so the 500-baht test fails: the function returns 50 where the test expects zero. The saved local log reports eight tests with one failure.

To try it on GitHub, copy the contents of starter into the root of your practice repository. Include the hidden .github folder. The layout should be:

delivery.py
tests/test_delivery.py
tests/__init__.py
.github/workflows/tests.yml

Do not upload the ZIP as one file or put an extra starter/ directory around these paths. If you use GitHub’s web editor, create each file with its full path. Commit and push on your practice branch. The supplied workflow is:

name: Bakery delivery tests
on: [push, pull_request]
permissions:
  contents: read
jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 checked 2026-11-24
        with:
          persist-credentials: false
      - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 checked 2026-11-24
        with:
          python-version: '3.12'
      - name: Run delivery tests
        run: python -m unittest discover -s tests -v

on chooses the events; test names the job; runs-on chooses its machine; and the last step runs the test command. Checkout obtains your code and setup-python selects Python 3.12. The long action identifiers pin the official action revisions we checked on 24 November 2026. They are not passwords. Review upstream changes before updating them.

This file has no deployment step or secret input. Read-only permissions and disabled persisted checkout credentials limit access; they do not make arbitrary code safe. Review AI-written commands before committing them. Both push and pull-request events can produce runs for the same change.

Open the failure, fix the rule, check the new run

After pushing, open Actions → Bakery delivery tests → the matching run → test → Run delivery tests. Check the branch and commit first. In this exercise the expected first failure is test_exact_threshold. Open that step’s output and confirm eight tests actually ran. A result with zero discovered tests does not validate this example.

Correct only the condition in delivery.py:

return 0 if total_baht >= 500 else 50

Run the same command locally, commit the fix and push it. Inspect the new revision’s run on GitHub. Re-running the old failed run does not pick up an uncommitted correction on your computer. Our corrected local run reports:

Ran 8 tests

OK

That is a local result from the downloadable example, not a captured GitHub Actions result. The GitHub workflow is ready for your own hosted trial. If it fails before the test step, inspect the setup error instead of editing the business-rule tests. If no run appears, check the YAML path, branch, Actions availability and repository policy.

Decide what passing tests really establish

Eight green tests establish eight checked behaviors. They do not check discounts, multiple delivery areas, a checkout screen, security, or payment integration. Before using this function, list the missing rules and add tests for them.

A passing workflow also does not automatically prevent someone merging a pull request. Required status checks are a separate repository-policy decision. Keep human review: read the changed lines, check the test output for the current revision, and decide whether the tests cover the promised behavior. This exercise stops at testing; publication of a website is a separate step.

Related: reviewing AI-written code in a pull request. If you are still learning Git, work through the repository and branch steps before adding automation.

Sources and evidence

Product documentation checked 24 November 2026. Recorded interface images: GitHub’s official video, with source moments linked in each caption. Cover: a Gemini-generated illustration of a fictional bakery. Practice code and logs: original local exercise; no hosted CI result is claimed.