Skip to content

feat(ci): make the CI dev-shell gcroot path configurable - #1603

Merged
c-vigo merged 3 commits into
devfrom
feature/1601-persistent-dev-profile-path
Sep 2, 2026
Merged

c-vigo merged 3 commits into
devfrom
feature/1601-persistent-dev-profile-path

Conversation

@c-vigo

@c-vigo c-vigo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

setup-devkit-toolchain's direnv branch realises the consumer dev-shell into a
Nix profile under $RUNNER_TEMP. The --profile is what makes it a gcroot
rather than a bare nix develop, and on a hosted runner that placement is
right — the machine is discarded with the job anyway.

An ephemeral self-hosted runner inverts the trade-off: RUNNER_TEMP is
wiped between jobs while the /nix/store — the whole reason to run one —
persists. Nothing roots the dev-shell between jobs, so a routine nix.gc on the
host collects the closure every CI run needs. Measured on a direnv consumer
with a heavy dev-shell: a 26 s Set up devkit toolchain step becoming
180–237 s, in each of the three toolchain lanes that run per CI run.

This adds an opt-in .vig-os key naming a persistent path for that profile.
Absent or empty — the shipped default — reproduces today's behaviour byte for
byte for every consumer, hosted and self-hosted alike.

Type of Change

  • feat -- New feature

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

Wired the way DEVKIT_CI_RUNNER (#1173) is, per the issue discussion — same
class of fact (an infrastructure detail of the runner this repo builds on),
declared in the consumer's committed manifest, so there is no repo variable to
declare and it round-trips a --force upgrade:

  • assets/workspace/.vig-os — new DEVKIT_DEV_PROFILE_PATH= key, shipped
    empty, documented with the self-hosted rationale.
  • resolve-toolchain — reads the key and emits a dev-profile-path output.
    Vets it once, on the cheap hosted producer job: a relative path, a path inside
    the runner's _work/_temp tree, or the filesystem root fails there, before
    any lane realises a dev-shell. Trailing slashes are trimmed.
  • setup-devkit-toolchain — new optional dev-profile-path input, routed
    through env: (never inline ${{ }} in run:). The step resolves it, or
    falls back to $RUNNER_TEMP/devkit-dev-profile when unset, and all four
    nix develop calls use the resolved path. What only the target host can
    answer — is the parent directory creatable, is it writable — is checked there
    and fails the step loudly. Neither layer falls back silently: a job-scoped
    gcroot is indistinguishable from the bug.
  • ci.yml — the lint, test and commit-checks lanes pass the resolved
    path. Deliberately only those three: they are exactly the jobs
    DEVKIT_CI_RUNNER can move onto a consumer's runner, and the three the issue
    measured. Everything else in the scaffold stays on the hosted default, where
    RUNNER_TEMP is the correct place for the root.
  • init-workspace.sh — the key is read before the template overwrite and
    written back, so an upgrade cannot silently re-root the dev-shell in
    RUNNER_TEMP.
  • docs/MIGRATION.md — new "Keep the dev-shell gcroot across ephemeral
    self-hosted jobs" section plus the manifest-key table row, including the
    runner-host notes: slots on one host are expected to share the path
    (concurrent nix develop --profile realisations take the profile lock and
    converge), and it must be a local persistent directory, not a per-job tmpfs.

Changelog Entry

### Added

- **`DEVKIT_DEV_PROFILE_PATH`: keep the CI dev-shell gcroot across ephemeral
  self-hosted jobs** ([#1601](https://github.com/vig-os/devkit/issues/1601))
  - In `direnv` mode, `setup-devkit-toolchain` realises the repo's dev-shell
    into a Nix profile under `$RUNNER_TEMP` — a gcroot that dies with the job.
    Correct on a hosted runner, wrong on an ephemeral self-hosted one, whose
    `/nix/store` persists: nothing roots the closure between jobs, so the host's
    `nix.gc` collects it and every run re-realises the dev-shell. Measured on a
    heavy dev-shell: a 26 s toolchain step becoming 180–237 s, in each of the
    three lanes that run per CI run
  - The new optional `.vig-os` key names an absolute, persistent, runner-writable
    path for that profile. `resolve-toolchain` reads and vets it and emits a
    `dev-profile-path` output; the `lint`, `test` and `commit-checks` lanes —
    the ones `DEVKIT_CI_RUNNER` can move onto your runner — plumb it into the
    toolchain action's new `dev-profile-path` input
  - A value that could never persist (relative, or inside the runner's
    `_work`/`_temp` tree) is refused at resolve time, before any lane realises a
    dev-shell; a path the host cannot create or write fails the toolchain step
    itself. Neither falls back silently — a job-scoped gcroot is
    indistinguishable from the bug
  - Absent or empty (the shipped default) keeps `$RUNNER_TEMP/devkit-dev-profile`
    byte for byte, so hosted and self-hosted consumers alike are unchanged. The
    key round-trips a `--force` upgrade like the other manifest knobs. See
    [Keep the dev-shell gcroot across ephemeral self-hosted jobs](docs/MIGRATION.md#keep-the-dev-shell-gcroot-across-ephemeral-self-hosted-jobs)

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

TDD, RED committed first (ecfc316, 33a044e) then the implementation
(bdbe469). New/extended coverage:

  • tests/test_toolchain_dev_profile.py (new, 21 tests) — the input's shape and
    default; the env: routing (no ${{ }} in run:); every --profile using
    the resolved value; resolve-toolchain's emission (absent / empty / absolute
    / whitespace / quoted / trailing slash, and every delivery mode) and its
    refusals, executed against the action's real bash; the ci.yml re-export and
    the three lane call sites.
  • tests/test_setup_toolchain_env.py — six executed-bash cases on the step
    itself: the unset default is still $RUNNER_TEMP/devkit-dev-profile, a
    configured path moves every realisation, and relative / uncreatable /
    unwritable paths fail the step without realising anything. The nix stub now
    logs each --profile it is handed; the step harness was refactored to expose
    the process so the refusal paths are assertable.
  • tests/test_vig_os_manifest.py, tests/bats/init-workspace.bats — the key
    ships declared-and-empty, the output is declared, and the value round-trips an
    upgrade.

Local runs: full pytest green apart from two pre-existing environment
failures (test_image.py::test_manifest_files — local .pymarkdown vs the
pulled image — and test_integration.py::test_github_cli_authentication), both
verified failing on a stashed clean tree. prek run --all-files green.

Not verifiable locally: the acceptance criteria that need a real ephemeral
self-hosted runner (profile surviving a job boundary and a
nix-collect-garbage, second run not re-realising). Those want a live run on
the reporting consumer once this is adopted.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

The wiring shape follows the recommendation in the issue comment rather than an
Actions variable. The comment's two implementation notes are both addressed: the
shared-path expectation is documented in MIGRATION.md, the .vig-os key
comment and the action's input table; and the fail-loudly constraint is split
between resolve time (a value no host could make persistent) and step time (what
only the target host can answer).

The _work/_temp guard catches the mistake the knob exists to prevent —
rooting inside the tree the runner clears — but it cannot prove an arbitrary
path is persistent, and does not claim to.

Refs: #1601

@c-vigo
c-vigo enabled auto-merge September 2, 2026 07:49
@c-vigo
c-vigo merged commit 1a36651 into dev Sep 2, 2026
12 checks passed
@c-vigo
c-vigo deleted the feature/1601-persistent-dev-profile-path branch September 2, 2026 07:57
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