This is a learning repository that walks you through a clean, real-world CI/CD flow using a tiny Python calculator.
Simple Version (ELI5): Think of it like a school project with a smart checklist:
- Developer Flow: You make changes on your computer and run the calculator/tests.
- Pre-commit Hooks: A friendly gatekeeper checks your work before it gets saved.
- PR Review + CI Workflows: A robot team re-checks everything in GitHub before merge.
- Internal CI Tweaks: Extra speed + reporting tricks make the robot team fast and helpful.
Technical Version (for developers):
| Stage | What Happens | Tools Used |
|---|---|---|
| Developer flow | Local dev + tests before push | Python + pytest |
| Pre-commit hooks | Security + linting + formatting | pre-commit + Ruff + Gitleaks |
| PR review & CI workflows | Parallel/sequential jobs, coverage & security gates | GitHub Actions + Codecov + CodeQL + Bandit |
| Internal CI tweaks | Caching + report history + artifacts | Actions cache + Allure + GitHub Pages |
Live Demo: Test Reports on GitHub Pages
- What is This?
- The 4-Stage Learning Path
- π Start Learning
- Quick Start
- Project Structure
- Documentation
- π οΈ Awesome GitHub Tools
- Contributing
An instructional repository that teaches professional CI/CD through hands-on practice with a simple Python calculator.
β Python project structure and testing β Pre-commit hooks for code quality β GitHub Actions CI/CD pipelines β Enterprise features (Allure, caching, quality gates)
Perfect for: Students, bootcamp grads, developers learning DevOps.
This repository teaches CI/CD in 4 progressive stages:
1. Developer Flow
β Write code locally, run tests
2. Pre-commit Hooks
β Automatic quality checks before commits
3. CI/CD Workflows
β Automated testing in the cloud
4. Advanced Features
β Enterprise reporting, caching, quality gates
Total learning time: ~70 minutes
Follow the step-by-step guides in order:
| # | Guide | Time |
|---|---|---|
| 1 | Getting Started | 5 min |
| 2 | Understanding the Code | 10 min |
| 3 | Running Tests | 10 min |
| # | Guide | Time |
|---|---|---|
| 4 | Pre-commit Hooks | 10 min |
| # | Guide | Time |
|---|---|---|
| 5 | CI/CD Basics | 15 min |
| # | Guide | Time |
|---|---|---|
| 6 | Advanced Features | 20 min |
π Begin with Guide 1: Getting Started
For those who want to jump right in:
Option A: Using pip (traditional)
# Install dependencies
pip install -r requirements.txt
# Run calculator
python -m src.calculator
# Run tests
pytestOption B: Using uv (modern & fast) β‘
# Install dependencies (creates venv automatically)
uv sync --dev
# Run calculator
uv run python -m src.calculator
# Run tests
uv run pytestOption A: Using pip
pip install pre-commit
pre-commit installOption B: Using uv
uv sync --dev # Includes pre-commit
pre-commit installpytest --alluredir=allure-results
allure serve allure-resultsThis is a learning repository! Here are key insights about CI/CD concepts demonstrated in this project.
This project demonstrates a sophisticated 8-job pipeline with parallel and sequential stages:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STAGE 1: PARALLEL β
β (all three jobs start simultaneously) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββ ββββββββββββ βββββββββββββββ
β π Lint β βπSecurityβ βπ§ͺ Unit Testsβ
ββββββ¬βββββ ββββββ¬ββββββ ββββββββ¬βββββββ
β β β
ββββββββββββββββΌββββββββββββββββββ
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STAGE 2: DOCKER β
β (only runs if Dockerfile/src/requirements changed) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββ
βπ Check Changesβ
βββββββββ¬ββββββββ
β
βΌ
βββββββββββββββββ
βπ³ Docker Buildβ
βββββββββ¬ββββββββ
β
βΌ
βββββββββββββββββ
βπ¨ Smoke Test β
βββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STAGE 3: REPORT & DEPLOY β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββ
βπ Report β
ββββββ¬ββββββ
β
βΌ
ββββββββββββ
βπ Deploy β
ββββββββββββ
β Insight: Quality + Security Gate βββββββββββββββββββββββββ
Tool Focus Why It Matters Codecov Code quality "Are you testing enough?" - tracks coverage trends CodeQL Security "Is your code safe?" - finds vulnerabilities automatically Together they form a quality + security gate that catches both coverage regressions and vulnerabilities before merge.
# These lines are excluded from coverage (standard practice): if __name__ == "__main__": main()Why?
- Interactive CLI code (
input(),print()) is meant for human interaction, not unit tests- Testing these requires mocking stdin/stdout - low value, high complexity
- The core logic (Calculator class) is what matters - and that's at 100%
- This is standard practice in Python projects (Django, Flask, etc.)
β Insight: GitHub Copilot Code Review βββββββββββββββββββββ
Custom instructions in
.github/copilot-instructions.mdtell Copilot what's important for YOUR project:
- Without context: Copilot reviews can be noisy with false positives
- With instructions: Focused reviews on what actually matters
- Think of it as: Giving a human reviewer onboarding docs
Concept How It Works Parallel jobs Jobs without needs:start immediately togetherSequential jobs Jobs with needs: [job1, job2]wait for ALL listed jobsRunners Each parallel job gets its own fresh VM Total time max(parallel jobs) + sequential jobsExample from this repo:
# These run in PARALLEL (no needs:) lint: runs-on: ubuntu-latest security: runs-on: ubuntu-latest # This waits for BOTH to complete test: needs: [lint, security] # Won't start until both finish
Cache What It Stores Invalidates When pip cache Downloaded Python packages requirements.txtchangespytest cache Test collection data Test files change Result: First run ~45s, subsequent runs ~15s (3x faster!)
simple-calculator/
βββ guides/ # π Step-by-step learning (START HERE!)
βββ src/ # π§ Calculator code
βββ tests/ # β
Test code
βββ docs/ # π Deep-dive documentation
β βββ assets/ # π¨ Images
βββ .github/workflows/ # π€ CI/CD automation
βββ prompts/ # π§© Copy-paste CI/CD prompts
See docs/reference/STRUCTURE.md for details.
- π Learning Guides - Progressive 6-guide learning path (~70 min)
- ποΈ ARCHITECTURE.md - Complete system overview
- π CI-CD.md - CI/CD insights & best practices
- π ALLURE.md - Enterprise test reporting
- π GITHUB-PAGES.md - Free hosting setup
- π§ͺ TESTING.md - pytest testing guide
- β‘ UV.md - Fast package manager
- π§ TROUBLESHOOTING.md - Common issues
- π§© Prompts - Copy-paste CI/CD setup for your repos
- π€ Copilot Spaces - Interactive AI-powered exploration of this repository (requires Copilot licensing)
- π¬ GitMCP Chat - Chat with this repository using GitMCP
Enhance your GitHub workflow with these helpful tools:
-
π± GitHub Mobile App - Official GitHub app for iOS and Android. Manage repositories, review code, and respond to issues on the go.
-
π¨ GitHub Material Design Chrome Extension - Apply Material Design styling to GitHub's interface for a modern, polished look.
-
β‘ Refined GitHub - Browser extension that simplifies the GitHub interface and adds 200+ useful features including linkified references, reaction avatars, merge conflict fixers, and more. Available for Chrome and Firefox.
-
π€ GitHub MCP - Model Context Protocol server for GitHub integration, enabling AI assistants to interact with GitHub repositories, issues, and pull requests through the MCP framework.
- Fork the repository
- Create a feature branch
- Make your changes
- Run
pytestandpre-commit run --all-files - Submit a pull request
CI will automatically test your changes.
This project is for educational purposes.
π Start with Guide 1: Getting Started
Learn professional CI/CD practices through hands-on experience!
