Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Act configuration for local CI testing
--platform ubuntu-latest=catthehacker/ubuntu:act-latest
--pull=false
13 changes: 13 additions & 0 deletions .busted
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
return {
_all = {
coverage = false,
lpath = "lua/?.lua;lua/?/init.lua",
lua = "nlua",
pattern = ".*_spec%.lua",
ROOT = { "tests" },
verbose = true,
["suppress-pending"] = false,
["show-error-list"] = true,
},
}

36 changes: 32 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,41 @@ on:

jobs:
tests:
name: Run tests
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
neovim_version: ["nightly", "stable"]
steps:
- uses: actions/checkout@v4
- uses: rhysd/action-setup-vim@v1
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential gcc make luarocks lua5.1 liblua5.1-dev
- name: Setup Neovim
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: nightly
- name: Run Tests
run: make test
version: ${{ matrix.neovim_version }}
- name: Install test dependencies
run: |
sudo luarocks install busted
sudo luarocks install nlua
sudo luarocks install luassert
- name: Run tests
env:
NEOVIM_VERSION: ${{ matrix.neovim_version }}
run: |
set -euo pipefail
export PATH="/usr/local/bin:$PATH"

echo "Running tests for Neovim ${{ matrix.neovim_version }}..."
echo "================================================"

if [ -f "scripts/test-runner.sh" ]; then
chmod +x scripts/test-runner.sh
./scripts/test-runner.sh || exit $?
else
busted --verbose tests/ || exit $?
fi
1 change: 0 additions & 1 deletion .github/workflows/luarocks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
tags: # Will upload to luarocks.org when a tag is pushed
- "*"
pull_request: # Will test a local install without uploading to luarocks.org
workflow_dispatch:

jobs:
Expand Down
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
/.tests
/test
.env
.env.*
*.private
*.secret
.actrc.local
.luarocks/
*.rock
*.src.rock
.DS_Store
*.swp
*.swo
*~
.vscode/
.idea/
25 changes: 23 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
.PHONY: test
.PHONY: test test-verbose test-minimal test-tap test-ci test-stable test-nightly

test:
nvim -l ./tests/busted.lua tests/
@./scripts/test-runner.sh

test-verbose:
@./scripts/test-runner.sh --verbose

test-minimal:
@./scripts/test-runner.sh --minimal

test-tap:
@./scripts/test-runner.sh --tap

test-ci:
@command -v act >/dev/null 2>&1 || { echo "act is not installed"; exit 1; }
act -W .github/workflows/ci.yml

test-ci-stable:
@command -v act >/dev/null 2>&1 || { echo "act is not installed"; exit 1; }
act -W .github/workflows/ci.yml -j tests --matrix neovim_version:stable

test-ci-nightly:
@command -v act >/dev/null 2>&1 || { echo "act is not installed"; exit 1; }
act -W .github/workflows/ci.yml -j tests --matrix neovim_version:nightly
19 changes: 17 additions & 2 deletions image.nvim-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,25 @@ dependencies = {
}

source = {
url = "git://github.com/3rd/image.nvim"
url = "git://github.com/3rd/image.nvim",
}

test_dependencies = {}
test_dependencies = {
"nlua",
"busted",
"luassert",
}

test = {
type = "busted",
platforms = {
unix = {
flags = {
"--config-file=.busted",
},
},
},
}

build = {
type = "builtin",
Expand Down
79 changes: 79 additions & 0 deletions scripts/test-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
set -o pipefail

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
BOLD='\033[1m'

color() {
echo -e "${1}${2}${NC}"
}

# Header
echo ""
color "${CYAN}${BOLD}" "╔══════════════════════════════════════════════════════════════╗"
color "${CYAN}${BOLD}" "β•‘ image.nvim Test Suite β•‘"
color "${CYAN}${BOLD}" "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•"
echo ""

# check if running in CI
if [ -n "$CI" ]; then
color "${BLUE}" "Environment: GitHub Actions CI"
color "${BLUE}" "Neovim Version: ${NEOVIM_VERSION:-unknown}"
else
color "${BLUE}" "Environment: Local"
if command -v nvim &>/dev/null; then
NVIM_VERSION=$(nvim --version | head -n1)
color "${BLUE}" "Neovim Version: $NVIM_VERSION"
fi
fi

echo ""
color "${YELLOW}" "Test Files:"
color "${YELLOW}" "───────────"

# list test files
for file in tests/**/*_spec.lua; do
if [ -f "$file" ]; then
echo " β€’ $(basename $file)"
fi
done

echo ""
color "${CYAN}" "Running Tests..."
color "${CYAN}" "════════════════"
echo ""

if [ "$1" == "--tap" ]; then
# TAP
busted --output=TAP --verbose tests/
TEST_RESULT=$?
elif [ "$1" == "--minimal" ]; then
# minimal output
busted tests/
TEST_RESULT=$?
else
# default: verbose
busted --output=gtest --verbose tests/ 2>&1 | sed 's/^/ /'
TEST_RESULT=${PIPESTATUS[0]}
fi

echo ""
color "${CYAN}" "════════════════"

# summary
if [ $TEST_RESULT -eq 0 ]; then
echo ""
color "${GREEN}${BOLD}" "βœ“ All tests passed!"
echo ""
else
echo ""
color "${RED}${BOLD}" "βœ— Tests failed!"
echo ""
exit $TEST_RESULT
fi