From 2319ee23974edab69d68623ec56225113706325d Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Wed, 9 Nov 2022 01:35:29 +0000 Subject: [PATCH] ci: improve sandboxing of tests --- .github/workflows/install_nvim.sh | 2 +- .github/workflows/tests.yml | 14 +++++--------- .gitignore | 1 + run_tests.sh | 21 +++++++++++++++++++-- tests/{init.lua => minimal_init.lua} | 0 5 files changed, 26 insertions(+), 12 deletions(-) rename tests/{init.lua => minimal_init.lua} (100%) diff --git a/.github/workflows/install_nvim.sh b/.github/workflows/install_nvim.sh index 9171a4a..79028c8 100755 --- a/.github/workflows/install_nvim.sh +++ b/.github/workflows/install_nvim.sh @@ -1,8 +1,8 @@ #!/bin/bash +set -e PLUGINS="$HOME/.local/share/nvim/site/pack/plugins/start" mkdir -p "$PLUGINS" wget https://github.com/neovim/neovim/releases/download/${NVIM_TAG}/nvim.appimage chmod +x nvim.appimage sudo mv ./nvim.appimage /usr/bin/nvim -git clone --depth=1 https://github.com/nvim-lua/plenary.nvim.git "$PLUGINS/plenary.nvim" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f943ea0..c0f286c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,15 +1,11 @@ name: Run tests -on: - push: - branches: - - master - pull_request: ~ +on: [push, pull_request] jobs: luacheck: name: Luacheck - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v1 @@ -25,7 +21,7 @@ jobs: stylua: name: StyLua - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 - name: Stylua @@ -38,10 +34,10 @@ jobs: run_tests: strategy: matrix: - nvim_tag: [v0.7.0, v0.7.2] + nvim_tag: [v0.7.0, v0.7.2, v0.8.0] name: Run tests - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 env: NVIM_TAG: ${{ matrix.nvim_tag }} steps: diff --git a/.gitignore b/.gitignore index 6fd0a37..a800d1d 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ luac.out *.x86_64 *.hex +.testenv/ diff --git a/run_tests.sh b/run_tests.sh index 6d1ceec..d9d764a 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,5 +1,22 @@ #!/bin/bash set -e -nvim --headless --noplugin -u tests/init.lua \ - -c "PlenaryBustedDirectory ${1-tests} { minimal_init = './tests/init.lua' }" +mkdir -p ".testenv/config/nvim" +mkdir -p ".testenv/data/nvim" +mkdir -p ".testenv/state/nvim" +mkdir -p ".testenv/run/nvim" +mkdir -p ".testenv/cache/nvim" +PLUGINS=".testenv/data/nvim/site/pack/plugins/start" + +if [ ! -e "$PLUGINS/plenary.nvim" ]; then + git clone --depth=1 https://github.com/nvim-lua/plenary.nvim.git "$PLUGINS/plenary.nvim" +fi + +XDG_CONFIG_HOME=".testenv/config" \ + XDG_DATA_HOME=".testenv/data" \ + XDG_STATE_HOME=".testenv/state" \ + XDG_RUNTIME_DIR=".testenv/run" \ + XDG_CACHE_HOME=".testenv/cache" \ + nvim --headless -u tests/minimal_init.lua \ + -c "PlenaryBustedDirectory ${1-tests} { minimal_init = './tests/minimal_init.lua' }" +echo "Success" diff --git a/tests/init.lua b/tests/minimal_init.lua similarity index 100% rename from tests/init.lua rename to tests/minimal_init.lua