-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82a3aac
commit 684ccbd
Showing
6 changed files
with
96 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,40 @@ | ||
name: kulala tests | ||
--- | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: ~ | ||
pull_request_review: | ||
types: [submitted] | ||
|
||
jobs: | ||
tests: | ||
name: tests | ||
if: github.event.review.state == 'approved' | ||
name: Tests | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-22.04 | ||
rev: v0.10.0/nvim-linux64.tar.gz | ||
rev: v0.10.0/nvim.appimage | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore cache. | ||
- name: Restore cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: _neovim | ||
path: | | ||
_neovim | ||
~/.local/share/nvim/site/pack/vendor/start | ||
key: ${{ runner.os }}-${{ matrix.rev }} | ||
|
||
- name: Prepare dependencies | ||
run: | | ||
test -d _neovim || { | ||
mkdir -p _neovim | ||
curl -sL "https://github.com/neovim/neovim/releases/download/${{ matrix.rev }}" | tar xzf - --strip-components=1 -C "${PWD}/_neovim" | ||
} | ||
mkdir -p ~/.local/share/nvim/site/pack/vendor/start | ||
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim | ||
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start | ||
export PATH="${PWD}/_neovim/bin:${PATH}" | ||
export VIM="${PWD}/_neovim/share/nvim/runtime" | ||
nvim --headless -c 'TSInstallSync lua | quit' | ||
env: | ||
NVIM_DL_BASE: https://github.com/neovim/neovim/releases/download/ | ||
run: ./scripts/tests.sh prepare \ | ||
${NVIM_DL_BASE}${{ matrix.rev }} | ||
|
||
- name: Run tests | ||
env: | ||
PATH: "${PWD}/_neovim/bin:${PATH}" | ||
VIM: "${PWD}/_neovim/share/nvim/runtime" | ||
run: | | ||
export PATH="${PWD}/_neovim/bin:${PATH}" | ||
export VIM="${PWD}/_neovim/share/nvim/runtime" | ||
nvim --version | ||
/bin/bash ./scripts/test | ||
./scripts/tests.sh run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ http-client.env.json | |
*.http | ||
*graphql-schema.json | ||
/http-examples | ||
/_neovim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copy from MIT licensed neotest plugin: | ||
# https://github.com/nvim-neotest/neotest/blob/958a6bff41c7086fe8b46f7f320d0fd073cfc6a0/scripts/test | ||
|
||
|
||
prepare() { | ||
local download_url=$1 | ||
|
||
if [[ ! -d _neovim ]] && [[ -n $download_url ]]; then | ||
mkdir -p _neovim && curl -sL -o _neovim/nvim "$download_url" && chmod +x _neovim/nvim | ||
_neovim/nvim --headless -c 'TSInstallSync lua | quit' | ||
fi | ||
if [[ ! -d ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim ]]; then | ||
git clone --depth 1 \ | ||
https://github.com/nvim-lua/plenary.nvim \ | ||
~/.local/share/nvim/site/pack/vendor/start/plenary.nvim | ||
fi | ||
if [[ ! -d ~/.local/share/nvim/site/pack/vendor/start/kulala.nvim ]]; then | ||
ln -s "$(pwd)" ~/.local/share/nvim/site/pack/vendor/start | ||
fi | ||
} | ||
|
||
run() { | ||
if [[ -f _neovim/nvim ]]; then | ||
nvim() { | ||
_neovim/nvim "$@" | ||
} | ||
fi | ||
|
||
local tempfile | ||
tempfile=$(mktemp) | ||
|
||
nvim --version | ||
|
||
if [[ -n $2 ]]; then | ||
nvim --headless --noplugin -u tests/init.vim -c "PlenaryBustedFile $1" | tee "${tempfile}" | ||
else | ||
nvim --headless --noplugin -u tests/init.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.vim'}" | tee "${tempfile}" | ||
fi | ||
|
||
# Plenary doesn't emit exit code 1 when tests have errors during setup | ||
errors=$(sed 's/\x1b\[[0-9;]*m//g' "${tempfile}" | awk '/(Errors|Failed) :/ {print $3}' | grep -v '0') | ||
|
||
if [[ -n $errors ]]; then | ||
echo "Tests failed" | ||
exit 1 | ||
fi | ||
|
||
exit 0 | ||
} | ||
|
||
main() { | ||
local action="$1" | ||
shift | ||
local args=$* | ||
case $action in | ||
"run") | ||
run "$args" | ||
;; | ||
"prepare") | ||
prepare "$args" | ||
;; | ||
*) | ||
echo "Invalid action" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
} | ||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters