diff --git a/.claude/settings.json b/.claude/settings.json deleted file mode 100644 index cd5372a..0000000 --- a/.claude/settings.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "attribution": { - "commit": "", - "pr": "" - }, - "hooks": { - "PostToolUse": [ - { - "matcher": "Write|Edit", - "hooks": [ - { - "type": "command", - "command": "jq -r '.tool_response.filePath // .tool_input.file_path' | { read -r f; case \"$f\" in *.rb) bin/stree write \"$f\" ;; esac; } 2>/dev/null || true" - } - ] - } - ] - } -} diff --git a/.envrc b/.envrc deleted file mode 100644 index b50a72f..0000000 --- a/.envrc +++ /dev/null @@ -1 +0,0 @@ -export MUTANT_SINCE=HEAD diff --git a/.githooks/pre-commit b/.githooks/pre-commit deleted file mode 100755 index 3a43294..0000000 --- a/.githooks/pre-commit +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -stash_ref="" -cleanup() { - if [ -n "$stash_ref" ]; then - git stash pop --quiet "$stash_ref" || true - fi -} -trap cleanup EXIT - -if ! git diff --quiet || [ -n "$(git ls-files --others --exclude-standard)" ]; then - git stash push --keep-index --include-untracked --quiet --message "pre-commit: $(date +%s)" - stash_ref="stash@{0}" -fi - -bin/rake diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ae00924..711e2f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,10 +22,22 @@ jobs: with: persist-credentials: false fetch-depth: 0 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 + - name: Install Nix + uses: cachix/install-nix-action@v31 with: - ruby-version: '4.0.2' - bundler-cache: true + extra_nix_config: | + accept-flake-config = true + - name: Set up cachix + uses: cachix/cachix-action@v16 + with: + name: devenv + - name: Install devenv + run: nix profile install nixpkgs#devenv + - name: Cache gems + uses: actions/cache@v4 + with: + path: .devenv/state/.bundle + key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile.lock') }} + restore-keys: ${{ runner.os }}-gems- - name: Run the default task - run: bin/rake + run: devenv shell -- bin/rake diff --git a/.gitignore b/.gitignore index eeca105..ca4d092 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,12 @@ +/.claude/settings.json +/.mcp.json /.bundle/ /.mutant/ /pkg/ /tmp/ /test/pg_regress/results/ +.devenv* +devenv.local.nix +devenv.local.yaml +.pre-commit-config.yaml +/.githooks/ diff --git a/Gemfile.lock b/Gemfile.lock index 9c1ddd0..abbd85f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -313,7 +313,6 @@ CHECKSUMS benchmark (0.5.0) sha256=465df122341aedcb81a2a24b4d3bd19b6c67c1530713fd533f3ff034e419236c bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f - bundler (4.0.11) sha256=5bcec0fb78302e48d02ee46f10ee6e6942be647ba5b44a6d1ddfda9a240ce785 concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a crass (1.0.6) sha256=dc516022a56e7b3b156099abc81b6d2b08ea1ed12676ac7a5657617f012bd45d @@ -396,4 +395,4 @@ CHECKSUMS zeitwerk (2.8.2) sha256=7212a61311083c604184b1ea2574b9aa05cd14f855a0841c06985cabe9181d12 BUNDLED WITH - 4.0.11 + 2.7.2 diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..867955b --- /dev/null +++ b/devenv.lock @@ -0,0 +1,197 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1782231411, + "narHash": "sha256-W/Yhek5L3nc0gaGgMHPrzO6DbLGq7Yb9DKw/kvLwij0=", + "owner": "cachix", + "repo": "devenv", + "rev": "a4fd3348220d96f7602385adff0ace482e720586", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "NixOS", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1781733627, + "narHash": "sha256-U3yTuGBnmXvXoQI3qkpfEDsn9RovQPAjN7ndRco+3u0=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "3bbec39bc90eadfa031e6f3b77272f3f60803e39", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "inputs": { + "nixpkgs-src": "nixpkgs-src" + }, + "locked": { + "lastModified": 1782132010, + "narHash": "sha256-ZnAVHdVrotp80iIMm5CSR1fdxPlw7Uwmwxb+O/wsgZ8=", + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "12866ae2dddbc0ab8b329915f8072bb9c75bde89", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs-ruby": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1782291298, + "narHash": "sha256-s5qd1ZWKoc8m6dnTvcHTMWerE8xXOSG82Vgp7eIPesk=", + "owner": "bobvanderlinden", + "repo": "nixpkgs-ruby", + "rev": "5a59e45e96465645c00422fedf5e62e337f6cfea", + "type": "github" + }, + "original": { + "owner": "bobvanderlinden", + "repo": "nixpkgs-ruby", + "type": "github" + } + }, + "nixpkgs-src": { + "flake": false, + "locked": { + "lastModified": 1781607440, + "narHash": "sha256-rxO+uc/KFbSJp+pgyXRuAX6QlG9hJdnt0BXpEQRXY+U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3e41b24abd260e8f71dbe2f5737d24122f972158", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "git-hooks": "git-hooks", + "nixpkgs": "nixpkgs", + "nixpkgs-ruby": "nixpkgs-ruby" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} \ No newline at end of file diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..50f0c47 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,54 @@ +{ pkgs, lib, ... }: + +{ + languages.ruby.enable = true; + languages.ruby.version = "4.0.5"; + + packages = [ + pkgs.postgresql_18 + pkgs.postgresql_18.pg_config + pkgs.pgformatter + pkgs.jq + pkgs.libyaml + ]; + + env.PG_REGRESS = "${pkgs.postgresql_18.dev}/lib/pgxs/src/test/regress/pg_regress"; + + enterShell = '' + export MUTANT_SINCE="''${MUTANT_SINCE:-HEAD}" + bundle install --quiet + ''; + + enterTest = "bin/rake"; + + tasks = { + "app:format".exec = "bin/rake format"; + "app:test".exec = "bin/rake test"; + "app:mutate".exec = "bin/mutant run"; + "app:pg-regress".exec = "bin/rake pg_regress"; + "app:check".exec = "bin/rake"; # default: test + mutate_since + }; + + git-hooks.hooks.rake = { + enable = true; + name = "rake (test + mutate_since)"; + entry = "${pkgs.writeShellScript "rake-precommit" '' + export MUTANT_SINCE="''${MUTANT_SINCE:-HEAD}" + exec bin/rake + ''}"; + pass_filenames = false; + language = "system"; + stages = [ "pre-commit" ]; + }; + + claude.code.enable = true; + claude.code.hooks.git-hooks-run.enable = false; + claude.code.hooks.format-ruby = { + name = "Format Ruby with syntax_tree"; + hookType = "PostToolUse"; + matcher = "Write|Edit"; + command = '' + jq -r '.tool_response.filePath // .tool_input.file_path' | { read -r f; case "$f" in *.rb) bin/stree write "$f" ;; esac; } 2>/dev/null || true + ''; + }; +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..5a3d24b --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,13 @@ +inputs: + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling + git-hooks: + url: github:cachix/git-hooks.nix + inputs: + nixpkgs: + follows: nixpkgs + nixpkgs-ruby: + url: github:bobvanderlinden/nixpkgs-ruby + inputs: + nixpkgs: + follows: nixpkgs