Skip to content

Commit 8e7ed79

Browse files
committed
ci: migrate GitHub Actions from Lua/Luarocks to Nix-based build system
Change-Id: I5548155ef563feacef4e69df16386ca300509f96 Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent 2a387ba commit 8e7ed79

File tree

4 files changed

+117
-90
lines changed

4 files changed

+117
-90
lines changed

.github/workflows/test.yml

Lines changed: 62 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ on:
99
permissions:
1010
contents: read
1111

12+
# Cancel in-progress runs for pull requests when developers push
13+
# additional changes
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
17+
1218
jobs:
1319
unit-tests:
1420
runs-on: ubuntu-latest
@@ -17,86 +23,63 @@ jobs:
1723
neovim-version: ["stable", "nightly"]
1824

1925
steps:
20-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
26+
- name: Checkout
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2128
with:
29+
fetch-depth: 0
2230
persist-credentials: false
2331

32+
- name: Setup Nix
33+
uses: nixbuild/nix-quick-install-action@5bb6a3b3abe66fd09bbf250dce8ada94f856a703 # v30
34+
35+
- uses: nix-community/cache-nix-action@135667ec418502fa5a3598af6fb9eb733888ce6a # v6.1.3
36+
with:
37+
primary-key: nix-claudecode-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
38+
restore-prefixes-first-match: nix-claudecode-${{ runner.os }}-
39+
gc-max-store-size-linux: 2G
40+
purge: true
41+
purge-prefixes: nix-claudecode-${{ runner.os }}-
42+
purge-created: 0
43+
purge-primary-key: never
44+
2445
- name: Setup Neovim
2546
uses: rhysd/action-setup-vim@8e931b9954b19d4203d5caa5ff5521f3bc21dcc7 # v1.4.2
2647
with:
2748
neovim: true
2849
version: ${{ matrix.neovim-version }}
2950

30-
- name: Setup Lua
31-
uses: leafo/gh-actions-lua@8aace3457a2fcf3f3c4e9007ecc6b869ff6d74d6 # v11
32-
with:
33-
luaVersion: "5.1"
34-
35-
- name: Setup Luarocks
36-
uses: leafo/gh-actions-luarocks@4c082a5fad45388feaeb0798dbd82dbd7dc65bca # v5
37-
38-
- name: Install dependencies
39-
run: |
40-
luarocks install luacheck
41-
luarocks install busted
42-
luarocks install luacov
43-
luarocks install luacov-reporter-lcov
44-
4551
- name: Run Luacheck
46-
run: luacheck lua/ tests/ --no-unused-args --no-max-line-length
52+
run: nix develop .#ci -c luacheck lua/ tests/ --no-unused-args --no-max-line-length
4753

4854
- name: Run tests
49-
run: |
50-
chmod +x ./run_tests.sh
51-
./run_tests.sh
55+
run: nix develop .#ci -c ./run_tests.sh
56+
57+
- name: Check formatting
58+
run: nix flake check
5259

5360
- name: Generate coverage report
5461
run: |
5562
# Check if stats file exists (created by busted --coverage)
5663
if [ -f "luacov.stats.out" ]; then
5764
# Generate the regular luacov report
58-
luacov
59-
60-
# Convert to lcov format if luacov-reporter-lcov is installed
61-
if command -v luacov-reporter-lcov &> /dev/null; then
62-
luacov-reporter-lcov
63-
if [ -f "luacov.report.out.lcov" ]; then
64-
cp luacov.report.out.lcov lcov.info
65-
else
66-
# Fallback if lcov format not generated
67-
echo "Creating simple lcov.info from luacov.report.out"
68-
{
69-
echo "TN:"
70-
grep -E "^Summary$" -A1000 luacov.report.out | grep -E "^[^ ].*:" | while read -r line; do
71-
file=$(echo "$line" | cut -d':' -f1)
72-
echo "SF:$file"
73-
percent=$(echo "$line" | grep -oE "[0-9\.]+%" | tr -d '%')
74-
if [ -n "$percent" ]; then
75-
echo "DA:1,1"
76-
echo "LF:1"
77-
echo "LH:$percent"
78-
fi
79-
echo "end_of_record"
80-
done
81-
} > lcov.info
82-
fi
83-
else
84-
echo "luacov-reporter-lcov not found, generating simple lcov.info"
85-
{
86-
echo "TN:"
87-
grep -E "^Summary$" -A1000 luacov.report.out | grep -E "^[^ ].*:" | while read -r line; do
88-
file=$(echo "$line" | cut -d':' -f1)
89-
echo "SF:$file"
90-
percent=$(echo "$line" | grep -oE "[0-9\.]+%" | tr -d '%')
91-
if [ -n "$percent" ]; then
92-
echo "DA:1,1"
93-
echo "LF:1"
94-
echo "LH:$percent"
95-
fi
96-
echo "end_of_record"
97-
done
98-
} > lcov.info
99-
fi
65+
nix develop .#ci -c luacov
66+
67+
# Create simple lcov.info from luacov.report.out
68+
echo "Creating lcov.info from luacov.report.out"
69+
{
70+
echo "TN:"
71+
grep -E "^Summary$" -A1000 luacov.report.out | grep -E "^[^ ].*:" | while read -r line; do
72+
file=$(echo "$line" | cut -d':' -f1)
73+
echo "SF:$file"
74+
percent=$(echo "$line" | grep -oE "[0-9\.]+%" | tr -d '%')
75+
if [ -n "$percent" ]; then
76+
echo "DA:1,1"
77+
echo "LF:1"
78+
echo "LH:$percent"
79+
fi
80+
echo "end_of_record"
81+
done
82+
} > lcov.info
10083
else
10184
echo "No coverage data found in luacov.stats.out"
10285
touch lcov.info
@@ -116,10 +99,25 @@ jobs:
11699
neovim-version: ["stable"]
117100

118101
steps:
119-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
102+
- name: Checkout
103+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
120104
with:
105+
fetch-depth: 0
121106
persist-credentials: false
122107

108+
- name: Setup Nix
109+
uses: nixbuild/nix-quick-install-action@5bb6a3b3abe66fd09bbf250dce8ada94f856a703 # v30
110+
111+
- uses: nix-community/cache-nix-action@135667ec418502fa5a3598af6fb9eb733888ce6a # v6.1.3
112+
with:
113+
primary-key: nix-claudecode-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
114+
restore-prefixes-first-match: nix-claudecode-${{ runner.os }}-
115+
gc-max-store-size-linux: 2G
116+
purge: true
117+
purge-prefixes: nix-claudecode-${{ runner.os }}-
118+
purge-created: 0
119+
purge-primary-key: never
120+
123121
- name: Setup Neovim
124122
uses: rhysd/action-setup-vim@8e931b9954b19d4203d5caa5ff5521f3bc21dcc7 # v1.4.2
125123
with:
@@ -132,5 +130,4 @@ jobs:
132130
ln -s "$(pwd)" ~/.local/share/nvim/site/pack/vendor/start/claudecode.nvim
133131
134132
- name: Run integration tests
135-
run: |
136-
nvim --headless -u tests/minimal_init.lua -c "lua require('plenary.test_harness').test_directory('tests/integration', {minimal_init = 'tests/minimal_init.lua'})"
133+
run: nix develop .#ci -c nvim --headless -u tests/minimal_init.lua -c "lua require('plenary.test_harness').test_directory('tests/integration', {minimal_init = 'tests/minimal_init.lua'})"

flake.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
let
1313
pkgs = import nixpkgs {
1414
inherit system;
15+
16+
config.allowUnfreePredicate = pkg: builtins.elem (pkgs.lib.getName pkg) [
17+
"claude-code"
18+
];
1519
};
1620

1721
treefmt = treefmt-nix.lib.evalModule pkgs {
@@ -27,6 +31,26 @@
2731
};
2832
settings.formatter.shellcheck.options = [ "--exclude=SC1091,SC2016" ];
2933
};
34+
35+
# CI-specific packages (minimal set for testing and linting)
36+
ciPackages = with pkgs; [
37+
lua5_1
38+
luajitPackages.luacheck
39+
luajitPackages.busted
40+
luajitPackages.luacov
41+
neovim
42+
treefmt.config.build.wrapper
43+
];
44+
45+
# Development packages (additional tools for development)
46+
devPackages = with pkgs; [
47+
ast-grep
48+
luarocks
49+
gnumake
50+
websocat
51+
jq
52+
claude-code
53+
];
3054
in
3155
{
3256
# Format the source tree
@@ -35,22 +59,16 @@
3559
# Check formatting
3660
checks.formatting = treefmt.config.build.check self;
3761

38-
devShells.default = pkgs.mkShell {
39-
buildInputs = with pkgs; [
40-
lua5_1
41-
luajitPackages.luacheck
42-
luajitPackages.busted
43-
luajitPackages.luacov
44-
45-
ast-grep
46-
neovim
47-
luarocks
48-
gnumake
49-
websocat
50-
jq
51-
52-
treefmt.config.build.wrapper
53-
];
62+
devShells = {
63+
# Minimal CI environment
64+
ci = pkgs.mkShell {
65+
buildInputs = ciPackages;
66+
};
67+
68+
# Full development environment
69+
default = pkgs.mkShell {
70+
buildInputs = ciPackages ++ devPackages;
71+
};
5472
};
5573
}
5674
);

lua/claudecode/selection.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ function M.update_selection()
132132
end
133133

134134
local current_buf = vim.api.nvim_get_current_buf()
135+
local buf_name = vim.api.nvim_buf_get_name(current_buf)
136+
137+
-- If the buffer name starts with "✻ [Claude Code]", do not update selection
138+
if buf_name and string.sub(buf_name, 1, string.len("✻ [Claude Code]")) == "✻ [Claude Code]" then
139+
-- Optionally, cancel demotion timer like for the terminal
140+
if M.state.demotion_timer then
141+
M.state.demotion_timer:stop()
142+
M.state.demotion_timer:close()
143+
M.state.demotion_timer = nil
144+
end
145+
return
146+
end
135147

136148
-- If the current buffer is the Claude terminal, do not update selection
137149
if terminal then

0 commit comments

Comments
 (0)