Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: onboard ci #7

Merged
merged 10 commits into from
Apr 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
# 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 <<EOF
${{ env._ARCHIVE_URL }}
EOF
)"
curl -L "${url:?}" | tar xzf -
mv *plenary* plenary

- if: ${{ !steps.restore-cache.outputs.cache-hit }}
name: Cache deps
uses: actions/cache/save@v3
with:
path: |
${{ env.HOME }}/nvim
${{ env.HOME }}/plenary
key: ${{ steps.restore-cache.outputs.cache-primary-key }}

- uses: actions/checkout@v3

- name: Add nvim to PATH
run: echo ~/nvim/usr/bin >> "${GITHUB_PATH:?}"

- name: Test
run: make test