Skip to content

Bind-mount host dirs in astro dev pytest to match astro dev start#2016

Merged
jlaneve merged 1 commit intomainfrom
fix/pytest-bind-mount-host-dirs
Feb 19, 2026
Merged

Bind-mount host dirs in astro dev pytest to match astro dev start#2016
jlaneve merged 1 commit intomainfrom
fix/pytest-bind-mount-host-dirs

Conversation

@jlaneve
Copy link
Contributor

@jlaneve jlaneve commented Feb 19, 2026

Summary

  • astro dev pytest now bind-mounts dags/, tests/, plugins/, and include/ from the host into the ephemeral pytest container, matching the volume mounts that astro dev start provides via docker-compose
  • Removes the previous docker cp approach for dags/ (replaced by bind mount) and the post-exit docker cp of include/ back to host (now automatic via bind mount)
  • .astro/ continues to use docker cp due to inconsistent .dockerignore behavior across platforms

Problem

astro dev start bind-mounts dags/, tests/, plugins/, and include/ via docker-compose volumes. However, astro dev pytest created a one-off container using docker create and only copied dags/ and .astro/ via docker cp. This meant:

  • tests/ was not available in the pytest container unless baked into the image with COPY tests ./tests
  • plugins/ and include/ were also missing
  • Users had to maintain COPY directives in their Dockerfile solely for astro dev pytest, causing unnecessary image rebuilds and inconsistency with the astro dev start workflow

Traced to airflow/docker_image.go Pytest() function — the docker create call had no -v flags, and only dags/ and .astro/ were copied post-creation.

Fix

Add -v bind mount flags to the docker create call for all four directories (dags/, tests/, plugins/, include/), matching the compose template mounts. This eliminates the need for docker cp of dags/ and ensures all host directories are visible to pytest.

Test plan

  • Unit tests pass (go test ./airflow/ -run TestDockerImagePytest)
  • Full airflow package tests pass (go test ./airflow/)
  • Manual: default test file runs
  • Manual: host-only probe file in tests/ found via bind mount
  • Manual: -i <custom-image> with host-only file (customer's exact repro) — previously broken, now works
  • Manual: cross-directory access (read plugins/, include/ files from tests)
  • Manual: write to include/ from inside container persists on host
  • Manual: empty and missing directories handled (Docker creates them)
  • Manual: --args, --env flags work
  • Manual: .astro/test_dag_integrity_default.py works
  • Manual: failing tests still propagate exit code 1

🤖 Generated with Claude Code

Previously, `astro dev pytest` created an ephemeral container and only
copied `dags/` and `.astro/` into it via `docker cp`. This meant
`tests/`, `plugins/`, and `include/` were only available if baked into
the Docker image with COPY, unlike `astro dev start` which bind-mounts
all four directories via docker-compose.

Switch to `-v` bind mounts on `docker create` for dags/, tests/,
plugins/, and include/ so that host files are always visible without
needing COPY in the Dockerfile. The `.astro/` folder continues to use
`docker cp` due to inconsistent `.dockerignore` behavior across
platforms.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coveralls-official
Copy link

Pull Request Test Coverage Report for Build dea3aa0c-6b80-4ca8-93a6-f32c1809e835

Details

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.003%) to 35.1%

Totals Coverage Status
Change from base Build 89a978cf-4306-4b80-9221-69a4200c30a0: -0.003%
Covered Lines: 22984
Relevant Lines: 65481

💛 - Coveralls

@jlaneve jlaneve marked this pull request as ready for review February 19, 2026 22:22
@jlaneve jlaneve requested a review from a team as a code owner February 19, 2026 22:22
@jlaneve jlaneve merged commit 0952f85 into main Feb 19, 2026
4 of 7 checks passed
@jlaneve jlaneve deleted the fix/pytest-bind-mount-host-dirs branch February 19, 2026 22:24
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