From ca2560cae8a680c424a338fbeca8f0ab84e9791d Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Sat, 2 Sep 2023 08:44:56 -0700 Subject: [PATCH] ci: merge workflow jobs and add makefile --- .github/nvim_doc_tools | 1 - .github/pre-commit | 4 +-- .github/pre-push | 11 ++++++++ .github/workflows/install_nvim.sh | 2 +- .github/workflows/tests.yml | 42 ++++++++++++++++++++++++++++--- .github/workflows/update-docs.yml | 35 -------------------------- .gitignore | 2 ++ .gitmodules | 3 --- Makefile | 27 ++++++++++++++++++++ doc/oil.txt | 10 ++++---- {.github => scripts}/generate.py | 0 {.github => scripts}/main.py | 0 12 files changed, 86 insertions(+), 51 deletions(-) delete mode 160000 .github/nvim_doc_tools create mode 100755 .github/pre-push delete mode 100644 .github/workflows/update-docs.yml create mode 100644 Makefile rename {.github => scripts}/generate.py (100%) rename {.github => scripts}/main.py (100%) diff --git a/.github/nvim_doc_tools b/.github/nvim_doc_tools deleted file mode 160000 index d146f2b..0000000 --- a/.github/nvim_doc_tools +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d146f2b7e72892b748e21d40a175267ce2ac1b7b diff --git a/.github/pre-commit b/.github/pre-commit index 49ee249..c64fbec 100755 --- a/.github/pre-commit +++ b/.github/pre-commit @@ -1,5 +1,3 @@ #!/bin/bash set -e -luacheck lua tests - -stylua --check . +make fastlint diff --git a/.github/pre-push b/.github/pre-push new file mode 100755 index 0000000..ecb23a9 --- /dev/null +++ b/.github/pre-push @@ -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 diff --git a/.github/workflows/install_nvim.sh b/.github/workflows/install_nvim.sh index c5119dc..4c0203c 100644 --- a/.github/workflows/install_nvim.sh +++ b/.github/workflows/install_nvim.sh @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 25a9d9a..7494e3e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,12 @@ name: Tests -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + branches: + - master jobs: luacheck: @@ -17,7 +23,7 @@ jobs: sudo luarocks install luacheck - name: Run Luacheck - run: luacheck . + run: luacheck lua tests stylua: name: StyLua @@ -29,7 +35,7 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} version: v0.15.2 - args: --check . + args: --check lua tests typecheck: name: typecheck @@ -62,6 +68,35 @@ jobs: run: | bash ./run_tests.sh + update_docs: + name: Update docs + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + + - 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 @@ -71,6 +106,7 @@ jobs: - stylua - typecheck - run_tests + - update_docs runs-on: ubuntu-22.04 steps: - uses: google-github-actions/release-please-action@v3 diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml deleted file mode 100644 index c7463c7..0000000 --- a/.github/workflows/update-docs.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Update docs - -on: push - -jobs: - update-readme: - name: Update docs - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Install Neovim and dependencies - env: - NVIM_TAG: v0.9.0 - run: | - bash ./.github/workflows/install_nvim.sh - - - name: Update docs - 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 - python -m pip install pyparsing==3.0.9 - python .github/main.py generate - python .github/main.py lint - 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}) diff --git a/.gitignore b/.gitignore index d818abb..d8cb86e 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,5 @@ luac.out .direnv/ .testenv/ doc/tags +scripts/nvim_doc_tools +scripts/nvim-typecheck-action diff --git a/.gitmodules b/.gitmodules index c47e568..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule ".github/nvim_doc_tools"] - path = .github/nvim_doc_tools - url = https://github.com/stevearc/nvim_doc_tools diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..71447f8 --- /dev/null +++ b/Makefile @@ -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 diff --git a/doc/oil.txt b/doc/oil.txt index f06f8ff..9c3f8c8 100644 --- a/doc/oil.txt +++ b/doc/oil.txt @@ -3,11 +3,11 @@ -------------------------------------------------------------------------------- CONTENTS *oil-contents* - 1. Options.....................................................|oil-options| - 2. Api.............................................................|oil-api| - 3. Columns.....................................................|oil-columns| - 4. Actions.....................................................|oil-actions| - 5. Highlights...............................................|oil-highlights| + 1. Options |oil-options| + 2. Api |oil-api| + 3. Columns |oil-columns| + 4. Actions |oil-actions| + 5. Highlights |oil-highlights| -------------------------------------------------------------------------------- OPTIONS *oil-options* diff --git a/.github/generate.py b/scripts/generate.py similarity index 100% rename from .github/generate.py rename to scripts/generate.py diff --git a/.github/main.py b/scripts/main.py similarity index 100% rename from .github/main.py rename to scripts/main.py