Skip to content

Commit

Permalink
chore: fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-reineke committed Aug 5, 2024
1 parent 0d1b6e3 commit 1985dab
Show file tree
Hide file tree
Showing 14 changed files with 277 additions and 81 deletions.
2 changes: 2 additions & 0 deletions .cbfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[languages]
lua = ["stylua -s -"]
56 changes: 56 additions & 0 deletions .github/workflows/lua_language_server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Lua Language Server Check

on:
workflow_call:
inputs:
lua_ls_version:
required: true
type: string
neovim_versions:
required: true
type: string

jobs:
lua-language-server:
name: lua language server
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
rev: ${{ fromJson(inputs.neovim_versions) }}
steps:
- uses: actions/checkout@v3
- run: date +%F > todays-date
- name: Restore cache for Neovim
uses: actions/cache@v3
with:
path: .ci/neovim
key: ${{ matrix.rev }}-${{ hashFiles('todays-date') }}
- name: Restore cache for vendor dependencies
uses: actions/cache@v3
with:
path: .ci/vendor
key: ${{ hashFiles('todays-date') }}
- name: Restore cache for lua LS
uses: actions/cache@v3
with:
path: .ci/lua-ls
key: ${{ inputs.lua_ls_version }}
- name: Prepare
run: |
test -d .ci/neovim || {
mkdir -p .ci/neovim
curl -sL "https://github.com/neovim/neovim/releases/download/${{ matrix.rev }}/nvim-linux64.tar.gz" | tar xzf - --strip-components=1 -C "${PWD}/.ci/neovim"
}
test -d .ci/lua-ls || {
mkdir -p .ci/lua-ls
curl -sL "https://github.com/LuaLS/lua-language-server/releases/download/${{ inputs.lua_ls_version }}/lua-language-server-${{ inputs.lua_ls_version }}-linux-x64.tar.gz" | tar xzf - -C "${PWD}/.ci/lua-ls"
}
- name: Run check
run: |
export PATH="${PWD}/.ci/neovim/bin:${PATH}"
export PATH="${PWD}/.ci/lua-ls/bin:${PATH}"
export VIM="${PWD}/.ci/neovim/share/nvim/runtime"
nvim --version
make lua-language-server version=${{ matrix.rev == 'nightly' && 'nightly' || 'stable' }}
25 changes: 25 additions & 0 deletions .github/workflows/nightly_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Nightly Neovim Check
# Checks LSP and unit tests against new Neovim nightly once a week

on:
schedule:
- cron: '30 21 * * 0' # 6:30 AM JST, Monday
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
uses: ./.github/workflows/tests.yml
with:
neovim_versions: |
[ "nightly" ]
lua-language-server:
uses: ./.github/workflows/lua_language_server.yml
with:
lua_ls_version: 3.9.1
neovim_versions: |
[ "nightly" ]
100 changes: 60 additions & 40 deletions .github/workflows/pr_check.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,81 @@
name: Pull request check
name: Pull Request Check

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
format:
runs-on: ubuntu-latest
tests:
uses: ./.github/workflows/tests.yml
with:
neovim_versions: |
[ "nightly", "v0.10.0" ]
lua-language-server:
uses: ./.github/workflows/lua_language_server.yml
with:
lua_ls_version: 3.9.1
neovim_versions: |
[ "nightly", "v0.10.0" ]
stylua:
name: stylua
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: JohnnyMorganz/stylua-action@1.0.0
- uses: actions/checkout@v3
- uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --check .
version: latest
args: --color always --check .

luacheck:
name: luacheck
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Prepare
run: |
sudo apt-get update
sudo apt-get install -y luarocks
sudo luarocks install luacheck
- name: Lint
run: sudo make luacheck

block-fixup:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
- name: Block Fixup Commit Merge
uses: 13rac1/[email protected]

luacheck:
conventional-commit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master

- uses: leafo/[email protected]
- name: Checkout code
uses: actions/checkout@v3
with:
luaVersion: 'luajit-2.1.0-beta3'

- uses: leafo/[email protected]

- name: build
run: |
luarocks install luacheck
fetch-depth: 0

- name: test
- name: Check Commit Messages
run: |
luacheck lua specs
tests:
strategy:
fail-fast: false
matrix:
version:
- stable
- nightly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Neovim
uses: rhysd/action-setup-vim@v1
id: neovim
with:
neovim: true
version: ${{ matrix.version }}
- name: Run tests
run: make specs
commits=$(git log --no-merges --pretty=format:"%s" HEAD~${{ github.event.pull_request.commits }}..HEAD)
bad_commits=()
for commit in "$commits"; do
if ! echo $commit | grep -qE "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.+\))?: .+"; then
bad_commits+=("$commit")
fi
done
if [[ ${#bad_commits[@]} -ne 0 ]]; then
echo "The following commits do not follow the Conventional Commit format:"
for bad_commit in "${bad_commits[@]}"; do
echo " - $bad_commit"
done
exit 1
fi
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Unit Tests

on:
workflow_call:
inputs:
neovim_versions:
required: true
type: string

jobs:
tests:
name: unit tests
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
rev: ${{ fromJson(inputs.neovim_versions) }}
steps:
- uses: actions/checkout@v3
- run: date +%F > todays-date
- name: Restore cache for Neovim
uses: actions/cache@v3
with:
path: .ci/neovim
key: ${{ matrix.rev }}-${{ hashFiles('todays-date') }}
- name: Prepare
run: |
test -d .ci/neovim || {
mkdir -p .ci/neovim
curl -sL "https://github.com/neovim/neovim/releases/download/${{ matrix.rev }}/nvim-linux64.tar.gz" | tar xzf - --strip-components=1 -C "${PWD}/.ci/neovim"
}
- name: Run tests
run: |
export PATH="${PWD}/.ci/neovim/bin:${PATH}"
export VIM="${PWD}/.ci/neovim/share/nvim/runtime"
nvim --version
make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/doc/tags
vendor
.ci/*
6 changes: 5 additions & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
globals = { "vim", "_", "assert", "describe", "before_each", "after_each", "it" }
globals = { "vim", "_", "describe", "it", "after_each", "before_each", "assert" }
max_line_length = false

exclude_files = {
".ci/vendor",
}
18 changes: 18 additions & 0 deletions .luarc.nightly.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"runtime.version": "LuaJIT",
"diagnostics.globals": [
"it",
"describe",
"before_each",
"after_each",
"setup",
"teardown"
],
"diagnostics.ignoredFiles": "Disable",
"diagnostics.libraryFiles": "Disable",
"workspace.library": [
"/usr/local/share/nvim/runtime/lua",
".ci/neovim/share/nvim/runtime/lua",
".ci/vendor/pack/vendor/start/neodev.nvim/types/nightly"
]
}
18 changes: 18 additions & 0 deletions .luarc.stable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"runtime.version": "LuaJIT",
"diagnostics.globals": [
"it",
"describe",
"before_each",
"after_each",
"setup",
"teardown"
],
"diagnostics.ignoredFiles": "Disable",
"diagnostics.libraryFiles": "Disable",
"workspace.library": [
"/usr/local/share/nvim/runtime/lua",
".ci/neovim/share/nvim/runtime/lua",
".ci/vendor/pack/vendor/start/neodev.nvim/types/stable"
]
}
1 change: 1 addition & 0 deletions .styluaignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.ci/*
31 changes: 23 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,34 @@ ifndef VERBOSE
.SILENT:
endif

specs: dependencies
@echo "Running lsp-format specs..."
test: dependencies
@echo "Running lsp-format tests..."
timeout 300 nvim -e \
--headless \
-u specs/minimal_init.vim \
-c "PlenaryBustedDirectory specs/features {minimal_init = 'specs/minimal_init.vim'}"
--noplugin \
-u specs/spec.lua \
-c "PlenaryBustedDirectory specs/features {minimal_init = 'specs/spec.lua'}"

luacheck:
luacheck .

stylua:
stylua --check .

lua-language-server: dependencies
rm -rf .ci/lua-language-server-log
lua-language-server --configpath .luarc.$(version).json --logpath .ci/lua-language-server-log --check .
@if jq -e 'if . | length > 0 then true else false end' .ci/lua-language-server-log/check.json > /dev/null; then \
cat .ci/lua-language-server-log/check.json; \
exit 1; \
fi

dependencies:
if [ ! -d vendor ]; then \
if [ ! -d .ci/vendor ]; then \
git clone --depth 1 \
https://github.com/nvim-lua/plenary.nvim \
vendor/pack/vendor/start/plenary.nvim; \
.ci/vendor/pack/vendor/start/plenary.nvim; \
git clone --depth 1 \
https://github.com/neovim/nvim-lspconfig \
vendor/pack/vendor/start/nvim-lspconfig; \
https://github.com/folke/neodev.nvim \
.ci/vendor/pack/vendor/start/neodev.nvim; \
fi
Loading

0 comments on commit 1985dab

Please sign in to comment.