Skip to content

Commit

Permalink
Merge branch 'main' into new-colorscheme
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesmithgh committed Dec 11, 2023
2 parents 3ab6e29 + dc49399 commit 6d5d1b0
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 66 deletions.
52 changes: 0 additions & 52 deletions .github/workflows/test.yml

This file was deleted.

100 changes: 100 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: tests
on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
workflow_dispatch:
inputs:
enable_debug_vnc:
required: false
type: boolean
default: false
enable_debug_tmate:
required: false
type: boolean
default: false
schedule:
# daily 9AM EST
- cron: "0 14 * * *"

jobs:
plenary:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Neovim nightly
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: nightly

- name: Setup Kitty
run: |
curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin launch=n
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y xfce4 libxcb-xkb1
# homebrew is not used but is required to reproduce an issue for a test case
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- name: Start Xvfb
if: ${{ ! inputs.enable_debug_vnc }}
run: |
Xvfb :1 -screen 0 1024x768x16 &
- name: (debug) Start TurboVNC
if: ${{ inputs.enable_debug_vnc }}
run: |
mkdir -p "$GITHUB_WORKSPACE/tmp"
curl -s -L https://github.com/TurboVNC/turbovnc/releases/download/3.1/turbovnc_3.1_amd64.deb -o "$GITHUB_WORKSPACE/tmp/turbovnc.deb"
cd "$GITHUB_WORKSPACE/tmp" || exit 1
sudo dpkg -i turbovnc.deb
sudo apt update
sudo apt install -f
cd "$GITHUB_WORKSPACE" || exit 1
export PATH="/opt/TurboVNC/bin:$PATH"
vncserver -SecurityTypes None
- name: (debug) Setup ngrok session
if: ${{ inputs.enable_debug_vnc }}
env:
NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
run: |
mkdir -p "$GITHUB_WORKSPACE/tmp/bin"
curl -s -L https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz -o "$GITHUB_WORKSPACE/tmp/ngrok.tgz"
cd "$GITHUB_WORKSPACE/tmp" || exit 1
tar -xvf ngrok.tgz -C "$GITHUB_WORKSPACE/tmp/bin"
cd "$GITHUB_WORKSPACE" || exit 1
export PATH="$GITHUB_WORKSPACE/tmp/bin:$PATH"
ngrok config add-authtoken "$NGROK_AUTH_TOKEN"
ngrok tcp 22 --log=stdout > "$GITHUB_WORKSPACE/tmp/ngrok.log" &
sleep 1 # wait for ngrok to start
NGROK_TLS_URL="$(curl --silent http://127.0.0.1:4040/api/tunnels | jq -r '.tunnels[0].public_url')"
host="$(echo $NGROK_TLS_URL | awk -F:// '{print $2}' | awk -F: ' {print $1}')"
port="$(echo $NGROK_TLS_URL | awk -F:// '{print $2}' | awk -F: ' {print $2}')"
printf '\n\nngrok agent running avaible at %s\n\nRun the following command on your machine:\n\n ssh -L 59000:localhost:5901 -C -N -p %s -l runner %s\n\nConnect on your machine at: localhost:59000\n\n' $NGROK_TLS_URL $port $host
- name: (debug) Setup tmate session
if: ${{ inputs.enable_debug_tmate || inputs.enable_debug_vnc }}
uses: mxschmitt/action-tmate@v3

- name: Test kitty-scrollback.nvim
run: |
# TODO: improve the env var exports, github actions are making it hard so I gave up for now
export KITTY_CONFIG_DIRECTORY="$GITHUB_WORKSPACE/tests"
export PATH=$HOME/.local/kitty.app/bin:/home/linuxbrew/.linuxbrew/bin:$PATH
export DISPLAY=:1
export PS1="\[\e[34m\]$ \[\e[m\]"
echo 'export KITTY_CONFIG_DIRECTORY="$GITHUB_WORKSPACE/tests"' >> "$HOME/.bashrc"
echo 'export PATH=$HOME/.local/kitty.app/bin:/home/linuxbrew/.linuxbrew/bin:$PATH' >> "$HOME/.bashrc"
echo 'export DISPLAY=:1' >> "$HOME/.bashrc"
echo 'export PS1="\[\e[34m\]$ \[\e[m\]"' >> "$HOME/.bashrc"
make test
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [2.4.3](https://github.com/mikesmithgh/kitty-scrollback.nvim/compare/v2.4.2...v2.4.3) (2023-12-11)


### Bug Fixes

* add kitty fallback for checkhealth ([#98](https://github.com/mikesmithgh/kitty-scrollback.nvim/issues/98)) ([6c93db4](https://github.com/mikesmithgh/kitty-scrollback.nvim/commit/6c93db4f4a82001cd1c6f3ff014481426dfa8648))

## [2.4.2](https://github.com/mikesmithgh/kitty-scrollback.nvim/compare/v2.4.1...v2.4.2) (2023-12-07)


Expand Down
17 changes: 12 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@
## Troubleshooting

### Github Actions
- Interactive debug the action by temporarily adding the build step
```yml
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
```

#### Interactive debugging

- Run the worklow [tests](https://github.com/mikesmithgh/kitty-scrollback.nvim/actions/workflows/tests.yml)
- Check `enable_debug_vnc` to enable TurboVNC, ngrok, and tmate debugging
- This allows you to connect to the Github runner via vnc (for GUI) and ssh
- Check `enable_debug_tmate` to enable tmate debugging
- This allows you to connect to the Github runner via ssh

#### Verbose logging

- Enable verbose logging by running the action with [debug logging](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging) enabled.
- This can also be achieved by setting `RUNNER_DEBUG` to `1`, `RUNNER_DEBUG=1 make test`

21 changes: 14 additions & 7 deletions lua/kitty-scrollback/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ M.generate_kittens = function(all, generate_modes)
target_gen_modes[gen_mode] = true
end

local kitty_scrollback_kitten =
vim.api.nvim_get_runtime_file('python/kitty_scrollback_nvim.py', false)[1]
local example_path =
vim.api.nvim_get_runtime_file('lua/kitty-scrollback/configs/example.lua', false)[1]
local kitty_scrollback_kitten = vim.fn.fnamemodify(
vim.api.nvim_get_runtime_file('python/kitty_scrollback_nvim.py', false)[1],
':p'
)
local example_path = vim.fn.fnamemodify(
vim.api.nvim_get_runtime_file('lua/kitty-scrollback/configs/example.lua', false)[1],
':p'
)

local action_alias = 'kitty_scrollback_nvim'
local alias_config = {
Expand Down Expand Up @@ -181,8 +185,10 @@ M.generate_kittens = function(all, generate_modes)
end

M.checkhealth = function()
local kitty_scrollback_kitten =
vim.api.nvim_get_runtime_file('python/kitty_scrollback_nvim.py', false)[1]
local kitty_scrollback_kitten = vim.fn.fnamemodify(
vim.api.nvim_get_runtime_file('python/kitty_scrollback_nvim.py', false)[1],
':p'
)
-- NOTE(#58): nvim v0.9 support
-- setup backports for v0.9 because checkhealth can be called outside of standard setup flow
if vim.fn.has('nvim-0.10') <= 0 then
Expand All @@ -191,7 +197,8 @@ M.checkhealth = function()
if vim.fn.has('nvim-0.9') > 0 then
vim
.system({
p.kitty_data.kitty_path,
-- fallback to 'kitty' because checkhealth can be called outside of standard setup flow
(p and p.kitty_data and p.kitty_data.kitty_path) and p.kitty_data.kitty_path or 'kitty',
'@',
'kitten',
kitty_scrollback_kitten,
Expand Down
43 changes: 43 additions & 0 deletions tests/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,47 @@ M.assert_screen_equals = function(actual, expected, ...)
assert(actual_rstrip == expected_rstrip, ...)
end

M.assert_screen_starts_with = function(actual, expected, ...)
local expected_rstrip = expected:gsub('%s*\n', '\n'):gsub('\n$', '')
local actual_rstrip = actual:gsub('%s*\n', '\n'):sub(1, #expected_rstrip)
M.debug({
actual = actual,
actual_rstrip = actual_rstrip,
actual_length = #actual,
actual_rstrip_length = #actual_rstrip,
expected = expected,
expected_rstrip = expected_rstrip,
expected_length = #expected,
expected_rstrip_length = #expected_rstrip,
})
if actual_rstrip ~= expected_rstrip then
print_differences(actual_rstrip, expected_rstrip)
end
assert(actual_rstrip == expected_rstrip, ...)
end

M.assert_screen_match = function(actual, pattern, ...)
local actual_rstrip = actual:gsub('%s*\n', '\n')
M.debug({
actual = actual,
actual_rstrip = actual_rstrip,
actual_length = #actual,
actual_rstrip_length = #actual_rstrip,
match = pattern,
})
assert(actual_rstrip:match(pattern), ...)
end

M.assert_screen_not_match = function(actual, pattern, ...)
local actual_rstrip = actual:gsub('%s*\n', '\n')
M.debug({
actual = actual,
actual_rstrip = actual_rstrip,
actual_length = #actual,
actual_rstrip_length = #actual_rstrip,
match = pattern,
})
assert(not actual_rstrip:match(pattern), ...)
end

return M
28 changes: 26 additions & 2 deletions tests/kitty-scrollback/kitty_scrollback_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local ksb_dir = vim.fn.fnamemodify(
)
h.debug({
ksb_dir = ksb_dir,
minimal_kitty_conf = ksb_dir .. 'tests/minimal_kitty.conf',
kitty_conf = ksb_dir .. 'tests/kitty.conf',
})

local tmpsock = h.tempsocket(ksb_dir .. 'tmp/')
Expand All @@ -25,7 +25,7 @@ local kitty_cmd = h.debug({
'kitty',
'--listen-on=unix:' .. tmpsock,
'--config',
ksb_dir .. 'tests/minimal_kitty.conf',
ksb_dir .. 'tests/kitty.conf',
'--override',
'shell=' .. shell,
'--session',
Expand All @@ -34,6 +34,7 @@ local kitty_cmd = h.debug({

describe('kitty-scrollback.nvim', function()
before_each(function()
vim.fn.mkdir(ksb_dir .. 'tests/workdir', 'p')
kitty_instance = vim.system(kitty_cmd, {
stdin = 'cd ' .. ksb_dir .. 'tests/workdir',
})
Expand Down Expand Up @@ -85,4 +86,27 @@ $ brew search a 󰄛
'kitty-scrollback.nvim content did not match the terminal screen'
)
end)

it('should successfully open checkhealth', function()
local stdtout = h.feed_kitty({
[[nvim +'lua vim.opt.rtp:append("../..") vim.opt.rtp:append("../../kitty-scrollback.nvim") require("kitty-scrollback").setup() vim.cmd("KittyScrollbackCheckHealth")']],
[[\n]], -- enter
})
h.assert_screen_not_match(
stdtout,
'ERROR',
'kitty-scrollback.nvim checkhealth had an unexpected health check ERROR'
)
h.assert_screen_starts_with(
stdtout,
[[
──────────────────────────────────────────────────────────────────────────────
kitty-scrollback: require("kitty-scrollback.health").check()
kitty-scrollback: Neovim version
]],
'kitty-scrollback.nvim checkhealth content did not start with expected content'
)
end)
end)
File renamed without changes.

0 comments on commit 6d5d1b0

Please sign in to comment.