Ravindra BagaleCourses & study guides मराठी

Chapter 90: GitHub Actions Deep Dive

DevOps

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

  1. Create a new practice repo (private or public, your choice). Add app.py with a function add(a, b) that returns a + b.
  2. Add test_app.py with one pytest test: assert add(2, 3) == 5.
  3. Add requirements.txt with one line: pytest.
  4. Create the file .github/workflows/lab.yml in the GitHub web editor (or your editor) with the YAML below.
  5. Commit and push. Nothing runs yet, because the only trigger is manual.
  6. Open Actions → lab → Run workflow. Choose note = first try. Click Run workflow.
  7. Watch test (3.13) and test (3.14) run at the same time.
  8. After they pass, report runs. Download the lab-report artifact from the run page.
  9. Break the test on purpose (== 6), push, and run again. See the red X and that report is skipped.
  10. 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 report was 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.

Did you understand? Let us try it once more.