| 1 | # sway pre-commit hooks (S19). |
| 2 | # |
| 3 | # Three variants — pick the one that matches your install posture. |
| 4 | # All three run ``sway gate`` under the hood and differ only in how |
| 5 | # sway itself is resolved on the runner. |
| 6 | # |
| 7 | # Variant 1: ``sway-gate`` (RECOMMENDED) — ``language: system``. |
| 8 | # Uses the sway binary already on your ``PATH``. Fast, no extra |
| 9 | # install. Requires ``pip install 'dlm-sway[hf]'`` beforehand. This |
| 10 | # is the right choice when sway is part of your dev environment |
| 11 | # anyway. |
| 12 | # |
| 13 | # Variant 2: ``sway-gate-isolated`` — ``language: python``. |
| 14 | # pre-commit builds a fresh Python venv and installs sway + the |
| 15 | # ``[hf]`` extra into it. First run pulls ~5 GB of torch wheels and |
| 16 | # takes ~2 minutes; subsequent runs reuse the cached venv. Right |
| 17 | # choice for users without a pre-existing sway install. |
| 18 | # |
| 19 | # Variant 3: ``sway-gate-docker`` — ``language: docker_image``. |
| 20 | # Pulls the pre-built ``ghcr.io/tenseleyflow/sway-gate`` image |
| 21 | # (torch wheels baked in, MiniLM weights pre-cached). First run is |
| 22 | # ~1 minute to pull + warm; subsequent runs reuse the local image. |
| 23 | # Right choice for zero-install CI / ephemeral runners with docker |
| 24 | # available. Requires docker on the host. |
| 25 | # |
| 26 | # All variants set ``pass_filenames: false`` — ``sway gate`` takes |
| 27 | # exactly one spec path via ``args:``, not a list of matched files. |
| 28 | # The ``files:`` regex only decides WHEN the hook fires; the ``args:`` |
| 29 | # in your ``.pre-commit-config.yaml`` decides WHAT spec it gates. |
| 30 | # |
| 31 | # Consumer-side config example — see README "Pre-commit" section for |
| 32 | # the full walk-through. |
| 33 | |
| 34 | - id: sway-gate |
| 35 | name: sway gate — differential testing for fine-tuned LMs |
| 36 | description: | |
| 37 | Gate an adapter against its sway spec on every commit that touches |
| 38 | the spec, a .dlm file, or adapter files. Uses the sway install on |
| 39 | your PATH. |
| 40 | entry: sway gate |
| 41 | language: system |
| 42 | # Fire on changes to the spec, .dlm documents, or adapter directories |
| 43 | # (adapter_config.json / adapter_model.safetensors live inside an |
| 44 | # "adapter" dir by convention). Narrow enough that Python edits |
| 45 | # don't trigger the gate — those are caught by pytest. |
| 46 | files: '(?:(^|/)sway\.ya?ml|\.dlm$|(^|/)adapter.*(adapter_config\.json|adapter_model\.safetensors)$)' |
| 47 | pass_filenames: false |
| 48 | |
| 49 | - id: sway-gate-isolated |
| 50 | name: sway gate (isolated venv) — differential testing for fine-tuned LMs |
| 51 | description: | |
| 52 | Same as sway-gate, but pre-commit builds a fresh Python venv and |
| 53 | installs sway inside it. First run pulls ~5 GB of torch wheels — |
| 54 | use this variant when you can't rely on a host-level sway install. |
| 55 | entry: sway gate |
| 56 | language: python |
| 57 | # v0.1.0 on PyPI — consumer ``rev:`` in .pre-commit-config.yaml |
| 58 | # tracks the sway release tag ("v0.1.0", "v0.2.0", ...). Closes |
| 59 | # audit-03 F05. |
| 60 | additional_dependencies: |
| 61 | - "dlm-sway[hf]==0.1.0" |
| 62 | files: '(?:(^|/)sway\.ya?ml|\.dlm$|(^|/)adapter.*(adapter_config\.json|adapter_model\.safetensors)$)' |
| 63 | pass_filenames: false |
| 64 | |
| 65 | - id: sway-gate-docker |
| 66 | name: sway gate (docker image) — differential testing for fine-tuned LMs |
| 67 | description: | |
| 68 | Same as sway-gate, but pre-commit pulls the pre-built sway-gate |
| 69 | Docker image and runs sway inside it. Torch wheels are baked in; |
| 70 | MiniLM weights are pre-cached. Fastest first-run path when you |
| 71 | already have docker on the host. |
| 72 | # For ``language: docker_image`` pre-commit treats the first token |
| 73 | # of ``entry:`` as the image to pull and the rest as argv inside the |
| 74 | # container. The image's ENTRYPOINT is ``["sway"]``, so passing |
| 75 | # ``gate`` here lands the caller at ``sway gate <args>``. |
| 76 | # Tag tracks the sway release; the image is built by |
| 77 | # .github/workflows/docker.yml on ``v*`` tag push. |
| 78 | entry: ghcr.io/tenseleyflow/sway-gate:v0.1.0 gate |
| 79 | language: docker_image |
| 80 | files: '(?:(^|/)sway\.ya?ml|\.dlm$|(^|/)adapter.*(adapter_config\.json|adapter_model\.safetensors)$)' |
| 81 | pass_filenames: false |
| 82 |