Skip to content

feat: add a cacheDependencies input - #63

Closed
davereid wants to merge 1 commit into
mainfrom
feat/cache-dependencies
Closed

davereid wants to merge 1 commit into
mainfrom
feat/cache-dependencies

Conversation

@davereid

@davereid davereid commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds an opt-in cacheDependencies input that caches Composer, npm and Yarn downloads between workflow runs, following up on the Composer caching approach from #15.

  • New input cacheDependencies (default false): writes .ddev/config.zz-setup-ddev-cache.yaml, pointing COMPOSER_CACHE_DIR, npm_config_cache and YARN_CACHE_FOLDER at .ddev/.setup-ddev-cache, and caches that directory with actions/cache, keyed on composer.lock, package-lock.json and yarn.lock
  • New output cache-hit: true when the lock files matched a saved cache exactly
  • New tests/fixtures/ddevProj2 fixture and cache-save/cache-restore jobs that install offline from the restored cache
  • README: documents the new option

An alternative to #62, which documents the same approach as a recipe for workflows to copy. Related to #15, which stays open for Docker image caching.

Remaining tasks

  • Check that cache-restore passes: actions/cache saves from inside a composite action, and the cache variables reach the web container
  • Yarn 4 uses a global cache by default, so YARN_CACHE_FOLDER may not apply there; the tests only cover Composer and npm

AI disclosure

Claude Code (Claude Opus 5.5) wrote the input, the tests, the README section and this description, from my earlier Composer example in #15. I proposed adding caching to the action itself and reviewed the changes.

🤖 Generated with Claude Code

Caches Composer, npm and Yarn downloads with actions/cache, keyed on the lock files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment on lines +81 to +97
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: ./
with:
ddevDir: tests/fixtures/ddevProj2
cacheDependencies: true

- name: Install dependencies to fill the cache
working-directory: tests/fixtures/ddevProj2
run: |
ddev composer install
ddev npm ci

cache-restore:
Comment on lines +98 to +119
needs: cache-save
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: ./
id: ddev
with:
ddevDir: tests/fixtures/ddevProj2
cacheDependencies: true

- name: Cache restored
env:
CACHE_HIT: ${{ steps.ddev.outputs.cache-hit }}
run: test "$CACHE_HIT" = 'true'

- name: Install dependencies without network access
working-directory: tests/fixtures/ddevProj2
run: |
ddev exec 'COMPOSER_DISABLE_NETWORK=1 composer install'
ddev npm ci --offline
@davereid

Copy link
Copy Markdown
Collaborator Author

Closing in favor of a separate action, davereid/github-action-cache-ddev. Instead of overriding the package managers' cache settings, it mounts runner directories over the caches DDEV already keeps (Composer, npm, Yarn 1 and 4, Corepack, Node.js), so this action stays focused on setting up DDEV. #15 stays open for Docker image caching.

@davereid davereid closed this Nov 16, 2026
@davereid
davereid deleted the feat/cache-dependencies branch November 16, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants