Capstone: Build, Test, PushΒΆ
You have built a complete Continuous Integration pipeline, one station at a time. This capstone proves it works end to end by shipping a real new feature through it, with no step-by-step hand-holding this time. You know how to do each piece now. πͺ
The goalΒΆ
Add a new feature to the Snapshot app, cover it with a test, and push. Your pipeline should test it, build the image, and publish it, all green, all on its own.
Your taskΒΆ
- Add a health check endpoint at
/healththat returns{"status": "ok"}. - Add a test that confirms
/healthresponds correctly. - Commit and push, then watch the pipeline run the whole belt: test, build, publish.
You should not need to change the workflow at all. The pipeline you built already does everything. That is the point.
HintsΒΆ
- The new route goes in
app.py, alongside the existing one. - The new test goes in
test_app.py, using the sameapp.test_client()pattern. - After pushing, watch the Actions tab, then check Packages for the updated image.
Give it a real try before opening the solution below.
Reference solution
Add to app.py:
Add to test_app.py:
def test_health_returns_ok():
client = app.test_client()
response = client.get("/health")
assert response.status_code == 200
assert response.get_json() == {"status": "ok"}
Then push:
The pipeline runs 3 passed, builds, and publishes the updated image.
β Success criteriaΒΆ
You have completed the beginner track if:
- The app has a working
/healthendpoint - A new test covers it, and the pipeline reports
3 passed - The build and publish steps run only after the tests pass
- The updated image appears under Packages
π What you've builtΒΆ
Look at what your pipeline now does, entirely on its own, every time you push:
- Runs your tests
- Stops immediately if any test fails
- Builds the Docker image
- Publishes it to the registry
That is real Continuous Integration. You never build, test, or publish by hand again.
Next up: the Intermediate track, where the pipeline stops just publishing images and starts deploying them, automatically, to a real server.