@@ -0,0 +1,55 @@ |
| 1 | +# sway pre-commit hooks (S19). |
| 2 | +# |
| 3 | +# Two variants — pick the one that matches your install posture. Both |
| 4 | +# run ``sway gate`` under the hood and differ only in how sway itself |
| 5 | +# 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 | +# Both variants set ``pass_filenames: false`` — ``sway gate`` takes |
| 20 | +# exactly one spec path via ``args:``, not a list of matched files. |
| 21 | +# The ``files:`` regex only decides WHEN the hook fires; the ``args:`` |
| 22 | +# in your ``.pre-commit-config.yaml`` decides WHAT spec it gates. |
| 23 | +# |
| 24 | +# Consumer-side config example — see README "Pre-commit" section for |
| 25 | +# the full walk-through. |
| 26 | + |
| 27 | +- id: sway-gate |
| 28 | + name: sway gate — differential testing for fine-tuned LMs |
| 29 | + description: | |
| 30 | + Gate an adapter against its sway spec on every commit that touches |
| 31 | + the spec, a .dlm file, or adapter files. Uses the sway install on |
| 32 | + your PATH. |
| 33 | + entry: sway gate |
| 34 | + language: system |
| 35 | + # Fire on changes to the spec, .dlm documents, or adapter directories |
| 36 | + # (adapter_config.json / adapter_model.safetensors live inside an |
| 37 | + # "adapter" dir by convention). Narrow enough that Python edits |
| 38 | + # don't trigger the gate — those are caught by pytest. |
| 39 | + files: '(?:(^|/)sway\.ya?ml|\.dlm$|(^|/)adapter.*(adapter_config\.json|adapter_model\.safetensors)$)' |
| 40 | + pass_filenames: false |
| 41 | + |
| 42 | +- id: sway-gate-isolated |
| 43 | + name: sway gate (isolated venv) — differential testing for fine-tuned LMs |
| 44 | + description: | |
| 45 | + Same as sway-gate, but pre-commit builds a fresh Python venv and |
| 46 | + installs sway inside it. First run pulls ~5 GB of torch wheels — |
| 47 | + use this variant when you can't rely on a host-level sway install. |
| 48 | + entry: sway gate |
| 49 | + language: python |
| 50 | + # Pinned to a specific commit — sway hasn't tagged a release yet. |
| 51 | + # When v0.1.0 ships, we'll switch to tag-based pinning. |
| 52 | + additional_dependencies: |
| 53 | + - "dlm-sway[hf] @ git+https://github.com/tenseleyFlow/sway.git@2ecd9a0c9d65a9b9576a185597c88f41444f9646" |
| 54 | + files: '(?:(^|/)sway\.ya?ml|\.dlm$|(^|/)adapter.*(adapter_config\.json|adapter_model\.safetensors)$)' |
| 55 | + pass_filenames: false |