Chapter 90: GitHub Actions Deep Dive
90.10 Lab — manual test-and-artifact workflow
Story (fictional teaching scenario). You are training juniors at a Razorpay-style payments team. Fatima from Cairo and Rohit from Nagpur each create a practice repo in their own account. Every piece is safe and nearly free on a public practice repo (minutes on private repos are billed after the free quota, approximate, check GitHub's billing page). You will build one workflow that you start by hand, test on two Python versions (3.13 and 3.14), and save a report as an artifact.
Lab steps
- Create a new practice repo (private or public, your choice). Add
app.pywith a functionadd(a, b)that returnsa + b. - Add
test_app.pywith one pytest test:assert add(2, 3) == 5. - Add
requirements.txtwith one line:pytest. - Create the file
.github/workflows/lab.ymlin the GitHub web editor (or your editor) with the YAML below. - Commit and push. Nothing runs yet, because the only trigger is manual.
- Open Actions → lab → Run workflow. Choose
note=first try. Click Run workflow. - Watch
test (3.13)andtest (3.14)run at the same time. - After they pass,
reportruns. Download thelab-reportartifact from the run page. - Break the test on purpose (
== 6), push, and run again. See the red X and thatreportis skipped. - Fix the test. Run once more. Delete the practice repo when you are done if you do not need it.
Lab workflow
name: lab
on:
workflow_dispatch:
inputs:
note:
description: "A short note for the report"
default: "practice"
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.13", "3.14"]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
cache: pip
- run: pip install -r requirements.txt
- run: pytest -q
report:
needs: test
runs-on: ubuntu-latest
steps:
- run: echo "Tests passed. Note - ${{ inputs.note }}" > report.txt
- uses: actions/upload-artifact@v7
with:
name: lab-report
path: report.txt
retention-days: 3
Output (illustrative) (good run)
test (3.13) ✓ 1 passed
test (3.14) ✓ 1 passed
report ✓ Artifact lab-report uploaded
What it shows: Manual trigger, matrix, needs, cache and artifact, all in one small file.
What good looks like
- You can start the workflow by hand and pass an input.
- You saw a failed run and understood why
reportwas skipped. - You downloaded the artifact and read the note.
- No real secret or cloud key was used anywhere.
Do the lab twice. First copy it. Second time, type it yourself without looking. That is when you really learn it.
Lab दोन वेळा करा. पहिल्यांदा copy करा. दुसऱ्यांदा न बघता स्वतः type करा. तेव्हाच खरं शिकता.
Lab दो बार करो. पहली बार copy करो. दूसरी बार बिना देखे खुद type करो. तभी सच में सीखते हो.
Did you understand? Let us try it once more.