forked from mistweaverco/kulala.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tmp): use
stdpath('cache')
for tmp files (mistweaverco#284)
* fix(tmp): use `stdpath('cache')` for tmp files This should fix: mistweaverco#282 * Add windows testrunner dockerfile * fix(ci): workflow file * refactor(ci): add optional windows test pipeline * feat(ci): windows * fix(fs): join_paths on windows * fix(ci): windows cache * fix(fs): gsub returns two params * debug(ci): windows caching * feat(tests): windows fs.join_paths * refactor(ci): tests
- Loading branch information
1 parent
69262a8
commit e1d6404
Showing
10 changed files
with
252 additions
and
66 deletions.
There are no files selected for viewing
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 @@ | ||
--- | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- '**/*.lua' | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test-linux: | ||
name: Test Code on Linux | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/mistweaverco/kulala-nvim-testrunner:latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
.tests | ||
key: ${{ runner.os }}-tests | ||
- name: Run tests | ||
run: ./scripts/tests.sh run | ||
lint: | ||
name: Lint Code | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/mistweaverco/kulala-nvim-testrunner:latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Run linter | ||
run: ./scripts/lint.sh check-code | ||
test-windows: | ||
name: Test Code on Windows | ||
runs-on: windows-latest | ||
if: ${{ github.event.label.name == 'needs-windows-test' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore cache | ||
id: cache-deps | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
.tests | ||
~\scoop | ||
~\AppData\Roaming\LJ4W | ||
~\AppData\Roaming\luarocks | ||
key: ${{ runner.os }}-tests | ||
- name: Check if cache hit | ||
if: steps.cache-deps.outputs.cache-hit == 'true' | ||
run: echo "GH_CACHE_HIT=true" >> $Env:GITHUB_ENV | ||
- name: Install dependencies | ||
run: ./scripts/install-ci-test-requirements.ps1 | ||
- name: Save cache | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: | | ||
.tests | ||
~\scoop | ||
~\AppData\Roaming\LJ4W | ||
~\AppData\Roaming\luarocks | ||
key: ${{ runner.os }}-tests | ||
- name: Run tests | ||
run: ./scripts/tests.ps1 |
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 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
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,44 @@ | ||
$Env:KULALA_ROOT_DIR = (Get-Location).Path | ||
|
||
if ($Env:GH_CACHE_HIT -eq $null) { | ||
mkdir .tests | ||
} | ||
|
||
cd .tests | ||
|
||
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser | ||
|
||
if ($Env:GH_CACHE_HIT -eq $null) { | ||
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression | ||
scoop install main/git | ||
scoop install main/neovim@0.10.2 | ||
} else { | ||
$Env:PATH = "$Env:USERPROFILE\scoop\shims;$Env:USERPROFILE\scoop\apps\git\current\cmd;$Env:USERPROFILE\scoop\apps\neovim\current\bin;$Env:PATH" | ||
} | ||
|
||
if ($Env:GH_CACHE_HIT -eq $null) { | ||
Invoke-RestMethod -Uri https://github.com/mistweaverco/luajit-for-win64/archive/refs/tags/v0.0.2.zip -outfile luajit.zip | ||
7z x luajit.zip | ||
RM luajit.zip | ||
cd luajit-for-win64-0.0.2 | ||
.\luajit-for-win64.cmd | ||
} else { | ||
cd luajit-for-win64-0.0.2 | ||
} | ||
|
||
$Env:KULALA_LUA_DIR = (Get-Location).Path | ||
|
||
$Env:PATH = "$Env:KULALA_LUA_DIR\tools\cmd;$Env:KULALA_LUA_DIR\tools\PortableGit\mingw64\bin;$Env:KULALA_LUA_DIR\tools\PortableGit\usr\bin;$Env:KULALA_LUA_DIR\tools\mingw\bin;$Env:KULALA_LUA_DIR\lib;$Env:KULALA_LUA_DIR\bin;$Env:APPDATA\LJ4W\LuaRocks\bin;$Env:PATH" | ||
$Env:LUA_PATH = "$Env:KULALA_LUA_DIR\lua\?.lua;$Env:KULALA_LUA_DIR\lua\?\init.lua;$Env:APPDATA\luarocks\share\lua\5.1\?.lua;$Env:APPDATA\luarocks\share\lua\5.1\?\init.lua;$Env:LUA_PATH" | ||
$Env:LUA_CPATH = "$Env:APPDATA\luarocks;$Env:APPDATA\luarocks\lib\lua\5.1\?.dll;$Env:LUA_CPATH" | ||
|
||
if ($Env:GH_CACHE_HIT -eq $null) { | ||
luarocks install --lua-version 5.1 busted | ||
} | ||
|
||
# Persist the Environment Variables | ||
"PATH=$Env:Path" >> $Env:GITHUB_ENV | ||
"LUA_PATH=$Env:LUA_PATH" >> $Env:GITHUB_ENV | ||
"LUA_CPATH=$Env:LUA_CPATH" >> $Env:GITHUB_ENV | ||
|
||
cd $Env:KULALA_ROOT_DIR |
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,2 @@ | ||
nvim --version | ||
nvim -l tests/minit.lua tests |
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,4 +1,46 @@ | ||
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 | ||
# FROM mcr.microsoft.com/windows/nanoserver:20H2-amd64 | ||
FROM mcr.microsoft.com/powershell:lts-windowsservercore-1809 | ||
|
||
SHELL ["pwsh", "-Command"] | ||
|
||
USER ContainerAdministrator | ||
WORKDIR C:\\Users\\ContainerAdministrator\\AppData\\Local\\nvim | ||
|
||
WORKDIR "C:\\kulala.nvim" | ||
|
||
RUN Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser | ||
RUN Invoke-RestMethod -Uri https://get.scoop.sh -outfile 'install.ps1' | ||
RUN .\install.ps1 -RunAsAdmin | ||
|
||
# required before add extras | ||
RUN scoop install main/git | ||
|
||
# add for extras suggested by neovim | ||
RUN scoop bucket add extras | ||
|
||
RUN scoop install extras/vcredist2022 | ||
RUN scoop install main/[email protected] | ||
|
||
WORKDIR "C:\\luajjt" | ||
|
||
RUN Invoke-RestMethod -Uri https://github.com/mistweaverco/luajit-for-win64/archive/refs/tags/v0.0.2.zip -outfile luajit.zip | ||
RUN 7z x luajit.zip | ||
|
||
WORKDIR "C:\\luajjt\luajit-for-win64-0.0.2" | ||
|
||
RUN .\luajit-for-win64.cmd | ||
|
||
RUN setx /M KULALA_LUA_DIR \"C:\luajjt\luajit-for-win64-0.0.2\" | ||
|
||
RUN setx /M PATH \"$Env:KULALA_LUA_DIR\tools\cmd;$Env:KULALA_LUA_DIR\tools\PortableGit\mingw64\bin;$Env:KULALA_LUA_DIR\tools\PortableGit\usr\bin;$Env:KULALA_LUA_DIR\tools\mingw\bin;$Env:KULALA_LUA_DIR\lib;$Env:KULALA_LUA_DIR\bin;$Env:APPDATA\LJ4W\LuaRocks\bin;$Env:path\" | ||
|
||
RUN setx /M LUA_PATH \"$Env:KULALA_LUA_DIR\lua\?.lua;$Env:KULALA_LUA_DIR\lua\?\init.lua;$Env:APPDATA\luarocks\share\lua\5.1\?.lua;$Env:APPDATA\luarocks\share\lua\5.1\?\init.lua;$Env:LUA_PATH\" | ||
RUN setx /M LUA_CPATH \"$Env:APPDATA\luarocks;$Env:APPDATA\luarocks\lib\lua\5.1\?.dll;$Env:LUA_CPATH\" | ||
|
||
RUN luarocks install --lua-version 5.1 busted | ||
|
||
WORKDIR "C:\\kulala.nvim" | ||
|
||
RUN git config --global safe.directory '*' | ||
RUN git config --global core.autocrlf true | ||
|
||
ENTRYPOINT ["pwsh"] |
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,55 @@ | ||
local Fs = require("kulala.utils.fs") | ||
|
||
local assert = require("luassert") | ||
|
||
describe("kulala.utils.fs", function() | ||
-- restore all changed done by luassert before each test run | ||
local snapshot | ||
|
||
before_each(function() | ||
snapshot = assert:snapshot() | ||
end) | ||
|
||
after_each(function() | ||
snapshot:revert() | ||
end) | ||
|
||
describe("join_paths on windows", function() | ||
Fs.os = "windows" | ||
Fs.ps = "\\" | ||
it("joins mixed on windows", function() | ||
local expected = "C:\\a\\b\\c" | ||
local actual = Fs.join_paths("C:\\a", "b", "c") | ||
assert.are.same(expected, actual) | ||
end) | ||
it("joins no-mixed on windows", function() | ||
local expected = "C:\\a\\b\\c" | ||
local actual = Fs.join_paths("C:\\a", "b", "c") | ||
assert.are.same(expected, actual) | ||
end) | ||
it("fixes ps on windows", function() | ||
local expected = "C:\\a\\user\\bin\\blah\\blubb" | ||
local actual = Fs.join_paths("C:\\a", "user/bin", "blah/blubb") | ||
assert.are.same(expected, actual) | ||
end) | ||
end) | ||
describe("join_paths on linux", function() | ||
Fs.os = "unix" | ||
Fs.ps = "/" | ||
it("joins mixed on unix", function() | ||
local expected = "/a/b/c" | ||
local actual = Fs.join_paths("/a", "b", "c") | ||
assert.are.same(expected, actual) | ||
end) | ||
it("joins no-mixed on unix", function() | ||
local expected = "/a/b/c" | ||
local actual = Fs.join_paths("/a", "b", "c") | ||
assert.are.same(expected, actual) | ||
end) | ||
it("joins more mixed on unix", function() | ||
local expected = "/a/user/bin/blah/blubb" | ||
local actual = Fs.join_paths("/a", "user/bin", "blah/blubb") | ||
assert.are.same(expected, actual) | ||
end) | ||
end) | ||
end) |