-
-
Notifications
You must be signed in to change notification settings - Fork 34
Blog: Running DDEV in CI with WarpBuild #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deviantintegral
wants to merge
3
commits into
ddev:main
Choose a base branch
from
deviantintegral:warpbuild-post
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| name: Andrew Berry | ||
| firstName: Andrew | ||
| avatarUrl: https://2.gravatar.com/avatar/fa4256320a36792e419f7d315048707e57234cdca897102467bf1564833c5ff4?s=96&d=mm&r=g | ||
| --- | ||
|
|
||
| Andrew loves nerding about tech and building things with code. He's the VP of Technology at Lullabot and a member of the DDEV Board of Directors. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| --- | ||
| title: "Using WarpBuild to speed up DDEV in CI" | ||
| pubDate: 2026-01-01 | ||
| modifiedDate: 2026-01-03 | ||
| modifiedComment: "" | ||
| summary: Use WarpBuild to speed up DDEV in CI. | ||
| author: Andrew Berry | ||
| featureImage: | ||
| src: /img/blog/2026/01/warp-speed-ci.jpg | ||
| srcDark: /img/blog/2026/01/warp-speed-ci.jpg | ||
| alt: Warp Speed CI | ||
| caption: | ||
| credit: | ||
| categories: | ||
| - DevOps | ||
| - Performance | ||
| --- | ||
|
|
||
| For most developers, DDEV solves a common challenge: making sure that each developer as a consistent, stable local environment for building their web application. At Lullabot, as we had more and more success with DDEV, another related issue kept coming up: how do we grow and develop our use of continuous integration and automated testing while avoiding similar challenges? | ||
|
|
||
| A typical CI/CD pipeline is implemented using the tools and systems provided by the CI service itself. For example, at a basic level you can place shell commands inside configuration files to run tests and tools. Running those commands locally in DDEV is possible, but it's a painful copypaste process. If you're a back-end or DevOps engineer, odds are high you've wasted hours trying to figure out why a test you wrote locally isn't passing in CI – or vice versa! | ||
|
|
||
| As a first step, we used [Task](https://taskfile.dev/) to improve our velocity. Having a unified task runner that works outside PHP lets us standardize CI tasks more easily. However, this still left a big surface area for differences between local and CI environments. For example, in GitHub, the `shivammathur/setup-php` action is used to install PHP and extensions, but the action is not identical to DDEV. Underlying system libraries and packages installed with `apt-get` could also be different, causing unexpected issues. Finally, there was often a lag in detecting when local test environments broke because those changes weren't tested in CI. | ||
|
|
||
| This brought us to using DDEV for CI. It's a great solution! Running all of our builds and tasks in CI solved nearly every "it works on my machine" problem we had. However, it introduced a new challenge: **CI startup performance**. | ||
|
|
||
| Unlike using a CI-provider's built-in tooling, DDEV is not typically cached or included in CI runners. Just running the [setup-ddev](https://github.com/ddev/github-action-setup-ddev) action can take up to a minute on a bad day. That doesn't include any additional packages or Dockerfile customizations a project may include. At Lullabot, we use [ddev-playwright](https://github.com/Lullabot/ddev-playwright) to run end-to-end tests. Browser engines and their dependencies are heavy! System dependencies can be north of 1GB of compressed packages (that then have to be installed), and browsers themselves can be several hundred MB. This was adding several minutes of setup time just to run a single test. | ||
|
|
||
| Luckily, based on our experience building [Tugboat](https://tugboatqa.com/), we knew that the technology to improve startup performance existed. When [WarpBuild](https://www.warpbuild.com/) was announced with Snapshot support in 2024, we immediately started testing it out. Our theory was that Snapshots would be fast enough to create and restore that we'd see significant improvements in startup time. Let's show how we set it up! | ||
|
|
||
| We had three parallel jobs that all required DDEV: | ||
|
|
||
| 1. **Playwright Functional Tests** - these were using 8 "large" runners from GitHub to complete our test suite fast. Before WarpBuild, each runner took between 15 and 20 minutes to run tests. | ||
| 2. **Static tests** running PHPStan, PHPUnit, and so on. | ||
| 3. [ZAP](https://www.zaproxy.org/) for security scanning. | ||
|
|
||
| Note that our Playwright tests themselves run in parallel on a single worker as well, using [lullabot/playwright-drupal](https://github.com/lullabot/playwright-drupal). This allows us to optimize the additional startup time for installing Drupal itself (which can't be cached in a snapshot) across many tests. | ||
|
|
||
| After linking WarpBuild to our GitHub repository, we had to update our workflows. Here's the changes we made [after enabling Snapshots](https://docs.warpbuild.com/ci/snapshot-runners) in the WarpBuild UI. | ||
|
|
||
| 1. Update workflows to use the WarpBuild runner such as `warp-ubuntu-2404-x64-16x`. WarpBuild has _many_ runner options available, including ARM and spot instances to reduce costs further. We'll explain `snapshot.key` and `inputs.snapshot` below. | ||
| ```yaml | ||
| runs-on: | ||
| "${{ contains(github.event.head_commit.message, '[warp-no-snapshot]') && | ||
| 'warp-ubuntu-2404-x64-16x' || | ||
| format('warp-ubuntu-2404-x64-16x;snapshot.key=PROJECT-NAME-playwright-snapshot-1.24.10-v1-{0}', inputs.snapshot) }}" | ||
| ``` | ||
| 2. Switch `actions/cache` to `WarpBuilds/cache`: | ||
| ```yaml | ||
| - uses: WarpBuilds/cache@v1 | ||
| with: | ||
| path: | | ||
| ${{ github.workspace }}/.ddev/.drainpipe-composer-cache | ||
| ${{ github.workspace }}/vendor | ||
| ${{ github.workspace }}/web/core | ||
| ${{ github.workspace }}/web/modules/contrib | ||
| key: ${{ runner.os }}-composer-full-${{ hashFiles('**/composer.lock') }} | ||
| ``` | ||
| 3. Create a hash of key files to know when the snapshot should be rebuilt. | ||
| ```yaml | ||
| - name: Determine Snapshot Base | ||
| id: snapshot-base | ||
| run: | | ||
| set -x | ||
| hash=$(cat .github/actions/ddev/action.yml test/playwright/.yarnrc.yml test/playwright/yarn.lock | md5sum | cut -c 1-8) | ||
| echo "snapshot=$hash" >> $GITHUB_OUTPUT | ||
| shell: bash | ||
| ``` | ||
| This hash is used as a part of the `runs-on` key above, and when saving a snapshot below. That way, if DDEV or Playwright are upgraded, the pull request will build from scratch and create a new snapshot automatically. | ||
| 4. We check to see if we are running from a snapshot or not by testing for DDEV. | ||
| ```yaml | ||
| - name: Find ddev | ||
| id: find-ddev | ||
| shell: bash | ||
| run: | | ||
| set -x | ||
| DDEV_PATH=$(which ddev) || DDEV_PATH='' | ||
| echo "ddev-path=$DDEV_PATH" >> "$GITHUB_OUTPUT" | ||
| ``` | ||
| 5. After installing DDEV and running `ddev install-playwright`, we run tests. If they pass, we run a `Create snapshot` step. `matrix.shard` prevents us from wasting time creating multiple snapshots on all shards (we selected shard 2 randomly). | ||
| ```yaml | ||
| - name: Clean up for the snapshot | ||
| if: ${{ matrix.shard == 2 && steps.find-ddev.outputs.ddev-path != '/usr/bin/ddev'}} | ||
| run: | | ||
| ddev poweroff | ||
| git clean -ffdx | ||
| - name: Create snapshot | ||
| uses: WarpBuilds/snapshot-save@v1 | ||
| if: ${{ matrix.shard == 2 && steps.find-ddev.outputs.ddev-path != '/usr/bin/ddev'}} | ||
| with: | ||
| alias: "PROJECT-NAME-playwright-snapshot-1.24.10-v1-${{ inputs.snapshot }}" | ||
| fail-on-error: true | ||
| wait-timeout-minutes: 60 | ||
| ``` | ||
| It was important to include the DDEV version in the snapshot name so we could clear it when updating DDEV. We also had a version number in case we messed up the cache. We recommend using Renovate Custom Managers to keep it in sync with other ddev versions in your project. | ||
|
|
||
| We don't pin actions to hashes in these examples for easy copypaste, but for security we always [use Renovate to pin hashes for us](https://docs.renovatebot.com/modules/manager/github-actions/#digest-pinning-and-updating). | ||
|
|
||
| The results? | ||
|
|
||
| - The time to start Playwright tests was reduced from **4 to 5 minutes** to **1 to 2 minutes**. Now, the longest time in the workflow is the `ddev start` command. | ||
| - We thought costs would go down, but we ended up writing many more tests! CI costs stayed roughly similar to our previous GitHub costs but with greater test coverage and faster reports. | ||
| - While ZAP tests needed browsers like Playwright, static tests didn't. However, restoring snapshots was fast enough creating separate snapshots without browsers wasn't worth the complexity. | ||
| - Snapshot storage costs are inexpensive enough to not matter compared to the CI runner cost. | ||
|
|
||
| While this seems like a lot of work, it was only about half a day to set up and test - and that was with a new, in-beta service with minimal documentation and rough edges. We haven't really had to touch this code since. Setting up new projects is an hour, at most. | ||
|
|
||
| Do you have other optimizations for DDEV in CI to share? Post in the comments, we'd love to hear them! | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These need bumping before publishing.