You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在GitHub Actions中使用Ddev运行验收测试遇路由健康检查失败求助

Fixing Ddev-Router Health Check Failure in GitHub Actions

Let's tackle this ddev-router health check issue you're facing in GitHub Actions. The root cause here is likely a combination of incomplete Ddev initialization, overly aggressive cleanup steps, and masking startup errors with ddev start || exit 0. Here's how to resolve it:

Key Issues in Your Current Workflow

  • Manual Docker cleanup/install: Uninstalling system packages like nginx and manually reinstalling Docker can introduce unexpected state conflicts in the GitHub Actions runner.
  • Masking startup errors: ddev start || exit 0 hides actual failures during Ddev initialization, so you never see why the project container didn't spin up (which directly causes the "no upstream server" error in ddev-router).
  • Missing initialization steps: You're not running ddev config to ensure your project is properly configured before starting Ddev, which can lead to incomplete container setup.

Step-by-Step Fix

1. Simplify Docker Setup

Use GitHub's official Docker setup actions instead of manual apt commands — they're optimized for CI environments and avoid state conflicts:

- name: Set up Docker
  uses: docker/setup-buildx-action@v3

2. Install Ddev with Official Script (More Reliable Than Brew)

The official Ddev installation script is faster and more consistent in CI than using Linuxbrew, which can have latency or dependency issues in runner environments:

- name: Install Ddev
  run: |
    curl -fsSL https://ddev.com/install.sh | bash
    ddev config global --instrumentation-opt-in=false

3. Properly Initialize and Start Ddev

Remove the error-masking ddev start || exit 0 and add explicit configuration and health check steps to ensure all containers are fully ready:

- name: Configure Ddev project
  run: ddev config --project-type=php --docroot=public --create-docroot=false
  # Adjust project-type and docroot to match your actual project setup

- name: Start Ddev and wait for services
  run: |
    ddev start
    ddev wait-for-services

4. Debugging Enhancements (Optional but Useful)

Add these steps to get clearer visibility into container state if issues persist:

- name: Debug Ddev state on failure
  if: failure()
  run: |
    ddev status
    docker logs ddev-router
    docker ps -a

Full Updated Workflow

Here's the complete fixed tests.yml:

name: Tests
on: [push, pull_request]
jobs:
  tests-via-ddev:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Docker
        uses: docker/setup-buildx-action@v3

      - name: Install Ddev
        run: |
          curl -fsSL https://ddev.com/install.sh | bash
          ddev config global --instrumentation-opt-in=false

      - name: Configure Ddev project
        run: ddev config --project-type=php --docroot=public --create-docroot=false
        # Update project-type and docroot to match your project

      - name: Start Ddev and wait for services
        env:
          DDEV_NON_INTERACTIVE: true
        run: |
          ddev start
          ddev wait-for-services

      - name: Enable Xdebug for coverage
        run: ddev exec enable_xdebug

      - name: Run tests
        run: ddev composer cookieman:test

      # Debug steps if something fails
      - name: Debug Ddev state on failure
        if: failure()
        run: |
          ddev status
          docker ps -a
          docker logs ddev-router

Why This Works

  • Official Docker actions ensure a clean, compatible Docker environment without conflicting with pre-installed packages on the runner.
  • ddev config explicitly sets up your project so Ddev knows how to create the correct containers (fixing the "no upstream server" issue by ensuring the project container exists and is properly linked to ddev-router).
  • ddev wait-for-services waits until all containers (including your project container and ddev-router) are fully healthy before proceeding, avoiding race conditions that cause premature health checks.
  • Removing error masking lets you see the actual startup error if something goes wrong, making debugging far easier.

内容的提问来源于stack exchange,提问作者Jonas Eberle

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:44:24