Skip to content

feat(ci): add resolve-toolchain and setup-devkit-toolchain composite actions - #1002

Merged
c-vigo merged 5 commits into
feature/988-mode-aware-scaffoldfrom
feature/994-setup-devkit-toolchain
Jul 13, 2026
Merged

c-vigo merged 5 commits into
feature/988-mode-aware-scaffoldfrom
feature/994-setup-devkit-toolchain

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the two shared mode-aware composite actions from #994, scaffolded (managed)
into every workspace mode under assets/workspace/.github/actions/. Provisioning
is separated from image selection per the #992 spike verdict
(docs/rfcs/ADR-conditional-container-toolchain.md, Option A adopted): a
workflow-level resolve-toolchain job selects the image; the step-level
setup-devkit-toolchain composite handles the toolchain preamble.

resolve-image is left untouched (retired later by #991/#989). No workflow is
converted here — that is #991.

How each mode branch works

resolve-toolchain/action.yml — reads .vig-os with the same tolerant
KEY=VALUE parsing as resolve-image (DEVKIT_MODE + DEVKIT_VERSION with legacy
DEVCONTAINER_VERSION fallback). Outputs:

  • mode — devcontainer|direnv|both|bare; a manifest-bearing repo with no
    DEVKIT_MODE defaults to both (today's container behavior).
  • image — ghcr.io/vig-os/devcontainer:<tag> for container-ish modes; an
    explicit empty string for direnv/bare (always emitted, never omitted,
    per the ADR — empty image makes the downstream job run on the host).
  • image-tag — the bare resolved version tag (logging/compat; doubles as the
    devkit-version to plumb into the bare branch).

Container-ish modes keep the docker manifest inspect accessibility probe
(auth-vs-missing classification preserved); host modes skip it via
if: steps.resolve.outputs.image != ''.

setup-devkit-toolchain/action.yml — single step-level preamble, gated per
mode input, safe as the first step after checkout in every job:

  • devcontainer/both (in-container): export UV_PROJECT_ENVIRONMENT +
    PREK_HOME to $GITHUB_ENV, git config --global --add safe.directory, and
    the [FEATURE] Nix-direct (direnv-mode) CI lane + version-skew hardening for shipped workflows #854 prek version-skew guard. No retry shim (image-baked retry binary).
  • direnv (host): install-nix-action + vig-os Cachix substituter (verbatim
    from the direnv ci.yml), optional consumer cachix-action, then build the
    repo's own flake dev-shell once via nix develop --profile and prepend
    its bin dirs to $GITHUB_PATH (mirrors this repo's setup-env: filters
    podman/python3, forwards UV_PYTHON_DOWNLOADS_JSON_URL). Skew guard resolves
    prek off the exported PATH and points at nix flake update vigos.
  • bare (host): setup-uv + uv tool install rust-just==1.51.0,
    prek==0.3.11, and vig-utils @ git+…@${DEVKIT_VERSION}#subdirectory=packages/vig-utils
    (Expose vig-utils console scripts host-side (dev-shell + pinned uv-tool path) #993); uv tool dir --bin >> $GITHUB_PATH.
  • host modes (direnv + bare): embed a self-contained retry shim via
    BASH_ENV (the scaffold cannot source the devkit-internal retry.sh, so the
    function is inlined).

Design decisions

  • Version plumbing into the bare branch: resolve-toolchain resolves the
    .vig-os version pin into image-tag in all modes (not just container),
    so CI + release workflows hard-coupled to the container image regardless of DEVKIT_MODE #991 passes devkit-version: ${{ needs.resolve-toolchain.outputs.image-tag }}
    to setup-devkit-toolchain. The bare install step fails fast with an
    actionable message if devkit-version is empty.
  • Retry shim: embedded verbatim as a self-contained function (from
    .github/scripts/retry.sh) rather than referenced, because scaffolded
    consumer repos have no access to devkit-internal scripts. Chains any
    pre-existing BASH_ENV. Validated end-to-end (heredoc de-indents correctly and
    the function is callable).

Evidence

  • bats tests/bats/init-workspace.bats — 136 tests pass, including 9 new
    #994 render/structural assertions (both actions ship in every mode tree,
    every uses: SHA-pinned, per-mode branch wiring, explicit empty host image).
  • prek run --all-files — all hooks green (yamllint, shellcheck,
    check-action-pins, sync-manifest all pass; CHANGELOG synced to
    .devcontainer/CHANGELOG.md).
  • Embedded retry() shim executed in a simulated runner env — defined and
    functional.
  • actionlint does not lint standalone composite action.yml metadata
    (it parses them as workflows and mis-reports); the permanent hook lands in
    Adopt actionlint for authored and per-mode rendered workflow templates #995. Run scripts were shellchecked ad hoc — only intentional SC2016 (info)
    on the nix develop --command bash -c 'printf … $PATH' idiom, identical to the
    existing setup-env action.

Open questions for #991 (workflow conversion)

How #991 consumes the two actions

jobs:
  resolve-toolchain:
    name: Resolve toolchain
    runs-on: ubuntu-24.04
    outputs:
      mode: ${{ steps.resolve.outputs.mode }}
      image: ${{ steps.resolve.outputs.image }}
      image-tag: ${{ steps.resolve.outputs.image-tag }}
    steps:
      - uses: actions/checkout@<sha>  # sparse: .vig-os + .github/actions/resolve-toolchain
      - id: resolve
        uses: ./.github/actions/resolve-toolchain
        with:
          registry-token: ${{ secrets.GHCR_PULL_TOKEN || github.token }}
          registry-username: ${{ github.actor }}

  lint:
    needs: [resolve-toolchain]
    runs-on: ubuntu-24.04
    # Empty image (host modes) => runs on host; non-empty => runs in container.
    container:
      image: ${{ needs.resolve-toolchain.outputs.image }}
      credentials:               # inert when image is empty (#992 spike)
        username: ${{ github.actor }}
        password: ${{ secrets.GHCR_PULL_TOKEN || github.token }}
    steps:
      - uses: actions/checkout@<sha>
      - uses: ./.github/actions/setup-devkit-toolchain
        with:
          mode: ${{ needs.resolve-toolchain.outputs.mode }}
          devkit-version: ${{ needs.resolve-toolchain.outputs.image-tag }}
          cachix-cache: ${{ vars.CACHIX_CACHE }}
          cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
      - run: just sync
      - run: just precommit

No automated CI runs on PRs into the epic branch; evidence is local (above).

Refs: #994

c-vigo added 5 commits July 13, 2026 09:42
Assert the two new mode-aware composites — resolve-toolchain and
setup-devkit-toolchain — ship in every rendered mode tree, SHA-pin every
action reference, and wire each mode branch (container in-image env, direnv
Nix dev-shell + skew guard, bare uv/vig-utils install, host-mode retry shim,
explicit empty image for host modes).

Refs: #994
Two mode-aware composite actions scaffolded into every workspace mode:

resolve-toolchain (evolves resolve-image, which stays for now) reads .vig-os
with the same tolerant KEY=VALUE parsing and emits mode + image + image-tag.
Container-ish modes (devcontainer/both) get the ghcr devcontainer image and
keep the docker manifest-inspect accessibility probe; host modes (direnv/bare)
get an explicit empty image so the downstream job runs on the host runner
(Option A, docs/rfcs/ADR-conditional-container-toolchain.md). Missing
DEVKIT_MODE defaults to both.

setup-devkit-toolchain is the single step-level toolchain preamble, gated per
DEVKIT_MODE and safe as the first step after checkout in every job:
- devcontainer/both: export UV_PROJECT_ENVIRONMENT + PREK_HOME, apply the git
  safe.directory fix, run the prek version-skew guard (#854).
- direnv: install-nix + vig-os Cachix substituter, build the repo's own flake
  dev-shell once and prepend its bin dirs to PATH (mirrors setup-env, filtering
  podman/python3 and forwarding UV_PYTHON_DOWNLOADS_JSON_URL); host-side skew
  guard points at nix flake update vigos.
- bare: setup-uv + pinned uv tool install of rust-just, prek, and vig-utils
  pinned to the devkit-version input (#993).
- direnv + bare: embed a self-contained retry shim via BASH_ENV (in-container
  jobs use the image-baked retry binary).

Refs: #994
A typo'd manifest mode must fail the resolve step loudly instead of being
silently classified as a host mode (empty image), matching the
init-workspace.sh corrupt-persisted-mode guard.

Refs: #994
An unrecognized manifest mode previously fell through the catch-all image
branch and was silently treated as a host mode (empty image), flipping a
container repo's CI onto host runners. Validate the mode after the default
is applied — failing loudly like the init-workspace.sh persisted-mode
guard — and close the image case statement with an explicit direnv|bare arm.

Refs: #994
@c-vigo
c-vigo merged commit b60d27e into feature/988-mode-aware-scaffold Jul 13, 2026
2 checks passed
@c-vigo
c-vigo deleted the feature/994-setup-devkit-toolchain branch July 13, 2026 08:04
c-vigo added a commit that referenced this pull request Jul 13, 2026
…997)

One release choreography, mode-aware toolchain provisioning: resolve-toolchain + setup-devkit-toolchain composites (ADR Option A), single mode-aware ci.yml, all release/automation workflows container-free in direnv/bare, opt-in .devcontainer/ prune, vig-utils host-side, actionlint. Sub-PRs: #998 #999 #1000 #1001 #1002 #1005 #1006 #1007.

Refs: #988
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