# Put `uv`/`uvx` on the irv-ml1-arbo Gitea Actions runner's PATH.
#
# WHY: the runner (`irv-ml1-arbo`, act_runner host-executor running AS lkraven
# under systemd) inherits the bare systemd service PATH —
#   /usr/local/bin:/usr/bin:/bin
# — which does NOT include lkraven's `~/.local/bin` or `~/.cargo/bin`. uv is
# installed at /home/lkraven/.local/bin/uv (login-shell only), so the CI step's
# `uv run` failed with `uv: not found` even though uv is present on the box.
# `/usr/local/bin` IS on the systemd PATH, so symlinking uv there makes it
# visible to the runner. This also lets deploy.yml drop the per-run `curl|sh`
# uv bootstrap. Operator-asked ("fix cicd"); comfy-dev (engine owner) authorized
# the specific symlink 2026-06-16 (althing thread 01KV94VTS27B…).
#
# Re-apply this if the runner host is rebuilt or uv is reinstalled elsewhere.
# Sudo because /usr/local/bin is root-owned; uv is owned by lkraven (the runner
# identity), which is who actually executes the symlink at job time — traversal
# of /home/lkraven works for lkraven, not for infra-ops (don't be fooled by an
# infra-ops `env -i` exec test reporting Permission denied; that's the wrong
# identity — verify AS lkraven).

vars:
  uv_src: /home/lkraven/.local/bin/uv
  uvx_src: /home/lkraven/.local/bin/uvx

steps:
  - name: Symlink uv into /usr/local/bin (on the systemd PATH)
    shell: ln -s {{ uv_src }} /usr/local/bin/uv
    creates: /usr/local/bin/uv

  - name: Symlink uvx into /usr/local/bin
    shell: ln -s {{ uvx_src }} /usr/local/bin/uvx
    creates: /usr/local/bin/uvx

verify:
  - name: uv resolves to the /usr/local/bin symlink under a systemd-like PATH (run AS lkraven)
    shell: sudo -u lkraven env -i PATH=/usr/local/bin:/usr/bin:/bin sh -c 'command -v uv && uv --version'
    changed_when: "false"

  - name: uvx resolves the same way
    shell: sudo -u lkraven env -i PATH=/usr/local/bin:/usr/bin:/bin sh -c 'command -v uvx && uvx --version'
    changed_when: "false"
