Lab 1 of 8 · Foundations: Linux, Git and Python
Create your project and push it to GitHub
Build a tiny web service with a health check and a test, and publish it to your own GitHub repository.
- Time
- 60–90 minutes
- Cost
- Free.
What you learn
Everything in DevOps runs on Linux, lives in Git and is glued together with scripts. In this lab you set up your tools and create the project you will grow for the rest of the roadmap.
- The terminal: moving around, files and folders
- Git: commit, push, and why history matters
- Python virtual environments and dependencies
- Writing and running an automated test
In the AI era: AI assistants write a lot of code now. Your job is to read it, test it and keep it in Git so every change can be reviewed and undone. That starts here.
Before you start
Windows: install WSL (Ubuntu) and run every command inside the Ubuntu terminal. Mac and Linux: use the Terminal app.
Install Git and Python 3.11 or newer. Check with
git --versionandpython3 --version.Create a free account at github.com.
Step by step
1 Create an empty repository on GitHub
Go to github.com/new. Name it
ai-status-app, choose Public, tick "Add a README file", and click Create repository. Then copy its address from the green Code button.2 Clone it to your computer
Replace YOUR-USERNAME with your GitHub username.
cdmoves you into the new folder.git clone https://github.com/YOUR-USERNAME/ai-status-app.git cd ai-status-app pwd ls -laYou should see:The path ends in
ai-status-app, and you seeREADME.mdand a hidden.gitfolder.3 Create the folders and a Python environment
A virtual environment keeps this project's packages separate from the rest of your computer. Run
source .venv/bin/activateagain whenever you open a new terminal.mkdir -p app tests touch app/__init__.py tests/__init__.py python3 -m venv .venv source .venv/bin/activateYou should see:Your prompt now starts with
(.venv).4 List the dependencies
Create this file in the project folder. Pinning versions means the project builds the same way next month.
fastapi==0.115.6 uvicorn==0.34.0 httpx==0.28.1 pytest==8.3.45 Install them
This downloads the packages into
.venv.pip install -r requirements.txtYou should see:The last line starts with
Successfully installed.6 Write the web service
FastAPI turns Python functions into web endpoints.
/healthis the endpoint every load balancer and Kubernetes cluster will check.from fastapi import FastAPI app = FastAPI(title="AI Status App") @app.get("/health") def health() -> dict[str, str]: return {"status": "ok"} @app.get("/") def home() -> dict[str, str]: return {"message": "Hello from my DevOps project"}7 Run it
Start the server, then open http://127.0.0.1:8000/health in your browser. Press Ctrl+C in the terminal to stop it.
uvicorn app.main:app --reload --port 8000You should see:The browser shows
{"status":"ok"}.8 Write a test
Tests let a machine check your work on every change. This one calls
/healthwithout starting a server.from fastapi.testclient import TestClient from app.main import app client = TestClient(app) def test_health() -> None: response = client.get("/health") assert response.status_code == 200 assert response.json() == {"status": "ok"}9 Run the test
Run it from the project folder with the virtual environment active.
python -m pytest -qYou should see:1 passed.10 Tell Git what to ignore
Never commit your virtual environment, caches or secrets.
.venv/ __pycache__/ .pytest_cache/ .env11 Commit and push
If Git asks for a password, GitHub needs a token instead: follow the "caching your credentials" link below, or install the GitHub CLI and run
gh auth login.git add . git commit -m "Add FastAPI app with health check and test" git pushYou should see:Refresh your repository on GitHub: you see the
appandtestsfolders.
You are done when
Your GitHub repository has
app/main.py,tests/test_main.py,requirements.txtand.gitignore.python -m pytest -qprints1 passed.You can explain what
git add,git commitandgit pusheach do.
We check your public GitHub repository and give you a page to share with recruiters, and can add the project to your resume.