AI Hints
Home›CI/CD with GitHub Actions Tutorial›Building Blocks Practice
CI/CD with GitHub Actions · Lesson 59 of 138

Practice: Debugging a Pipeline

Find the bug.

⏱ 2 min read▶ Video at 1:06:42🎓 Free
Watch this lesson in the CI/CD with GitHub Actions courseWatch on YouTube ↗Full CI/CD with GitHub Actions course

A teammate says, CI is broken, but the tests pass on my machine. Here's their workflow, and its log. Use what you know about reading logs to find the problem.

Practice: Debugging a Pipeline
From the video: Practice: Debugging a Pipeline
  • CI is broken
  • Works on my machine
  • Read the log

The red run

The first step fails. Pip says it can't open requirement dot txt. And the second step, the tests, never ran. So the tests weren't the problem at all. The real cause is in the first red step, as always.

Terminal
run-steps .github/workflows/ci.yml
Workflow: CI  (event: push, branch: main)
Job: test
  ✗ Run pip install -q -r requirement.txt
      ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirement.txt'
      Error: Process completed with exit code 1.
  Job failed

Finding and fixing it

LS shows the real file name, requirements dot txt, with an S. The workflow has a typo. Sed fixes it, and the run is green again. A typo in a file name is one of the most common CI bugs, because it only matters on a clean machine.

Terminal
ls *.txt
requirements.txt
sed -i 's/requirement.txt/requirements.txt/' .github/workflows/ci.yml
run-steps .github/workflows/ci.yml | tail -4
  ✓ Run pytest -q
      ...                                                                                [100%]
      3 passed in 0.01s
  Job succeeded

Works on my machine

When something passes locally but fails in CI, think about what's different. CI starts clean, so missing files, untracked files, and typos show up. It may use a different version of Python or a library. And it has no secrets you didn't give it. List the differences, and test each one.

keyvalue
Clean machineno leftover files
VersionsPython, libraries
Secrets, envonly what you set
Typospaths, names

Summary

Read the first failing step, compare the machines, and the bug usually appears. Next, a quiz on the building blocks.

Key takeaways
  • First red step
  • CI starts clean
  • Check names and paths
Next up: Building Blocks Quiz — test yourself