From f08590be32afdb3306a61fa7da3000e6ea19ae93 Mon Sep 17 00:00:00 2001 From: Null Chilly <56817415+nullchilly@users.noreply.github.com> Date: Thu, 2 Mar 2023 01:06:48 +0700 Subject: [PATCH] refactor(tests): use package manager (#422) --- .github/workflows/neovim.yml | 56 ++++++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 46 ++--------------------------- .gitignore | 1 + tests/init.lua | 27 +++++++++++++++++ 4 files changed, 86 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/neovim.yml create mode 100644 tests/init.lua diff --git a/.github/workflows/neovim.yml b/.github/workflows/neovim.yml new file mode 100644 index 0000000..9733611 --- /dev/null +++ b/.github/workflows/neovim.yml @@ -0,0 +1,56 @@ +--- +name: Neovim +on: + pull_request: ~ + push: + paths-ignore: + - "*.md" + branches: + - main + +jobs: + ubuntu: + name: Ubuntu + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Install Neovim + shell: bash + run: | + wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.deb -O /tmp/nvim.deb + sudo dpkg -i /tmp/nvim.deb + - name: Run neovim + run: | + nvim --version + nvim --headless -u tests/init.lua +q + macos: + name: Macos + runs-on: macos-latest + + steps: + - uses: actions/checkout@v3 + - name: Install Neovim + run: | + wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz + xattr -c ./nvim-macos.tar.gz + tar xzvf nvim-macos.tar.gz &> /dev/null + ln -s $(pwd)/nvim-macos/bin/nvim /usr/local/bin/nvim + - name: Run neovim + run: | + nvim --version + nvim --headless -u tests/init.lua +q + windows: + name: Windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - name: Install Neovim + run: | + C:\msys64\usr\bin\wget.exe -q https://github.com/neovim/neovim/releases/download/nightly/nvim-win64.zip + 7z x nvim-win64.zip + Add-Content $env:GITHUB_PATH ".\nvim-win64\bin\" + - name: Run neovim + run: | + nvim --version + nvim --headless -u tests/init.lua +q diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ccb367c..d2d2f58 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ on: jobs: ubuntu: - name: Run tests on Ubuntu + name: Plenary runs-on: ubuntu-latest steps: @@ -23,51 +23,9 @@ jobs: - name: Fetch dependencies run: | 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/kyazdani42/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 run: | nvim --version [ ! -d tests ] && exit 0 - nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal_init.vim', sequential = true}" - macos: - name: Run tests on Macos - runs-on: macos-latest - - steps: - - uses: actions/checkout@v3 - - name: Install Neovim - run: | - wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz - xattr -c ./nvim-macos.tar.gz - tar xzvf nvim-macos.tar.gz &> /dev/null - ln -s $(pwd)/nvim-macos/bin/nvim /usr/local/bin/nvim - - name: Fetch dependencies - run: | - 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/kyazdani42/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 - run: | - nvim --version - [ ! -d tests ] && exit 0 - nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal_init.vim', sequential = true}" - windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - name: Install Neovim - run: | - C:\msys64\usr\bin\wget.exe -q https://github.com/neovim/neovim/releases/download/nightly/nvim-win64.zip - 7z x nvim-win64.zip - Add-Content $env:GITHUB_PATH ".\nvim-win64\bin\" - # - name: Fetch dependencies - # run: | - # 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/kyazdani42/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 - run: | - nvim --version - nvim --headless -c "0cq" +q # PLENNARY DOESN'T WORK ON WINDOWS - # nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal_init.vim', sequential = true}" + nvim --headless -u tests/minimal_init.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal_init.vim', sequential = true}" diff --git a/.gitignore b/.gitignore index 52566a0..4ebdfaa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ doc/tags .vscode/ .DS_Store +.repro diff --git a/tests/init.lua b/tests/init.lua new file mode 100644 index 0000000..6db3de3 --- /dev/null +++ b/tests/init.lua @@ -0,0 +1,27 @@ +local status, error = pcall(function() + local root = vim.fn.fnamemodify(".repro", ":p") + for _, name in ipairs { "config", "data", "state", "cache" } do + vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name + end + + local lazypath = root .. "/plugins/lazy.nvim" + if not vim.loop.fs_stat(lazypath) then + vim.fn.system { "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath } + end + vim.opt.runtimepath:prepend(lazypath) + + require("lazy").setup({ + { "catppuccin/nvim", dev = true }, + }, { + root = root .. "/plugins", + dev = { + path = debug.getinfo(1).source:sub(2, -21), + }, + }) + + require("catppuccin").setup() + vim.cmd.colorscheme "catppuccin" +end) + +if error then print(error) end +vim.cmd(status and "0cq" or "1cq")