-
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 6cacd48
Showing
6 changed files
with
89 additions
and
48 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,35 @@ | ||
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' | ||
run: | # TODO: Cache apt dependencies | ||
sudo apt-get update && sudo apt-get install -y libfuse2 | ||
./scripts/tests.sh prepare ${{ matrix.rev }} | ||
- name: Run tests | ||
run: | | ||
export PATH="${PWD}/_neovim/bin:${PATH}" | ||
export VIM="${PWD}/_neovim/share/nvim/runtime" | ||
nvim --version | ||
/bin/bash ./scripts/test | ||
run: ./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,68 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copy from MIT licensed neotest plugin: | ||
# https://github.com/nvim-neotest/neotest/blob/958a6bff41c7086fe8b46f7f320d0fd073cfc6a0/scripts/test | ||
|
||
NVIM_DL_BASE="https://github.com/neovim/neovim/releases/download/" | ||
|
||
prepare() { | ||
local version=$1 | ||
|
||
if [[ ! -f _neovim/nvim ]] && [[ -n $version ]]; then | ||
mkdir -p _neovim && curl -sL -o _neovim/nvim "${NVIM_DL_BASE}${version}" && 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() { | ||
type _neovim/nvim && nvim() { _neovim/nvim "$@"; } | ||
|
||
local tempfile | ||
tempfile=$(mktemp) | ||
|
||
nvim --version | ||
|
||
if [[ -n $1 ]]; 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