buildbot-effects: support flake references for remote repos#585
Open
buildbot-effects: support flake references for remote repos#585
Conversation
Avoids the painful workflow of cloning a repo into a tempdir just to run a one-off effect. Commands now accept Nix flake reference syntax: buildbot-effects run github:org/repo/branch#my-effect buildbot-effects list github:org/repo/branch buildbot-effects list-schedules github:org/repo/branch buildbot-effects run-scheduled github:org/repo#schedule effect When a flake ref is detected (by the presence of '#' in the positional arg, or as an optional positional for list commands), we resolve it via `nix flake metadata --json` to obtain the rev, branch, store path, and locked URL — then pass the locked URL directly to builtins.getFlake instead of constructing a git+file:// URL from a local checkout. Closes: #584
When --branch was specified without --rev, effects_args() called get_git_rev() which always resolves HEAD of the current checkout, ignoring the requested branch entirely. This meant running: buildbot-effects --branch feature run my-effect would use the rev from whatever branch was checked out, not from 'feature'. Resolve the rev from the specified branch via git rev-parse when --branch is given. Closes: #583
646fb89 to
b3c95cd
Compare
Store paths from resolved flake references have no .git directory, causing git_get_tag() et al. to crash. Gate all git fallbacks behind an _is_git_repo() check. Also fix options_from_flake_ref: lockedUrl is null for many flake types, so fall back to the url field which includes the resolved rev. Move tests/ inside their respective packages to avoid duplicate module names confusing mypy.
The implementation was just `print("TODO")` and nothing used it.
--secrets only applies to run/run-scheduled, not list/list-schedules. Move all flags (--rev, --branch, --repo, --path, --debug, --secrets) from the parent parser to their respective subcommand parsers so --secrets is only accepted where it makes sense. Update all internal callers (nix_eval.py, buildbot_effects.py, scheduled.py) to place flags after the subcommand name.
e98cf42 to
3249532
Compare
The effects section in README was getting long and contained outdated CLI help output. Move it to a dedicated page and update to reflect the current CLI (flake ref support, subcommand flags, no run-all).
Suppress the 'fatal: not a git repository' message from _is_git_repo() by redirecting stderr to /dev/null. Add --add-root gcroot to nix-instantiate calls to silence the 'you did not specify --add-root' warning. The gcroot is kept alive via a TemporaryDirectory that spans the entire instantiate+run sequence. Also handle dirtyRev from nix flake metadata for dirty worktrees.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Avoids the painful workflow of cloning a repo into a tempdir just to run a one-off effect. Commands now accept Nix flake reference syntax:
buildbot-effects run github:org/repo/branch#my-effect
buildbot-effects list github:org/repo/branch
buildbot-effects list-schedules github:org/repo/branch
buildbot-effects run-scheduled github:org/repo#schedule effect
When a flake ref is detected (by the presence of '#' in the positional arg, or as an optional positional for list commands), we resolve it via
nix flake metadata --jsonto obtain the rev, branch, store path, and locked URL — then pass the locked URL directly to builtins.getFlake instead of constructing a git+file:// URL from a local checkout.Closes: #584