`load` relative to repo root
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 10.1k
- Forks
- 413
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 6
Description
Describe the Feature You Want
A mechanism to load a path relative to the SCM repo root, e.g., load('//src/bazel/Tiltfile.bazel', 'myfunc')
Technically, bazel describes // as relative to a workspace which in Tilt is the Tiltfile dir, not the repo root - it might make more sense to make it something like load('scmroot://path') to reserve // for other uses.
Current Behavior
Current options are:
load('../../../../../src/bazel/Tiltfile.bazel', 'myfunc'). Using..s like this is always annoying to get right, varies across Tiltfiles, and breaks if a Tiltfile moves.bazel = load_dynamic(os.path.join(str(local('git rev-parse --show-toplevel')).rstrip(), 'src/bazel/Tiltfile.bazel')). Functional, but wordy and leaves you with a dict instead of imported symbols.- load the repo into a path relative to the Tilt workspace via
git_checkoutand thenloadfrom.git-sources/myrepo/src/bazel/Tiltfile.bazel. If the repo is of non-trivial size, this is slow and takes up space. Also, will use Tiltfile.bazel from origin rather than whatever you have on disk, which makes iterating on that file confusing. - As of #5445, we can do this:
repo_root = str(local('git rev-parse --show-toplevel')).rstrip()
v1alpha1.extension_repo(name='root', url='file://%s' % repo_root)
v1alpha1.extension(name='bazel', repo_name='root', repo_path='bazel')
load('ext://bazel', 'foo')
foo()
which lets us import symbols without using ..s or copying the whole repo, but is a bit of a mouthful to put in the top of each Tiltfile.
Why Do You Want This?
A user reported having a monorepo with dozens or hundreds of services, and prefers to make a service's Tiltfile the entrypoint rather than having an entrypoint Tiltfile at the root. Each service's Tiltfiles may want to include the same set of helper functions.
(this could also be solved by swapping to a single root Tiltfile, but that might not be practical/desirable for all users)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how Tiltfile load resolves paths and how imported symbols are returned. Compare the proposed // and scmroot:// forms with the existing load_dynamic and extension examples in the issue. Done means a supported repo-root-relative load mechanism works for service Tiltfiles without copying the repository or requiring a long setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100