소스 검색

refactor(ci): better path handling (#1531)

kylo252 3 년 전
부모
커밋
fcb764cd63
5개의 변경된 파일39개의 추가작업 그리고 31개의 파일을 삭제
  1. 6 13
      .github/workflows/install.yaml
  2. 1 1
      utils/bin/lvim
  3. 14 3
      utils/bin/test_runner.sh
  4. 1 1
      utils/installer/install-neovim-from-release
  5. 17 13
      utils/installer/install.sh

+ 6 - 13
.github/workflows/install.yaml

@@ -23,16 +23,9 @@ jobs:
     steps:
       - uses: actions/checkout@v2
 
-      # sha256sum is not available by default
-      - name: Installl dependencies for OSX
-        if: matrix.os == 'osx'
-        run: |
-          echo "HOMEBREW_NO_AUTO_UPDATE=1" >> $GITHUB_ENV
-          echo "$HOME/.local/bin" >> $GITHUB_PATH
-          brew install coreutils
-
       - name: Install neovim binary
         run: |
+          echo "$HOME/.local/bin" >> $GITHUB_PATH
           bash ./utils/installer/install-neovim-from-release
 
       - name: Install LunarVim
@@ -43,16 +36,16 @@ jobs:
           ln -s "$PWD"/* "$HOME"/.local/share/lunarvim/lvim/.
           bash ./utils/installer/install.sh
 
-      - name: Run unit-tests
-        # NOTE: make sure to adjust the timeout if you start adding a lot of tests
-        timeout-minutes: 4
-        run: make test
-
       - name: Test LunarVim PackerCompile
         run: if "$HOME"/.local/bin/lvim --headless +PackerCompile -c ':qall' 2>&1|grep -q 'Error'; then false; fi
 
       - name: Test LunarVim Health
         run: if "$HOME"/.local/bin/lvim --headless +checkhealth -c ':qall' 2>&1|grep -q 'Error'; then false; fi
+
+      - name: Run unit-tests
+        # NOTE: make sure to adjust the timeout if you start adding a lot of tests
+        timeout-minutes: 4
+        run: make test
 #   freebsd:
 #     runs-on: macos-latest
 #     if: github.event.pull_request.draft == false

+ 1 - 1
utils/bin/lvim

@@ -1,6 +1,6 @@
 #!/bin/sh
 
 export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-$HOME/.local/share/lunarvim}"
-export LUNARVIM_CONFIG_DIR="${LUNARVIM_RUNTIME_DIR:-$HOME/.config/lvim}"
+export LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-$HOME/.config/lvim}"
 
 exec nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" "$@"

+ 14 - 3
utils/bin/test_runner.sh

@@ -1,9 +1,20 @@
 #!/usr/bin/env bash
 set -e
 
-# TODO: allow running with a minimal_init.lua
+export LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$HOME/.config/lvim"}"
+export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$HOME/.local/share/lunarvim"}"
+
+export LVIM_TEST_ENV=true
+
+rm -f "$LUNARVIM_CONFIG_DIR/plugin/packer_compiled.lua"
+
+lvim() {
+  # TODO: allow running with a minimal_init.lua
+  nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" --cmd "set runtimepath+=$LUNARVIM_RUNTIME_DIR/lvim" "$@"
+}
+
 if [ -n "$1" ]; then
-  nvim --headless -u ./init.lua -c "lua require('plenary.busted').run('$1')"
+  lvim --headless -c "lua require('plenary.busted').run('$1')"
 else
-  nvim --headless -u ./init.lua -c "PlenaryBustedDirectory tests/ { minimal_init = './init.lua' }"
+  lvim --headless -c "PlenaryBustedDirectory tests/ { minimal_init = './init.lua' }"
 fi

+ 1 - 1
utils/installer/install-neovim-from-release

@@ -52,7 +52,7 @@ function download_neovim() {
 
 function verify_neovim() {
   echo "Verifying the installation.."
-  DOWNLOADED_SHA="$(sha256sum "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz" | awk '{print $1}')"
+  DOWNLOADED_SHA="$(openssl dgst -sha256 "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz" | awk '{print $2}')"
 
   if [ "$RELEASE_SHA" != "$DOWNLOADED_SHA" ]; then
     echo "Error! checksum mis-match."

+ 17 - 13
utils/installer/install.sh

@@ -2,7 +2,7 @@
 set -eo pipefail
 
 #Set branch to master unless specified by the user
-declare -r LV_BRANCH="${LV_BRANCH:-rolling}"
+declare LV_BRANCH="${LV_BRANCH:-"rolling"}"
 declare -r LV_REMOTE="${LV_REMOTE:-lunarvim/lunarvim.git}"
 declare -r INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}"
 
@@ -10,16 +10,16 @@ declare -r XDG_DATA_HOME="${XDG_DATA_HOME:-"$HOME/.local/share"}"
 declare -r XDG_CACHE_HOME="${XDG_CACHE_HOME:-"$HOME/.cache"}"
 declare -r XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"$HOME/.config"}"
 
-# TODO: Use a dedicated cache directory #1256
-declare -r NEOVIM_CACHE_DIR="$XDG_CACHE_HOME/nvim"
-
 declare -r LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}"
 declare -r LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}"
+# TODO: Use a dedicated cache directory #1256
+declare -r LUNARVIM_CACHE_DIR="$XDG_CACHE_HOME/nvim"
+declare -r LUNARVIM_PACK_DIR="$LUNARVIM_RUNTIME_DIR/site/pack"
 
 declare -a __lvim_dirs=(
   "$LUNARVIM_CONFIG_DIR"
   "$LUNARVIM_RUNTIME_DIR"
-  "$NEOVIM_CACHE_DIR" # for now this is shared with neovim
+  "$LUNARVIM_CACHE_DIR"
 )
 
 declare -a __npm_deps=(
@@ -51,6 +51,7 @@ EOF
   detect_platform
 
   if [ -n "$GITHUB_ACTIONS" ]; then
+    LV_BRANCH="${GITHUB_REF##*/}"
     install_packer
     setup_lvim
     exit 0
@@ -91,11 +92,7 @@ EOF
       ;;
   esac
 
-  if [ -e "$LUNARVIM_RUNTIME_DIR/site/pack/packer/start/packer.nvim" ]; then
-    echo "Packer already installed"
-  else
-    install_packer
-  fi
+  install_packer
 
   __add_separator "80"
 
@@ -233,8 +230,15 @@ function backup_old_config() {
 }
 
 function install_packer() {
-  git clone --depth 1 https://github.com/wbthomason/packer.nvim \
-    "$LUNARVIM_RUNTIME_DIR/site/pack/packer/start/packer.nvim"
+  if [ -e "$LUNARVIM_PACK_DIR/packer/start/packer.nvim" ]; then
+    echo "Packer already installed"
+  else
+    if ! git clone --depth 1 "https://github.com/wbthomason/packer.nvim" \
+      "$LUNARVIM_PACK_DIR/packer/start/packer.nvim"; then
+      echo "Failed to clone Packer. Installation failed."
+      exit 1
+    fi
+  fi
 }
 
 function clone_lvim() {
@@ -271,7 +275,7 @@ function setup_lvim() {
   cp "$LUNARVIM_RUNTIME_DIR/lvim/utils/installer/config.example-no-ts.lua" \
     "$LUNARVIM_CONFIG_DIR/config.lua"
 
-  nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" --headless \
+  "$INSTALL_PREFIX/bin/lvim" --headless \
     -c 'autocmd User PackerComplete quitall' \
     -c 'PackerSync'