Skip to content

Commit

Permalink
Migrate tests to GitHub actions (#32)
Browse files Browse the repository at this point in the history
* Run tests through github actions
* Update dependencies
* DEP: Rename VimFlavor to Flavorfile
* DOC: Add badges to doc
* TST: Don't terminate vim surrounding w/ <++>

    Vim9 new vim indent script expect nothing after `endif`.
    `endif<++>` would be incorrectly indented.

* Remove neovim from test matrix

    ...as vimrunner and neovim are not compatible
  • Loading branch information
LucHermitte authored Aug 25, 2024
1 parent e785249 commit b74734e
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 30 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
test:
name: "test on ${{ matrix.os }} ; ${{ matrix.neovim && 'neovim' || 'vim' }}"

strategy:
matrix:
# Testing doesn't seem to work on Windows: output log file
# cannot be read...
# os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-latest]
neovim: [false]
# neovim: [false, true]
# TODO: Test different flavours of Vim...

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Setup Vim
uses: rhysd/action-setup-vim@v1
# uses: thinca/action-setup-vim@v2
id: vim
with:
neovim: ${{matrix.neovim }}
configure-args: |
--with-features=huge
- name: Run tests on Linux
if: runner.os == 'Linux' # headless execution is required on Linux
run: |
bundle list
xvfb-run bundle exec rake ci
- name: Run tests on ${{ matrix.os }}
if: runner.os != 'Linux'
run: |
bundle exec rake ci
File renamed without changes.
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

gem 'rspec', '~> 3.9.0'
gem 'vimrunner', '~> 0.3.4'
gem 'rspec', '~> 3.13.0'
gem 'vimrunner', '~> 0.3.5'
gem 'rake', '~> 13.0.1'
gem 'vim-flavor', '~> 2.2.2'
gem 'vim-flavor', '~> 4.0.3'
45 changes: 29 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# lh-brackets [![Last release](https://img.shields.io/github/tag/LucHermitte/lh-brackets.svg)](https://github.com/LucHermitte/lh-brackets/releases) [![Build Status](https://secure.travis-ci.org/LucHermitte/lh-brackets.png?branch=master)](http://travis-ci.org/LucHermitte/lh-brackets) [![Project Stats](https://www.openhub.net/p/21020/widgets/project_thin_badge.gif)](https://www.openhub.net/p/21020)
# lh-brackets [![Last release][Releases-badge]][Releases-url] [![Build Status][gh-action-badge]][gh-action-result] [![Project Stats][openhub-badge]][openhub-url]

[Releases-badge]: https://img.shields.io/github/tag/LucHermitte/lh-brackets.svg
[Releases-url]: https://github.com/LucHermitte/lh-brackets/tags
[gh-action-badge]: ./../../actions/workflows/tests.yml/badge.svg?branch=master "Test"
[gh-action-result]: ./../../actions/workflows/tests.yml?query=branch%3Amaster
[openhub-badge]: https://www.openhub.net/p/21020/widgets/project_thin_badge.gif
[openhub-url]: https://www.openhub.net/p/21020

## Features

Expand Down Expand Up @@ -111,27 +118,33 @@ As [lh-vim-lib](http://github.com/LucHermitte/lh-vim-lib), map-tools provides a
| `lh#map#eat_char()`, `:I(nore)abbr` | Permits to define abbreviations that do not insert a whitespace when the `<space>` key is used to trigger the abbreviation |
| `lh#map#insert_seq()` | High level function that interprets `!.*!` mappings, and take the context into account |


# Installation
* Requirements: Vim 7.+ (7.4-849 in order to support redo), [lh-vim-lib](http://github.com/LucHermitte/lh-vim-lib) v5.3.0+, [lh-style](http://github.com/LucHermitte/lh-style) v1.0.0+ for unit testing.
* With [vim-addon-manager](https://github.com/MarcWeber/vim-addon-manager), install lh-brackets (this is the preferred method because of the dependencies)
```vim
ActivateAddons lh-brackets
```

```vim
ActivateAddons lh-brackets
```
* or with [vim-flavor](https://github.com/kana/vim-flavor) (which also support dependencies)
```
flavor 'LucHermitte/lh-brackets'
```
```
flavor 'LucHermitte/lh-brackets'
```
* or you can clone the git repositories
```bash
git clone [email protected]:LucHermitte/lh-vim-lib.git
git clone [email protected]:LucHermitte/lh-brackets.git
```
```bash
git clone [email protected]:LucHermitte/lh-vim-lib.git
git clone [email protected]:LucHermitte/lh-brackets.git
```
* or with Vundle/NeoBundle:
```vim
Bundle 'LucHermitte/lh-vim-lib'
Bundle 'LucHermitte/lh-brackets'
```
```vim
Bundle 'LucHermitte/lh-vim-lib'
Bundle 'LucHermitte/lh-brackets'
```
## Credits
* This bracketing system is actually a variation on [Stephen Riehm's original bracketing system](http://mywebpage.netscape.com/bbenjif/vim/Riehm/doc/) ;
Expand Down
5 changes: 2 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ task :test => :spec
task :spec do
# 'spec' is implicitly run as well
# sh 'rspec --require spec_helper'
sh 'rspec ~/.vim-flavor/repos/LucHermitte_vim-UT/spec/UT_spec_v2.rb'
sh "bundle exec rspec ~/.vim-flavor/repos/LucHermitte_vim-UT/spec/UT_spec_v2.rb"
end


task :install do
sh 'cat VimFlavor >> tests/VimFlavor'
sh 'cat Flavorfile >> tests/Flavorfile'
sh 'cd tests && bundle exec vim-flavor install'
end
33 changes: 30 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,39 @@ def runtime(script)
command("runtime #{script_path}")
end
end

module Platform
# For tests use in order of priority:
# 1. gvim -- when available
# 2. vim -- if possible
# nvim is not compatible with vimrunner, let's ignore it now
def best_vim
prefered_vims.find { |vim| suitable?(vim) } or raise NoSuitableVimError
end
private

def prefered_vims
gvims + %w( vim )
end
end

end

Vimrunner::RSpec.configure do |config|
# Use a single Vim instance for the test suite. Set to false to use an
# instance per test (slower, but can be easier to manage).
config.reuse_server = true

vim_plugin_path = File.expand_path('.')
vim_flavor_path = ENV['HOME']+'/.vim/flavors'

# Use different vimrc in order to see packages installed by vim-flavor
vimrc = File.expand_path('../support/test.vimrc', __FILE__)

# Decide how to start a Vim instance. In this block, an instance
# should be spawned and set up with anything project-specific.
config.start_vim do
vim = Vimrunner.start_gvim
# vim = Vimrunner.start_vim
vim = Vimrunner::Server.new(:executable => Vimrunner::Platform.best_vim, :vimrc => vimrc).start
vim.add_plugin(vim_flavor_path, 'bootstrap.vim')
vim.prepend_runtimepath(vim_plugin_path)

Expand All @@ -47,19 +69,24 @@ def runtime(script)
# lh-brackets
vim_brackets_path = File.expand_path('../../../lh-brackets', __FILE__)
vim.prepend_runtimepath(vim_brackets_path)
# pp vim.echo('"RTP -> " . &rtp')
# pp vim.echo('"packages -> " . &pp')
# pp vim.echo('execute("scriptnames")')
vim.command('runtime plugin/misc_map.vim') # Inoreab
vim.command('runtime plugin/common_brackets.vim') # Brackets
pp vim.echo('execute("scriptnames")')
vim.command('runtime plugin/bracketing.base.vim') # !jump!
vim.command('vmap <silent> !jump! <Plug>MarkersJumpF')
vim.command('imap <silent> !jump! <Plug>MarkersJumpF')
vim.command('nmap <silent> !jump! <Plug>MarkersJumpF')

pp vim.echo('&rtp')
pp vim.echo('"RTP -> " . &rtp')

has_redo = vim.echo('has("patch-7.4.849")')
if has_redo != "1"
puts "WARNING: this flavor of vim won't permit lh-brackets to support redo"
end
# The returned value is the Client available in the tests.
vim
end
end
Expand Down
10 changes: 10 additions & 0 deletions spec/support/test.vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
" Special vimrc to used instead of vimrunner vimrc which disable all plugins
" It should automatically load plugins installed as packages by vim-flavor
set nocompatible

filetype plugin on
filetype indent on
syntax on

set noswapfile nobackup
set loadplugins
2 changes: 1 addition & 1 deletion spec/support/vim-snippets.vim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
" Code from lh-misc to test surrounding
xnoremap <buffer> <silent> ,if
\ <c-\><c-n>@=lh#map#surround('if !cursorhere!', 'endif!mark!',
\ <c-\><c-n>@=lh#map#surround('if !cursorhere!', 'endif',
\ 1, 1, '', 1, 'if ')<cr>
4 changes: 2 additions & 2 deletions spec/vim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
if foo
let s:fix_indent = s:old_indent - crt_indent
call s:Verbose('fix indent <- %1 (old_indent:%2 - crt_indent:%3)', s:fix_indent, s:old_indent, crt_indent)
endif<++>
endif
endfunction
EOF
end
Expand All @@ -66,7 +66,7 @@
let crt_indent = indent(s:goto_lin)
if foo
let s:fix_indent = s:old_indent - crt_indent
endif<++>
endif
call s:Verbose('fix indent <- %1 (old_indent:%2 - crt_indent:%3)', s:fix_indent, s:old_indent, crt_indent)
endfunction
EOF
Expand Down
2 changes: 2 additions & 0 deletions tests/Flavorfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flavor 'LucHermitte/vim-UT', '>= 2.0.8'
flavor 'LucHermitte/lh-style'
2 changes: 0 additions & 2 deletions tests/VimFlavor

This file was deleted.

0 comments on commit b74734e

Please sign in to comment.