Skip to content

Fix the project-directory advice #2283 added (core fixes) - #2290

Open
schnie wants to merge 2 commits into
v2from
project-dir-advice-core
Open

schnie wants to merge 2 commits into
v2from
project-dir-advice-core

Conversation

@schnie

@schnie schnie commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Replaces #2288 with the core user-facing fixes to the project-directory advice #2283 added, built on v2's existing helpers (config.IsProjectDir, project.HasManifest). The only change under config/ is that IsProjectDir's existing home check now compares paths properly (see 6). Non-test lines vs v2: +102 / -15.

Fixes

  1. APC astro deploy --dags no longer needs a Dockerfile. A DAG-only deploy builds nothing; it uploads dags/. cmd/apc's EnsureProjectDir var (name kept) now points at ensureDeployProjectDir. For --dags it accepts a pyproject.toml project (project.HasManifest) or a 1.x project (utils.EnsureProjectDir, with no Dockerfile check). Every other APC deploy still goes through utils.EnsureDockerfileProjectDir.
  2. APC astro deploy --remote skips the project check. --remote points the Deployment at an image already in the registry and builds nothing, so a missing --image-name is reported by RunE ("--image-name is mandatory when --remote flag is passed") rather than as a missing Dockerfile. --remote --dags still checks the project, since RunE makes a DAG-only deploy then.
  3. --image-name is read by its value in PreRunE and RunE alike. In astro deploy (Astro) and APC deploy, an explicit empty --image-name= names no image. The project check runs, and on Astro, --image-name= --dags is no longer refused as "--image-name implies an image-only deploy".
  4. APC astro deploy --save refuses a pyproject.toml project that has no .astro/config.yaml, with a usage error: "--save stores the deployment in .astro/config.yaml, which a pyproject.toml project does not have; pass the deployment id on each deploy instead". Without this, saving would create .astro/config.yaml and turn the project into a 1.x one.
  5. EnsureDockerfileProjectDir also requires <WorkingPath>/Dockerfile, which the APC build parses there. The error names what is missing ("this directory has no .astro/config.yaml and no Dockerfile" / "has no Dockerfile"), and its advice can be followed: run astro package --tag <image>, then astro deploy <deployment-id> --image-name <image>.
  6. Home directory.
    • config.IsProjectDir's home check used a raw HomePath == path. It now calls config.IsHomeDir, which compares the cleaned paths and falls back to os.SameFile, so ~/ and a symlink to ~ are not project directories either.
    • When the working directory is home, both checks in cmd/utils use that same helper to say so, and they do not suggest astro init.

astro remote deploy is unchanged from v2: the pyproject.toml bypass stays, and --image-name does not skip the project check. DeployClientImage reads the registry it pushes to from the project's .astro/config.yaml, so outside a project it could push to the wrong registry. TestRemoteDeployImageNameStillChecksTheProject pins this.

Tests:

  • TestDeployProjectCheckFollowsTheDeploy (cmd/apc): covers --dags, --remote and --save. It restores every global it sets.
  • TestDeploySkipsEnsureProjectDirWhenImageNameSet and TestDeployEmptyImageNameIsNotImageOnly (cmd/astro)
  • TestRemoteDeployImageNameStillChecksTheProject
  • TestEnsureDockerfileProjectDirNamesWhatIsMissing
  • TestEnsureProjectDirInTheHomeDirectory
  • TestIsProjectDirRefusesHomeUnderAnySpelling (config)

Left out on purpose (follow-ups)

#2288 rewrote project detection to cover these, and each review round found new regressions in that machinery (#2288's reviews). Each needs its own design:

  • An astro init guard against scaffolding into $HOME. An earlier revision of this PR refused it, but that breaks containers and CI where HOME is the project root (Astro Runtime images use HOME=/usr/local/airflow). The advice no longer sends anyone to run init in ~.
  • Enclosing-project advice from subdirectories, i.e. "you are inside the project at X". This needs a directory walk with home and settings-file stops.
  • A unified "is a project" predicate across 1.x .astro/config.yaml and pyproject.toml manifests.
  • ASTRO_HOME settings-file handling: the CLI's own ~/.astro/config.yaml, or one under ASTRO_HOME, can be mistaken for a 1.x project's.
  • astro deploy --save on Astro from a pyproject project, which may need the same refusal APC deploy now has.
  • astro init's warning when nesting a project inside another.

Checks

  • go build ./... and GOOS=windows go build ./...
  • GOOS=windows go vet on config, cmd/utils, cmd/apc, cmd/astro and cmd/local
  • make test and make test-e2e (tier 0)
  • make lint (no autofix rewrites), make lint-goos and make deadcode

Merge-tree

git merge-tree --write-tree is conflict-free against all three open branches. Each combination also passes go vet ./cmd/... ./config/ and go test on the touched packages:

- APC astro deploy --dags no longer needs a Dockerfile: a DAG-only deploy
  builds nothing, so a 1.x project or a pyproject.toml project makes one.
- --image-name bypasses test the value, not whether the flag was given, on
  astro deploy, astro remote deploy and APC deploy: an empty --image-name=
  builds, so the project check runs.
- astro remote deploy --image-name skips the project check, as astro deploy
  does: a prebuilt image is pushed as it is.
- EnsureDockerfileProjectDir also requires the Dockerfile the APC build
  parses, names what is missing, and gives advice that can be followed:
  astro package --tag <image>, then astro deploy <id> --image-name <image>.
- In the home directory the advice no longer suggests astro init, and astro
  init refuses to make a new project of the home directory.

Co-Authored-By: Claude <noreply@anthropic.com>
@coveralls-official

coveralls-official Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 37941716828

Coverage increased (+0.03%) to 57.496%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 6 uncovered changes across 2 files (57 of 63 lines covered, 90.48%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
cmd/utils/utils.go 23 19 82.61%
cmd/apc/deploy.go 25 23 92.0%
Total (4 files) 63 57 90.48%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 69095
Covered Lines: 39727
Line Coverage: 57.5%
Coverage Strength: 199.61 hits per line

💛 - Coveralls

…e guard

- astro remote deploy --image-name runs the project check again: the push
  reads its registry from the project's .astro/config.yaml.
- APC deploy --remote skips the project check, so RunE reports a missing
  --image-name instead of a missing Dockerfile.
- astro deploy's RunE reads --image-name's value as PreRunE does: an empty
  --image-name= no longer makes a --dags deploy image-only.
- APC deploy --save refuses a pyproject.toml project rather than writing a
  .astro/config.yaml into it.
- The APC project-check test restores every global it sets.
- Drop astro init's home-directory refusal: in Astro Runtime images HOME is
  the project root.
- One home comparison: config.IsProjectDir uses config.IsHomeDir (cleaned
  path or os.SameFile), and cmd/utils calls it instead of its own copy.

Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
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