AI Hints
CI/CD with GitHub Actions · Lesson 23 of 138

checkout

Getting your code.

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

Here's a surprise for many beginners. A runner starts completely empty. Your code isn't on it. If you forget the checkout step, your test command will fail, because there are no files to test.

checkout
From the video: checkout
  • A runner starts empty
  • Your code isn't there
  • Checkout fetches it

An empty runner

Let's act like a fresh runner. We're in an empty folder, called runner. LS dash A shows nothing at all. So pytest finds no tests, and exits with code five. That's what happens in CI without checkout.

Terminal
ls -A
pytest -q; echo "exit code $?"
no tests ran in 0.00s
exit code 5

What checkout does

The checkout action basically clones your repository, at the exact commit that started the run. Here, git clone copies the shop repository into the runner folder. Now the files are there, and the tests pass. On GitHub, actions checkout does this for you, including authentication.

Terminal
git clone -q ~/shop .
ls
README.md  app.py  requirements.txt  test_app.py
pytest -q
...                                                                                [100%]
3 passed in 0.01s

Summary

Runners start empty, so almost every workflow begins with actions checkout, which fetches your code at the right commit. Next, installing Python.

Key takeaways
  • Runners start empty
  • actions/checkout@v4
  • Always first
Next up: setup-python — the right version