Skip to content

test: bats suite, real-DDEV e2e, CI and template alignment - #13

Merged
elabx merged 6 commits into
mainfrom
test/bats-suite
Dec 2, 2026
Merged

elabx merged 6 commits into
mainfrom
test/bats-suite

Conversation

@elabx

@elabx elabx commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Adds automated tests and CI, and lines the repo up with DDEV's add-on maintenance guide and ddev-addon-template.

Tests

  • tests/test.bats: end-to-end on real DDEV, in the template's format. It installs the add-on from the directory, runs ddev worktree feat-e2e, and checks that the clone:

    • is running;
    • serves the site over HTTPS;
    • has the source's database row;
    • runs alongside the source, which is still up.

    Then it runs --list and ddev worktree-remove. Scheduled runs also install from the latest release. It installs into ~/.ddev, so outside CI it skips unless DDEV_WORKTREE_E2E=1.

  • tests/unit/: 62 fast tests with a fake ddev. No Docker needed; they run in seconds and cover:

CI (.github/workflows/tests.yml)

  • shellcheck.
  • Unit tests on Ubuntu and macOS. The template only tests Linux, but these are host commands that run on macOS /bin/bash 3.2 with BSD tools.
  • End-to-end through ddev/github-action-add-on-test@v2 on DDEV stable and HEAD, amd64 and arm64.
  • Triggers and settings, as in the template: every PR and push to main, nightly, and manual runs with debugging. Markdown-only changes are skipped, superseded runs are cancelled, and permissions are read-only.

Template alignment

  • install.yaml: ddev_version_constraint: '>= v1.24.10', the guide's current recommendation. This raises the minimum DDEV version from v1.24.0.
  • Shebang: #!/usr/bin/env bash in both commands.
  • README: registry, tests, last-commit and release badges, a Development section, and a License section.
  • .gitattributes: keeps tests/ and .github/ out of release tarballs.
  • LICENSE: MIT.

Fixes found along the way

  • Shellcheck: quote expansions inside ${..} so project names aren't matched as glob patterns. Two of these came from feat: adopt worktrees created by other tools with --path #12.
  • Known bug, test skipped: with omit_project_name_by_default: true and no name: in .ddev/config.yaml, the command stops at "Could not determine project name" before the omit logic runs. Left for a separate fix.

Not in this PR (repo settings)

  • The ddev-get topic and a description, so the add-on appears in ddev add-on list --all and on addons.ddev.com.
  • Merge settings and a ruleset for main.

🤖 Generated with Claude Code

elabx and others added 4 commits November 23, 2026 17:48
- tests/ runs both commands against a fake ddev in an isolated sandbox
  (own HOME and TMPDIR), so it needs no Docker. It covers clone creation,
  DB transfer and cleanup, branch handling, name sanitizing, the
  collision and --force protections, profiles, removal (including
  clones named by older versions), the safety check, --list and
  packaging (install.yaml, #ddev-generated, Flags JSON).
- One test is skipped: with omit_project_name_by_default and no name in
  config.yaml, the command stops before the omit logic (existing bug).
- Fixes the shellcheck findings: quote expansions inside ${..} so
  project names aren't matched as patterns, drop an unused variable,
  and replace an echo|sed with a read loop.
- GitHub Actions runs shellcheck and bats on Linux and macOS for every
  PR and every push to main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…license

Follows DDEV's add-on maintenance guide and ddev/ddev-addon-template:

- tests/test.bats is an end-to-end test on real DDEV, in the template's
  format: it installs the add-on from the directory (and, on scheduled
  runs, from the release), creates a clone, checks it runs, serves the
  site and has the source's database, then lists and removes it. It
  installs into ~/.ddev, so it skips outside CI unless DDEV_WORKTREE_E2E=1.
- The fake-ddev suite moves to tests/unit/.
- tests.yml gains the template's e2e job (ddev/github-action-add-on-test@v2,
  DDEV stable and HEAD on amd64 and arm64), a nightly schedule, manual
  runs with debugging, paths-ignore for Markdown, concurrency and
  read-only permissions. The unit job keeps macOS for the host commands.
- ddev_version_constraint is now '>= v1.24.10', the guide's current
  recommendation.
- The commands use #!/usr/bin/env bash, as the guide recommends.
- README: template badges, updated Development section, License section.
- .gitattributes keeps tests/ and .github/ out of release tarballs.
- LICENSE: MIT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- tests/unit/adopt.bats: 24 tests for `ddev worktree --path` and its
  removal (refusals, external marker, files kept, failed-delete
  handling, cross-project and name lookups, --list).
- The fake ddev can make `ddev list` fail (DDEV_LIST_RC).
- Quote ${SOURCE_PROJECT} inside two ${..} expansions from #12.
- Restore `CONFIG_WORKTREE=$(worktree_config ...)` in worktree-remove.
  An earlier shellcheck cleanup on this branch dropped the variable
  while it was unused; #12 now reads it to recognise adopted worktrees,
  and without it removal deleted their files. main was never affected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@elabx elabx changed the title test: add bats suite, shellcheck and CI test: bats suite, real-DDEV e2e, CI and template alignment Nov 25, 2026
- `! cmd` and `[[ ... ]]` that aren't a test's last line don't fail the
  test (bats ignores `!`; bash 3.2 on macOS ignores `[[ ]]` under set -e).
  Append `|| false` to all 40 such lines. Verified: the --no-db test now
  catches --no-db being ignored, and the profile-list test now catches a
  changed bullet on /bin/bash 3.2.
- Set GIT_CONFIG_GLOBAL=/dev/null and GIT_CONFIG_NOSYSTEM=1 so a host
  config like commit.gpgsign=true can't break make_source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@elabx
elabx merged commit d72b6fc into main Dec 2, 2026
7 checks passed
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.

1 participant