Skip to content

Commit 2bbf451

Browse files
cxxxrclaude
andcommitted
Add mallet linter to CI workflow
- Build mallet from source with trivial-glob dependency - Replace shell-based whitespace/tab checks with mallet - Add lint check to flake.nix checks - Separate test and lint jobs in GitHub Actions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f61881e commit 2bbf451

File tree

2 files changed

+102
-37
lines changed

2 files changed

+102
-37
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,20 @@ jobs:
2121
experimental-features = nix-command flakes
2222
2323
- name: Run tests
24-
run: nix flake check
24+
run: nix build .#checks.x86_64-linux.test
2525

2626
lint:
2727
runs-on: ubuntu-latest
2828

2929
steps:
3030
- uses: actions/checkout@v4
3131

32-
- name: Check for trailing whitespace
33-
run: |
34-
if grep -rn '[[:blank:]]$' --include='*.lisp' --include='*.asd' .; then
35-
echo "Found trailing whitespace"
36-
exit 1
37-
fi
38-
39-
- name: Check for tabs
40-
run: |
41-
if grep -rn $'\t' --include='*.lisp' --include='*.asd' .; then
42-
echo "Found tabs (use spaces)"
43-
exit 1
44-
fi
32+
- name: Install Nix
33+
uses: cachix/install-nix-action@v30
34+
with:
35+
nix_path: nixpkgs=channel:nixos-24.11
36+
extra_nix_config: |
37+
experimental-features = nix-command flakes
38+
39+
- name: Run mallet linter
40+
run: nix build .#checks.x86_64-linux.lint

flake.nix

Lines changed: 92 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,55 @@
2020
rove
2121
];
2222

23+
# trivial-glob (not in nixpkgs)
24+
trivial-glob-src = pkgs.fetchFromGitHub {
25+
owner = "fukamachi";
26+
repo = "trivial-glob";
27+
rev = "0c2675d9452ed164970f2fc4a0e41784ebee819a";
28+
sha256 = "sha256-XkeQXfKk7zcEuj4Q9eOve4d3hern0kyD2k3IamoZ6/w=";
29+
};
30+
31+
# mallet linter
32+
mallet-src = pkgs.fetchFromGitHub {
33+
owner = "fukamachi";
34+
repo = "mallet";
35+
rev = "de89ea2c319c703ed3fa8889de70e2abf85a7ce8";
36+
sha256 = "sha256-ujxSrepDVNq7RJxCfPQeF3owf5aXLEIkTzqIeIx+89o=";
37+
};
38+
39+
mallet = pkgs.stdenv.mkDerivation {
40+
pname = "mallet";
41+
version = "0.1.1";
42+
src = mallet-src;
43+
44+
nativeBuildInputs = [ pkgs.makeWrapper ];
45+
46+
buildInputs = [
47+
pkgs.sbcl
48+
] ++ (with pkgs.sbclPackages; [
49+
alexandria
50+
cl-ppcre
51+
eclector
52+
]);
53+
54+
buildPhase = ''
55+
export HOME=$(mktemp -d)
56+
export CL_SOURCE_REGISTRY="${trivial-glob-src}//:$PWD//"
57+
58+
sbcl --noinform --non-interactive \
59+
--eval '(require :asdf)' \
60+
--eval '(asdf:load-system :mallet)' \
61+
--eval '(asdf:make :mallet)'
62+
'';
63+
64+
installPhase = ''
65+
mkdir -p $out/bin
66+
cp mallet $out/bin/mallet-unwrapped
67+
makeWrapper $out/bin/mallet-unwrapped $out/bin/mallet \
68+
--set SBCL_HOME "${pkgs.sbcl}/lib/sbcl"
69+
'';
70+
};
71+
2372
# Build the C wrapper library
2473
ts-wrapper = pkgs.stdenv.mkDerivation {
2574
pname = "ts-wrapper";
@@ -83,36 +132,56 @@
83132
'';
84133
};
85134

86-
# For CI: run tests
87-
checks.default = pkgs.stdenv.mkDerivation {
88-
pname = "tree-sitter-cl-tests";
89-
version = "0.1.0";
90-
src = ./.;
135+
checks = {
136+
# Run tests
137+
test = pkgs.stdenv.mkDerivation {
138+
pname = "tree-sitter-cl-tests";
139+
version = "0.1.0";
140+
src = ./.;
141+
142+
buildInputs = [
143+
pkgs.sbcl
144+
pkgs.tree-sitter
145+
] ++ qlDeps;
146+
147+
buildPhase = ''
148+
export HOME=$(mktemp -d)
149+
export LD_LIBRARY_PATH="${libPath}"
150+
export CL_SOURCE_REGISTRY="$PWD//"
151+
152+
sbcl --non-interactive \
153+
--eval '(require :asdf)' \
154+
--eval '(asdf:load-system :tree-sitter-cl/tests)' \
155+
--eval '(let ((result (rove:run :tree-sitter-cl/tests))) (unless result (uiop:quit 1)))'
156+
'';
157+
158+
installPhase = ''
159+
mkdir -p $out
160+
echo "Tests passed" > $out/result.txt
161+
'';
162+
};
91163

92-
buildInputs = [
93-
pkgs.sbcl
94-
pkgs.tree-sitter
95-
] ++ qlDeps;
164+
# Run mallet linter
165+
lint = pkgs.stdenv.mkDerivation {
166+
pname = "tree-sitter-cl-lint";
167+
version = "0.1.0";
168+
src = ./.;
96169

97-
buildPhase = ''
98-
export HOME=$(mktemp -d)
99-
export LD_LIBRARY_PATH="${libPath}"
100-
export CL_SOURCE_REGISTRY="$PWD//"
170+
buildInputs = [ mallet ];
101171

102-
sbcl --non-interactive \
103-
--eval '(require :asdf)' \
104-
--eval '(asdf:load-system :tree-sitter-cl/tests)' \
105-
--eval '(let ((result (rove:run :tree-sitter-cl/tests))) (unless result (uiop:quit 1)))'
106-
'';
172+
buildPhase = ''
173+
mallet src/ *.asd
174+
'';
107175

108-
installPhase = ''
109-
mkdir -p $out
110-
echo "Tests passed" > $out/result.txt
111-
'';
176+
installPhase = ''
177+
mkdir -p $out
178+
echo "Lint passed" > $out/result.txt
179+
'';
180+
};
112181
};
113182

114183
packages = {
115-
inherit ts-wrapper tree-sitter-json-grammar;
184+
inherit ts-wrapper tree-sitter-json-grammar mallet;
116185
};
117186
});
118187
}

0 commit comments

Comments
 (0)