# sway pre-commit hooks (S19). # # Three variants — pick the one that matches your install posture. # All three run ``sway gate`` under the hood and differ only in how # sway itself is resolved on the runner. # # Variant 1: ``sway-gate`` (RECOMMENDED) — ``language: system``. # Uses the sway binary already on your ``PATH``. Fast, no extra # install. Requires ``pip install 'dlm-sway[hf]'`` beforehand. This # is the right choice when sway is part of your dev environment # anyway. # # Variant 2: ``sway-gate-isolated`` — ``language: python``. # pre-commit builds a fresh Python venv and installs sway + the # ``[hf]`` extra into it. First run pulls ~5 GB of torch wheels and # takes ~2 minutes; subsequent runs reuse the cached venv. Right # choice for users without a pre-existing sway install. # # Variant 3: ``sway-gate-docker`` — ``language: docker_image``. # Pulls the pre-built ``ghcr.io/tenseleyflow/sway-gate`` image # (torch wheels baked in, MiniLM weights pre-cached). First run is # ~1 minute to pull + warm; subsequent runs reuse the local image. # Right choice for zero-install CI / ephemeral runners with docker # available. Requires docker on the host. # # All variants set ``pass_filenames: false`` — ``sway gate`` takes # exactly one spec path via ``args:``, not a list of matched files. # The ``files:`` regex only decides WHEN the hook fires; the ``args:`` # in your ``.pre-commit-config.yaml`` decides WHAT spec it gates. # # Consumer-side config example — see README "Pre-commit" section for # the full walk-through. - id: sway-gate name: sway gate — differential testing for fine-tuned LMs description: | Gate an adapter against its sway spec on every commit that touches the spec, a .dlm file, or adapter files. Uses the sway install on your PATH. entry: sway gate language: system # Fire on changes to the spec, .dlm documents, or adapter directories # (adapter_config.json / adapter_model.safetensors live inside an # "adapter" dir by convention). Narrow enough that Python edits # don't trigger the gate — those are caught by pytest. files: '(?:(^|/)sway\.ya?ml|\.dlm$|(^|/)adapter.*(adapter_config\.json|adapter_model\.safetensors)$)' pass_filenames: false - id: sway-gate-isolated name: sway gate (isolated venv) — differential testing for fine-tuned LMs description: | Same as sway-gate, but pre-commit builds a fresh Python venv and installs sway inside it. First run pulls ~5 GB of torch wheels — use this variant when you can't rely on a host-level sway install. entry: sway gate language: python # v0.1.0 on PyPI — consumer ``rev:`` in .pre-commit-config.yaml # tracks the sway release tag ("v0.1.0", "v0.2.0", ...). Closes # audit-03 F05. additional_dependencies: - "dlm-sway[hf]==0.1.0" files: '(?:(^|/)sway\.ya?ml|\.dlm$|(^|/)adapter.*(adapter_config\.json|adapter_model\.safetensors)$)' pass_filenames: false - id: sway-gate-docker name: sway gate (docker image) — differential testing for fine-tuned LMs description: | Same as sway-gate, but pre-commit pulls the pre-built sway-gate Docker image and runs sway inside it. Torch wheels are baked in; MiniLM weights are pre-cached. Fastest first-run path when you already have docker on the host. # For ``language: docker_image`` pre-commit treats the first token # of ``entry:`` as the image to pull and the rest as argv inside the # container. The image's ENTRYPOINT is ``["sway"]``, so passing # ``gate`` here lands the caller at ``sway gate ``. # Tag tracks the sway release; the image is built by # .github/workflows/docker.yml on ``v*`` tag push. entry: ghcr.io/tenseleyflow/sway-gate:v0.1.0 gate language: docker_image files: '(?:(^|/)sway\.ya?ml|\.dlm$|(^|/)adapter.*(adapter_config\.json|adapter_model\.safetensors)$)' pass_filenames: false