Skip to content

Set CWD to bundle root in bundle commands #2686

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

denik
Copy link
Contributor

@denik denik commented Apr 9, 2025

Changes

In bundle commands, set CWD early to bundle root.

Why

This aligns with internal representation where all files are relative to bundle root and most subprocesses should be run within bundle root directory.

Some parts of code could be simplified (e.g. path.Glob or opening files) - previously we always had to convert to abs path first, now we can process the paths directly. (I did not do all possible simplifications, just a few obvious ones that did not break any tests).

Less testing required - we don't need to test as much anymore that all features work when running bundle commands in directory different from bundle root. We only need to test boundary conditions w.r.t parameters passed.

Tests

Existing tests.

@denik denik temporarily deployed to test-trigger-is April 9, 2025 10:45 — with GitHub Actions Inactive
@denik denik force-pushed the denik/set-cwd-bundle-root branch from 699ea7c to b1544fc Compare April 9, 2025 10:45
@denik denik temporarily deployed to test-trigger-is April 9, 2025 10:45 — with GitHub Actions Inactive
@denik denik force-pushed the denik/set-cwd-bundle-root branch from 7fe92d5 to b8e330a Compare April 9, 2025 15:16
@denik denik temporarily deployed to test-trigger-is April 9, 2025 15:17 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is April 9, 2025 15:46 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is April 9, 2025 16:24 — with GitHub Actions Inactive
@denik denik force-pushed the denik/set-cwd-bundle-root branch from de2d5df to 3180815 Compare April 10, 2025 09:26
@denik denik temporarily deployed to test-trigger-is April 10, 2025 09:26 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is April 10, 2025 09:26 — with GitHub Actions Inactive
@denik denik marked this pull request as ready for review April 10, 2025 13:47
@denik denik changed the title WIP Set CWD to bundle root Set CWD to bundle root in bundle commands Apr 10, 2025
@denik denik temporarily deployed to test-trigger-is April 10, 2025 13:47 — with GitHub Actions Inactive
}

abs := filepath.Join(cwd, *pathPtr)
rel, err := filepath.Rel(root, abs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail if we provide DATABRICKS_BUNDLE_ROOT which is outside of CWD. Can we have a test for this to confirm setting DATABRICKS_BUNDLE_ROOT works as expected?

@andrewnester
Copy link
Contributor

JFYI See https://github.com/databricks/cli/pull/2555/files#diff-a20d49a34bb0f2a3c96a0fa01f1b990f6d15870a751ecf9eb3b95e47fb37a10bR34 as well, this has to continue to work for apps inside the bundles

@denik
Copy link
Contributor Author

denik commented May 9, 2025

This is on hold, to get the following changes in first:

  • Switch to using path relative to bundle root everywhere.
  • Add more test coverage regarding CWD != BundleRoot != SyncRoot.

@denik denik marked this pull request as draft May 9, 2025 09:05
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