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:
- 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)
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:
- Check out passed
- Set up Python
- Install
- ruff check
- pytest
- ▶ running
Add the CI workflowYou
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:
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 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:
# Pila  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:
.github/workflows/ci.ymlname: 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
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.
- GitHub Docs: Quickstart for GitHub Actions: a first workflow, step by step
- GitHub Docs: Building and testing Python: setting up Python and running pytest
- GitHub Docs: Adding a workflow status badge: the badge’s address
- GitHub Docs: About protected branches: requiring status checks before merging
- Ruff documentation: the linter the pipeline runs