Skip to content

Commit

Permalink
tools: add makefile and refactor CI
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Sep 18, 2023
1 parent 5aaf392 commit 73f080d
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 50 deletions.
1 change: 0 additions & 1 deletion .github/nvim_doc_tools
Submodule nvim_doc_tools deleted from d146f2
3 changes: 1 addition & 2 deletions .github/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash
set -e
luacheck lua tests
stylua --check .
make fastlint
11 changes: 11 additions & 0 deletions .github/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e
IFS=' '
while read local_ref _local_sha _remote_ref _remote_sha; do
remote_main=$( (git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null || echo "///master") | cut -f 4 -d / | tr -d "[:space:]")
local_ref_short=$(echo "$local_ref" | cut -f 3 -d / | tr -d "[:space:]")
if [ "$local_ref_short" = "$remote_main" ]; then
make lint
make test
fi
done
2 changes: 1 addition & 1 deletion .github/workflows/install_nvim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e
PLUGINS="$HOME/.local/share/nvim/site/pack/plugins/start"
mkdir -p "$PLUGINS"

wget "https://github.com/neovim/neovim/releases/download/${NVIM_TAG}/nvim.appimage"
wget "https://github.com/neovim/neovim/releases/download/${NVIM_TAG-stable}/nvim.appimage"
chmod +x nvim.appimage
./nvim.appimage --appimage-extract >/dev/null
rm -f nvim.appimage
Expand Down
44 changes: 41 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Tests

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
luacheck:
Expand All @@ -17,7 +23,7 @@ jobs:
sudo luarocks install luacheck
- name: Run Luacheck
run: luacheck .
run: luacheck lua tests

stylua:
name: StyLua
Expand All @@ -29,7 +35,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v0.15.2
args: --check .
args: --check lua tests

typecheck:
name: typecheck
Expand Down Expand Up @@ -62,6 +68,37 @@ jobs:
run: |
bash ./run_tests.sh
update_docs:
name: Update docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Install Neovim and dependencies
run: |
bash ./.github/workflows/install_nvim.sh
- name: Update docs
run: |
python -m pip install pyparsing==3.0.9
make doc
- name: Commit changes
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_MSG: |
[docgen] Update docs
skip-checks: true
run: |
git config user.email "actions@github"
git config user.name "Github Actions"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git add README.md doc
# Only commit and push if we have changes
git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push origin HEAD:${GITHUB_REF})
release:
name: release

Expand All @@ -71,6 +108,7 @@ jobs:
- stylua
- run_tests
- typecheck
- update_docs
runs-on: ubuntu-22.04
steps:
- uses: google-github-actions/release-please-action@v3
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/update_docs.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ luac.out
.direnv/
.testenv/
doc/tags
scripts/nvim_doc_tools
scripts/nvim-typecheck-action
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.PHONY: all doc test lint fastlint clean

all: doc lint test

doc: scripts/nvim_doc_tools
python scripts/main.py generate
python scripts/main.py lint

test:
./run_tests.sh

lint: scripts/nvim-typecheck-action fastlint
./scripts/nvim-typecheck-action/typecheck.sh --workdir scripts/nvim-typecheck-action lua

fastlint: scripts/nvim_doc_tools
python scripts/main.py lint
luacheck lua tests --formatter plain
stylua --check lua tests

scripts/nvim_doc_tools:
git clone https://github.com/stevearc/nvim_doc_tools scripts/nvim_doc_tools

scripts/nvim-typecheck-action:
git clone https://github.com/stevearc/nvim-typecheck-action scripts/nvim-typecheck-action

clean:
rm -rf scripts/nvim_doc_tools scripts/nvim-typecheck-action
10 changes: 5 additions & 5 deletions doc/stickybuf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
--------------------------------------------------------------------------------
CONTENTS *stickybuf-contents*

1. Commands.............................................|stickybuf-commands|
2. Api.......................................................|stickybuf-api|
3. Options...............................................|stickybuf-options|
1. Commands |stickybuf-commands|
2. Api |stickybuf-api|
3. Options |stickybuf-options|

--------------------------------------------------------------------------------
COMMANDS *stickybuf-commands*
Expand Down Expand Up @@ -68,7 +68,7 @@ should_auto_pin({bufnr}): nil|"bufnr"|"buftype"|"filetype" *stickybuf.should_aut
--------------------------------------------------------------------------------
OPTIONS *stickybuf-options*

>
>lua
require("stickybuf").setup({
-- This function is run on BufEnter to determine pinning should be activated
get_auto_pin = function(bufnr)
Expand All @@ -81,7 +81,7 @@ OPTIONS *stickybuf-option

You can also use autocmd to pin buffers conditionally

>
>lua
vim.api.nvim_create_autocmd("BufEnter", {
desc = "Pin the buffer to any window that is fixed width or height",
callback = function(args)
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 73f080d

Please sign in to comment.