Capstone: Pila 1.2 · lesson 7 of 9
Ideas in this lesson
A.github/workflows/ci.yml7.2: continuous integration
BStatus badgethe latest run, on the README
CRequired check7.5: nothing merges red

Pipeline

Last updated

You're operations now. So far you've run the checks yourself, which works until the day you forget. In this lesson you'll make GitHub run them on every push and every pull request, watch a run go red and then green, put the result on the front page of your repository, and make the checks a rule that main can't skip.

By the end of this lesson you can

  • Write a GitHub Actions workflow that lints and tests every push
  • Read a failed run and fix what it found
  • Show the pipeline’s status in the README, and require it before merging

Write the workflow

A GitHub Actions workflow is a YAML file in .github/workflows/. Write Pila's:

CI workflowKept in this browser only
  • Runs on push and pull requests (done)
  • Checks out the code (not yet)
  • Sets up Python (not yet)
  • Installs pytest and ruff (not yet)
  • Runs ruff (not yet)
  • Runs pytest (not yet)
Write each part until its checks pass.

Save it as .github/workflows/ci.yml, on a branch, and commit it. YAML is fussy about indentation: two spaces per level, never tabs.

Push it, and watch

Push the branch and open a pull request. On GitHub, open the Actions tab, or the Checks section of the pull request, to watch the run live. This is the same pipeline you played in lesson 7.2, now real:

  1. Check out passed
  2. Set up Python
  3. Install
  4. ruff check
  5. pytest
  • ▶ running Add the CI workflow You
1 of 15 You pushes “Add the CI workflow”. The pipeline starts: Check out.

Without GitHub: the pipeline's job is “nobody merges without the checks”. Make that a habit with a Git hook: a script in .git/hooks/pre-push that runs ruff check . and python -m pytest, and stops the push if either fails. Simple Git's Hooks and checks shows how.

Make it fail, on purpose

Trust a pipeline only once you've seen it catch something. On a new branch, break a test on purpose, for example change an expected date, then push and open a pull request:

Terminal
git switch -c try-a-red-build
git commit -am "Break a test, to see CI fail"
git push -u origin try-a-red-build

Read the failed run's log. When you've seen the red ✕, close that pull request without merging, and delete the branch.

The pipeline is red on your pull request, but the change looks fine to you. What do you do?

The badge

A status badge shows the latest run of a workflow on main. Add one under the title of README.md, using your own user name:

README.md
# Pila

![CI](https://github.com/your-name/pila/actions/workflows/ci.yml/badge.svg)

A queue number by text, for the barangay health centre.

It's a small thing that says something important to anyone who finds the repository: this project checks itself, and right now, it passes.

No merging on red

Make the check a rule (Simple Git's Protecting branches). In your repository's Settings, under Branches or Rules, add a rule for main that requires a pull request and requires the check status to pass before merging.

Checked on 6 December 2026. If the settings have moved, GitHub's page on protected branches, linked below, has the current steps.

Merge the workflow's pull request once it's green. Here's the reference's file:

How the reference does it .github/workflows/ci.yml
name: CI
on: [push, pull_request]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-python@v6
        with:
          python-version: "3.14"
      - run: python -m pip install pytest ruff
      - run: ruff check .
      - run: python -m pytest

Check your pipeline

Why run the checks in a pipeline if you already run them yourself?
Why did you make the pipeline fail on purpose?

Sources

Every claim on this page comes from these sources: the standard, the founding text of a method, a study, or the official record of a project, from the body that publishes it. Industry reports are labelled as such.

All sources for Simple Software Development