Roadmaps / DevOps & Cloud / Lab 1

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 --version and python3 --version.

  • Create a free account at github.com.

Step by step

  1. 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. 2 Clone it to your computer

    Replace YOUR-USERNAME with your GitHub username. cd moves you into the new folder.

    Run this
    git clone https://github.com/YOUR-USERNAME/ai-status-app.git
    cd ai-status-app
    pwd
    ls -la
    You should see:

    The path ends in ai-status-app, and you see README.md and a hidden .git folder.

  3. 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/activate again whenever you open a new terminal.

    Run this
    mkdir -p app tests
    touch app/__init__.py tests/__init__.py
    python3 -m venv .venv
    source .venv/bin/activate
    You should see:

    Your prompt now starts with (.venv).

  4. 4 List the dependencies

    Create this file in the project folder. Pinning versions means the project builds the same way next month.

    File: requirements.txt
    fastapi==0.115.6
    uvicorn==0.34.0
    httpx==0.28.1
    pytest==8.3.4
  5. 5 Install them

    This downloads the packages into .venv.

    Run this
    pip install -r requirements.txt
    You should see:

    The last line starts with Successfully installed.

  6. 6 Write the web service

    FastAPI turns Python functions into web endpoints. /health is the endpoint every load balancer and Kubernetes cluster will check.

    File: app/main.py
    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. 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.

    Run this
    uvicorn app.main:app --reload --port 8000
    You should see:

    The browser shows {"status":"ok"}.

  8. 8 Write a test

    Tests let a machine check your work on every change. This one calls /health without starting a server.

    File: tests/test_main.py
    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. 9 Run the test

    Run it from the project folder with the virtual environment active.

    Run this
    python -m pytest -q
    You should see:

    1 passed.

  10. 10 Tell Git what to ignore

    Never commit your virtual environment, caches or secrets.

    File: .gitignore
    .venv/
    __pycache__/
    .pytest_cache/
    .env
    
  11. 11 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.

    Run this
    git add .
    git commit -m "Add FastAPI app with health check and test"
    git push
    You should see:

    Refresh your repository on GitHub: you see the app and tests folders.

You are done when

  • Your GitHub repository has app/main.py, tests/test_main.py, requirements.txt and .gitignore.

  • python -m pytest -q prints 1 passed.

  • You can explain what git add, git commit and git push each do.

Finished? Get your proof page

We check your public GitHub repository and give you a page to share with recruiters, and can add the project to your resume.