Interview Prep/CI/CD/GitHub Actions

CI takes 12 minutes mostly because dependencies are downloaded every run.

BeginnerScenarioGitHub Actions
Answer

Situation read → No dependency caching.

What I'd do →

  1. Use the built-in cache of setup actions (cache: npm|pip|maven|gradle) or actions/cache@v4 with key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} and restore-keys.
  2. Cache the package manager cache directory, not node_modules.
  3. Watch the 10 GB per-repo cache limit and eviction.

Why → Keying on the lockfile hash invalidates exactly when dependencies change.

Interview tip → Caches from PR branches are not shared with sibling branches, only from the default and base branches.

All CI/CD questions

More on GitHub Actions