You need to run integration tests against Postgres and Redis inside a job.
BeginnerScenarioGitHub Actions
Answer
Situation read → Service containers.
What I'd do →
services:
db:
image: postgres:16
env: { POSTGRES_PASSWORD: test }
ports: ['5432:5432']
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s --health-retries 10
redis:
image: redis:7
ports: ['6379:6379']
Why → Health checks make the job wait until the service is ready, and services are destroyed after the job.
Interview tip → On the runner host use localhost:<mapped port>; inside a container job use the service name.
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate