build: rework ci tests to include windows (#3011)

This commit is contained in:
James Trew 2024-04-13 11:27:53 -04:00 committed by GitHub
parent 5a701e9990
commit 4d4ade7f2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 67 additions and 50 deletions

View file

@ -9,48 +9,33 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-22.04, macos-12, windows-2022]
rev: [nightly, v0.9.0]
include: include:
- os: ubuntu-22.04 - os: ubuntu-22.04
rev: nightly/nvim-linux64.tar.gz install-rg: sudo apt-get update && sudo apt-get install -y ripgrep
manager: sudo apt-get
packages: -y ripgrep
- os: ubuntu-22.04
rev: v0.9.0/nvim-linux64.tar.gz
manager: sudo apt-get
packages: -y ripgrep
- os: macos-12 - os: macos-12
rev: nightly/nvim-macos.tar.gz install-rg: brew update && brew install ripgrep
manager: brew - os: windows-2022
packages: ripgrep install-rg: choco install ripgrep
- os: macos-12
rev: v0.9.0/nvim-macos.tar.gz
manager: brew
packages: ripgrep
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: date +%F > todays-date
- name: Restore from todays cache - uses: rhysd/action-setup-vim@v1
uses: actions/cache@v3
with: with:
path: _neovim neovim: true
key: ${{ runner.os }}-${{ matrix.rev }}-${{ hashFiles('todays-date') }} version: ${{ matrix.rev }}
- name: Prepare - name: Prepare
run: | run: |
${{ matrix.manager }} update ${{ matrix.install-rg }}
${{ matrix.manager }} install ${{ matrix.packages }} rg --version
test -d _neovim || {
mkdir -p _neovim git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ../plenary.nvim
curl -sL "https://github.com/neovim/neovim/releases/download/${{ matrix.rev }}" | tar xzf - --strip-components=1 -C "${PWD}/_neovim" git clone --depth 1 https://github.com/nvim-tree/nvim-web-devicons ../nvim-web-devicons
}
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
git clone --depth 1 https://github.com/nvim-tree/nvim-web-devicons ~/.local/share/nvim/site/pack/vendor/start/nvim-web-devicons
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
- name: Run tests - name: Run tests
run: | run: |
export PATH="${PWD}/_neovim/bin:${PATH}"
export VIM="${PWD}/_neovim/share/nvim/runtime"
nvim --version nvim --version
make test make test

View file

@ -14,12 +14,12 @@ jobs:
matrix: matrix:
include: include:
- os: ubuntu-22.04 - os: ubuntu-22.04
url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz url: https://github.com/neovim/neovim/releases/download/v0.9.5/nvim-linux64.tar.gz
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: date +%F > todays-date - run: date +%F > todays-date
- name: Restore cache for today's nightly. - name: Restore cache for today's nightly.
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: _neovim path: _neovim
key: ${{ runner.os }}-${{ matrix.url }}-${{ hashFiles('todays-date') }} key: ${{ runner.os }}-${{ matrix.url }}-${{ hashFiles('todays-date') }}

View file

@ -7,7 +7,7 @@ jobs:
name: Luacheck name: Luacheck
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Prepare - name: Prepare
run: | run: |
@ -22,8 +22,8 @@ jobs:
name: stylua name: stylua
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: JohnnyMorganz/stylua-action@v3 - uses: JohnnyMorganz/stylua-action@v4
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
version: latest version: latest

View file

@ -7,7 +7,7 @@ jobs:
luarocks-upload: luarocks-upload:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: LuaRocks Upload - name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v1.0.2 uses: nvim-neorocks/luarocks-tag-release@v1.0.2
env: env:
@ -15,8 +15,8 @@ jobs:
with: with:
summary: "Find, Filter, Preview, Pick. All lua, all the time." summary: "Find, Filter, Preview, Pick. All lua, all the time."
detailed_description: | detailed_description: |
A highly extendable fuzzy finder over lists. A highly extendable fuzzy finder over lists.
Built on the latest awesome features from neovim core. Built on the latest awesome features from neovim core.
Telescope is centered around modularity, allowing for easy customization. Telescope is centered around modularity, allowing for easy customization.
dependencies: | dependencies: |
plenary.nvim plenary.nvim

View file

@ -1,3 +1,5 @@
.PHONY: test lint docgen
test: test:
nvim --headless --noplugin -u scripts/minimal_init.vim -c "PlenaryBustedDirectory lua/tests/automated/ { minimal_init = './scripts/minimal_init.vim' }" nvim --headless --noplugin -u scripts/minimal_init.vim -c "PlenaryBustedDirectory lua/tests/automated/ { minimal_init = './scripts/minimal_init.vim' }"

View file

@ -2536,6 +2536,31 @@ UTILS *telescope.utils*
Utilities for writing telescope pickers Utilities for writing telescope pickers
utils.path_expand({path}) *telescope.utils.path_expand()*
Hybrid of `vim.fn.expand()` and custom `vim.fs.normalize()`
Paths starting with '%', '#' or '<' are expanded with `vim.fn.expand()`.
Otherwise avoids using `vim.fn.expand()` due to its overly aggressive
expansion behavior which can sometimes lead to errors or the creation of
non-existent paths when dealing with valid absolute paths.
Other paths will have '~' and environment variables expanded. Unlike
`vim.fs.normalize()`, backslashes are preserved. This has better
compatibility with `plenary.path` and also avoids mangling valid Unix paths
with literal backslashes.
Trailing slashes are trimmed. With the exception of root paths. eg. `/` on
Unix or `C:\` on Windows
Parameters: ~
{path} (string)
Return: ~
string
utils.transform_path({opts}, {path}) *telescope.utils.transform_path()* utils.transform_path({opts}, {path}) *telescope.utils.transform_path()*
Transform path is a util function that formats a path based on path_display Transform path is a util function that formats a path based on path_display
found in `opts` or the default value from config. It is meant to be used in found in `opts` or the default value from config. It is meant to be used in
@ -2546,9 +2571,9 @@ utils.transform_path({opts}, {path}) *telescope.utils.transform_path()*
Parameters: ~ Parameters: ~
{opts} (table) The opts the users passed into the picker. Might {opts} (table) The opts the users passed into the picker. Might
contains a path_display key contains a path_display key
{path} (string) The path that should be formatted {path} (string|nil) The path that should be formatted
Return: ~ Return: ~
string: The transformed path ready to be displayed string: The transformed path ready to be displayed

View file

@ -269,7 +269,7 @@ end
--- this function outside of telescope might yield to undefined behavior and will --- this function outside of telescope might yield to undefined behavior and will
--- not be addressed by us --- not be addressed by us
---@param opts table: The opts the users passed into the picker. Might contains a path_display key ---@param opts table: The opts the users passed into the picker. Might contains a path_display key
---@param path string?: The path that should be formatted ---@param path string|nil: The path that should be formatted
---@return string: The transformed path ready to be displayed ---@return string: The transformed path ready to be displayed
utils.transform_path = function(opts, path) utils.transform_path = function(opts, path)
if path == nil then if path == nil then

View file

@ -1,5 +1,5 @@
-- Just skip on mac, it has flaky CI for some reason -- Just skip on mac, it has flaky CI for some reason
if vim.fn.has "mac" == 1 then if vim.fn.has "mac" == 1 or require("telescope.utils").iswin then
return return
end end

View file

@ -1,7 +1,12 @@
local picker = require "telescope.pickers" local picker = require "telescope.pickers"
local Path = require "plenary.path"
local eq = assert.are.same local eq = assert.are.same
local function new_path(unix_path)
return Path:new(unpack(vim.split(unix_path, "/"))).filename
end
describe("telescope", function() describe("telescope", function()
describe("Picker", function() describe("Picker", function()
describe("window_dimensions", function() describe("window_dimensions", function()
@ -84,8 +89,8 @@ describe("telescope", function()
it("sorts matches after last os sep better", function() it("sorts matches after last os sep better", function()
local sorter = require("telescope.sorters").get_fuzzy_file() local sorter = require("telescope.sorters").get_fuzzy_file()
local better_match = sorter:score("aaa", { ordinal = "bbb/aaa" }) local better_match = sorter:score("aaa", { ordinal = new_path "bbb/aaa" })
local worse_match = sorter:score("aaa", { ordinal = "aaa/bbb" }) local worse_match = sorter:score("aaa", { ordinal = new_path "aaa/bbb" })
assert(better_match < worse_match, "Final match should be stronger") assert(better_match < worse_match, "Final match should be stronger")
end) end)
@ -103,6 +108,7 @@ describe("telescope", function()
describe("fzy", function() describe("fzy", function()
local sorter = require("telescope.sorters").get_fzy_sorter() local sorter = require("telescope.sorters").get_fzy_sorter()
local function score(prompt, line) local function score(prompt, line)
line = new_path(line)
return sorter:score(prompt, { ordinal = line }, function(val) return sorter:score(prompt, { ordinal = line }, function(val)
return val return val
end, function() end, function()
@ -171,7 +177,7 @@ describe("telescope", function()
end) end)
local function positions(prompt, line) local function positions(prompt, line)
return sorter:highlighter(prompt, line) return sorter:highlighter(prompt, new_path(line))
end end
describe("positioning", function() describe("positioning", function()

View file

@ -4,6 +4,5 @@ set rtp+=../tree-sitter-lua/
runtime! plugin/plenary.vim runtime! plugin/plenary.vim
runtime! plugin/telescope.lua runtime! plugin/telescope.lua
runtime! plugin/ts_lua.vim
let g:telescope_test_delay = 100 let g:telescope_test_delay = 100