GitHub Foundations — Question 4
As a developer, you need to leverage Redis in your workflow. What is the best way to use Redis on a self-hosted Linux runner without affecting future workflow runs?
Answer options
- A. Install Redis on the hosted runner image and place it in a runner group. Specify label: in your job to target the runner group.
- B. Set up Redis on a separate machine and reference that instance from your job.
- C. Specify container: and services: in your job definition to leverage a Redis service container.
- D. Add a run step to your workflow, which dynamically installs and configures Redis as part of your job.
Correct answer: C
Explanation
The correct answer is C because using the container: and services: options allows you to run Redis in an isolated environment specific to that job, ensuring it does not affect other runs. Option A is incorrect as installing Redis on the runner image could lead to conflicts in future runs. Option B is less efficient because it involves managing a separate machine, and option D introduces unnecessary complexity by dynamically installing Redis during the job.