diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8244c38 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,103 @@ +name: CI + +env: + _NVIM_REPO: neovim/neovim + _PLENARY_REPO: nvim-lua/plenary.nvim + _ARCHIVE_URL: https://github.com/${repo:?}/archive/refs/tags/${tag:?}.tar.gz + PLENARY: ~/plenary + +on: + push: + pull_request: + +defaults: + run: + shell: bash + +jobs: + # - name: Setup Vim + # You may pin to the exact commit or the version. + # uses: rhysd/action-setup-vim@015df8c5b8dabdca7febe31bb66c156c0d780374 + # uses: rhysd/action-setup-vim@v1.2.15 + # with: + # version: stable + # neovim: true + + test: + runs-on: ubuntu-latest + steps: + - run: printf %s=%s\\n HOME ~ >> "${GITHUB_ENV:?}" + + - name: Get latest dependency versions + env: + GH_TOKEN: ${{ github.token }} + run: | + _LATEST_NVIM_RELEASE_ID="$(gh release view stable -R "${_NVIM_REPO:?}" --json id -q .id)" + + _LATEST_PLENARY_TAG="$( + gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "/repos/${_PLENARY_REPO:?}/tags" \ + -q '.[].name' \ + | grep -E '^[Vv][[:digit:].]+$' \ + | sort -V \ + | tail -n 1 + )" + + echo "_LATEST_PLENARY_TAG=${_LATEST_PLENARY_TAG:?}" >> "${GITHUB_ENV:?}" + echo "_LATEST_NVIM_RELEASE_ID=${_LATEST_NVIM_RELEASE_ID:?}" >> "${GITHUB_ENV:?}" + + - name: Restore cache + id: restore-cache + uses: actions/cache/restore@v3 + with: + path: | + ${{ env.HOME }}/nvim + ${{ env.HOME }}/plenary + key: ${{ runner.os }}-deps-nvim@${{ env._LATEST_NVIM_RELEASE_ID }}-plenary@${{ env._LATEST_PLENARY_TAG }} + + - if: ${{ !steps.restore-cache.outputs.cache-hit }} + name: Download nvim + working-directory: ${{ env.HOME }} + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release download stable -R "${_NVIM_REPO:?}" -p nvim.appimage + chmod u+x nvim.appimage + ./nvim.appimage --appimage-extract + rm nvim.appimage + mv squashfs-root nvim + + - if: ${{ !steps.restore-cache.outputs.cache-hit }} + name: Download plenary + working-directory: ${{ env.HOME }} + env: + GITHUB_TOKEN: + GH_TOKEN: + run: | + repo="${_PLENARY_REPO:?}" + tag="${_LATEST_PLENARY_TAG:?}" + url="$(cat <> "${GITHUB_PATH:?}" + + - name: Test + run: make test