diff options
author | kylo252 <[email protected]> | 2021-08-15 18:01:37 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2021-08-15 20:31:37 +0430 |
commit | 1fbc34cf1d3c2ec5500ddb6e14f04751680d969f (patch) | |
tree | cdecc7d7e826ed2e47af17f552038261f34639d4 | |
parent | 6eb75c5678ddb4d040f644e331e222078b99b3a1 (diff) |
Fix slow CI by installing a neovim binary directly (#1059)
-rw-r--r-- | .github/workflows/install.yaml | 19 | ||||
-rwxr-xr-x | utils/bin/install-latest-neovim | 9 | ||||
-rwxr-xr-x | utils/installer/install-neovim-from-release | 83 |
3 files changed, 92 insertions, 19 deletions
diff --git a/.github/workflows/install.yaml b/.github/workflows/install.yaml index 08801f1b..6fb0d49c 100644 --- a/.github/workflows/install.yaml +++ b/.github/workflows/install.yaml @@ -22,19 +22,18 @@ jobs: if: github.event.pull_request.draft == false steps: - uses: actions/checkout@v2 - - - name: Install dependencies for Linux - if: matrix.os == 'linux' - run: | - sudo add-apt-repository ppa:neovim-ppa/unstable -y - sudo apt-get update - sudo apt-get install neovim -y - - name: Install dependencies for OSX + # sha256sum is not available by default + - name: Installl dependencies for OSX if: matrix.os == 'osx' run: | - brew update >/dev/null - brew install neovim + echo "HOMEBREW_NO_AUTO_UPDATE=1" >> $GITHUB_ENV + echo "$HOME/.local/bin" >> $GITHUB_PATH + brew install coreutils + + - name: Install neovim binary + run: | + bash ./utils/installer/install-neovim-from-release - name: Install LunarVim timeout-minutes: 4 diff --git a/utils/bin/install-latest-neovim b/utils/bin/install-latest-neovim deleted file mode 100755 index 8d1d95fd..00000000 --- a/utils/bin/install-latest-neovim +++ /dev/null @@ -1,9 +0,0 @@ -!#/bin/bash -cd ~ -sudo rm -r neovim -git clone --branch master --depth 1 https://github.com/neovim/neovim -cd neovim -sudo make CMAKE_BUILD_TYPE=Release install -cd ~ -sudo rm -r neovim - diff --git a/utils/installer/install-neovim-from-release b/utils/installer/install-neovim-from-release new file mode 100755 index 00000000..a2ba0513 --- /dev/null +++ b/utils/installer/install-neovim-from-release @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +set -eu pipefall + +declare -r LV_INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}" +declare -r RELEASE_VER="${RELEASE_VER:-latest}" # can be set to nightly + +declare ARCHIVE_NAME +declare RELEASE_NAME +declare OS + +OS="$(uname -s)" + +if [ "$OS" == "Linux" ]; then + ARCHIVE_NAME="nvim-linux64" + RELEASE_NAME="nvim-linux64" +elif [ "$OS" == "Darwin" ]; then + ARCHIVE_NAME="nvim-macos" + # for some reason the archive has a different name + RELEASE_NAME="nvim-osx64" +else + echo "$OS platform is not supported currently" + exit 1 +fi + +declare -r RELEASE_URL="https://github.com/neovim/neovim/releases/$RELEASE_VER/download/$ARCHIVE_NAME.tar.gz" +declare -r CHECKSUM_URL="$RELEASE_URL.sha256sum" + +DOWNLOAD_DIR="$(mktemp -d)" +readonly DOWNLOAD_DIR + +RELEASE_SHA="$(curl -Ls "$CHECKSUM_URL" | awk '{print $1}')" +readonly RELEASE_SHA + +function main() { + if [ ! -d "$LV_INSTALL_PREFIX" ]; then + mkdir -p "$LV_INSTALL_PREFIX" || __invalid__prefix__handler + fi + download_neovim + verify_neovim + install_neovim +} + +function download_neovim() { + echo "Downloading Neovim's binary from $RELEASE_VER release.." + if ! curl --progress-bar --fail -L "$RELEASE_URL" -o "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz"; then + echo "Download failed. Check that the release/filename are correct." + exit 1 + fi + echo "Download complete!" +} + +function verify_neovim() { + echo "Verifying the installation.." + DOWNLOADED_SHA="$(sha256sum "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz" | awk '{print $1}')" + + if [ "$RELEASE_SHA" != "$DOWNLOADED_SHA" ]; then + echo "Error! checksum mis-match." + echo "Expected: $RELEASE_SHA but got: $DOWNLOADED_SHA" + exit 1 + fi + echo "Verification complete!" +} + +function install_neovim() { + + echo "Installing Neovim.." + pushd "$DOWNLOAD_DIR" + tar -xzf "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz" + popd + # https://dev.to/ackshaey/macos-vs-linux-the-cp-command-will-trip-you-up-2p00 + cp -r "$DOWNLOAD_DIR/$RELEASE_NAME/." "$LV_INSTALL_PREFIX" + echo "Installation complete!" + echo "Now you can run $LV_INSTALL_PREFIX/bin/nvim" +} + +function __invalid__prefix__handler() { + echo "Error! Invalid value for LV_INSTALL_PREFIX: [$INSTALL_PREFIX]" + echo "Please verify that the folder exists and re-run the installer!" + exit 1 +} + +main "$@" |