From dd485642420f1f007d968900d8d36ec3303e8e5a Mon Sep 17 00:00:00 2001 From: smjonas Date: Sat, 11 Feb 2023 20:26:20 +0100 Subject: [PATCH 1/2] ci: update CI scripts and use release-please --- .github/workflows/integration.yml | 54 ++++++++++++++++--- .github/workflows/panvimdoc.yml | 22 -------- .github/workflows/{semver.yml => release.yml} | 2 +- README.md | 3 ++ lua/snippet_converter/init.lua | 4 ++ 5 files changed, 54 insertions(+), 31 deletions(-) delete mode 100644 .github/workflows/panvimdoc.yml rename .github/workflows/{semver.yml => release.yml} (95%) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 7b028ae..df78f6f 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -1,10 +1,4 @@ -name: Run CI - -on: - push: - branches: [main] - pull_request: - branches: [main] +name: CI jobs: luacheck: @@ -19,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: JohnnyMorganz/stylua-action@v1 + - uses: JohnnyMorganz/stylua-action@v2 with: token: ${{ secrets.GITHUB_TOKEN }} args: --color always --check lua/ @@ -37,3 +31,47 @@ jobs: - uses: ./.github/setup_luarocks - name: Run tests run: make run_tests + + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: panvimdoc + uses: kdheepak/panvimdoc@main + with: + vimdoc: snippet-converter + description: "Convert snippets to the format of your choice" + pandoc: doc/documentation.md + version: "NVIM ≥ v0.7.0" + - name: Push changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "chore(build): auto-generate vimdoc" + commit_user_name: "github-actions[bot]" + commit_user_email: "github-actions[bot]@users.noreply.github.com" + commit_author: "github-actions[bot] " + +release: + name: release + if: ${{ github.ref == 'refs/heads/main' }} + needs: [luacheck, stylua, tests, docs] + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + release-type: simple + package-name: snippet-converter.nvim + extra-files: | + lua/snippet_converter/init.lua + - uses: actions/checkout@v2 + - name: tag stable versions + if: ${{ steps.release.outputs.release_created }} + run: | + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git" + git tag -d stable || true + git push origin :stable || true + git tag -a stable -m "Last stable release" + git push origin stable diff --git a/.github/workflows/panvimdoc.yml b/.github/workflows/panvimdoc.yml deleted file mode 100644 index 1a3d522..0000000 --- a/.github/workflows/panvimdoc.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Generate docs - -on: - push: - branches: [main] - -jobs: - gen_docs: - runs-on: ubuntu-latest - name: Generate docs with pandvimdoc - steps: - - uses: actions/checkout@v2 - - name: panvimdoc - uses: kdheepak/panvimdoc@main - with: - vimdoc: snippet-converter - description: "Convert snippets to the format of your choice" - pandoc: doc/documentation.md - version: "NVIM v0.7" - - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: "Auto generate docs" diff --git a/.github/workflows/semver.yml b/.github/workflows/release.yml similarity index 95% rename from .github/workflows/semver.yml rename to .github/workflows/release.yml index 63dfb70..557e185 100644 --- a/.github/workflows/semver.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Generate semver tags +name: Release on: push: diff --git a/README.md b/README.md index d43cdd2..7f4b081 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,11 @@ Parse, transform and convert snippets. Supports a variety of formats and snippet engines. +<<<<<<< Updated upstream Current version: `1.4.1` +======= +>>>>>>> Stashed changes [![Neovim](https://img.shields.io/badge/Neovim%200.7+-green.svg?style=for-the-badge&logo=neovim)](https://neovim.io) [![Lua](https://img.shields.io/badge/Lua-blue.svg?style=for-the-badge&logo=lua)](http://www.lua.org) diff --git a/lua/snippet_converter/init.lua b/lua/snippet_converter/init.lua index 92a55c0..3ea657c 100644 --- a/lua/snippet_converter/init.lua +++ b/lua/snippet_converter/init.lua @@ -306,6 +306,7 @@ M.convert_snippets = function(args) return model end +<<<<<<< Updated upstream -- ## 1.4.1 (January 8, 2023) -- Bug fixes: -- - vsnip converter: escape $ in text nodes @@ -350,5 +351,8 @@ end -- Initial release of SnippetConverter! Currently supports UltiSnips, LuaSnip, SnipMate, -- VSCode and vsnip snippets. M.version = "1.4.1" +======= +M.version = "1.4.2" +>>>>>>> Stashed changes return M From 3aea8f3925820fae7240f777bbcaf25f5b55c22a Mon Sep 17 00:00:00 2001 From: smjonas Date: Sat, 11 Feb 2023 20:35:47 +0100 Subject: [PATCH 2/2] Fix CI errors --- .github/workflows/integration.yml | 52 +++++++++++++-------------- lua/snippet_converter/core/loader.lua | 52 ++++++++++++++------------- lua/snippet_converter/init.lua | 2 +- 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 86eb0c0..f147e9a 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [main] + branches: [main, ci] pull_request: - branches: [main] + branches: [main, ci] jobs: luacheck: @@ -57,27 +57,27 @@ jobs: commit_user_email: "github-actions[bot]@users.noreply.github.com" commit_author: "github-actions[bot] " -release: - name: release - if: ${{ github.ref == 'refs/heads/main' }} - needs: [luacheck, stylua, tests, docs] - runs-on: ubuntu-latest - steps: - - uses: google-github-actions/release-please-action@v3 - id: release - with: - release-type: simple - package-name: snippet-converter.nvim - extra-files: | - lua/snippet_converter/init.lua - - uses: actions/checkout@v2 - - name: tag stable versions - if: ${{ steps.release.outputs.release_created }} - run: | - git config user.name github-actions[bot] - git config user.email github-actions[bot]@users.noreply.github.com - git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git" - git tag -d stable || true - git push origin :stable || true - git tag -a stable -m "Last stable release" - git push origin stable + release: + name: release + if: ${{ github.ref == 'refs/heads/main' }} + needs: [luacheck, stylua, tests, docs] + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + release-type: simple + package-name: snippet-converter.nvim + extra-files: | + lua/snippet_converter/init.lua + - uses: actions/checkout@v2 + - name: tag stable versions + if: ${{ steps.release.outputs.release_created }} + run: | + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git" + git tag -d stable || true + git push origin :stable || true + git tag -a stable -m "Last stable release" + git push origin stable diff --git a/lua/snippet_converter/core/loader.lua b/lua/snippet_converter/core/loader.lua index 10e88ab..8be993a 100644 --- a/lua/snippet_converter/core/loader.lua +++ b/lua/snippet_converter/core/loader.lua @@ -28,33 +28,37 @@ local add_location = function(matching_snippet_files, source_format, snippet_pat end -- @param matching_snippet_files table -local find_matching_snippet_files = - function(matching_snippet_files, source_format, source_path, exclude_paths) - local extension = snippet_engines[source_format].extension - -- ./ indicates to look for files in the runtimepath - local rt_path = source_path:match("%./(.*)") - if rt_path then - -- Turn path into Lua pattern - local rt_path_pattern = vim.pesc(rt_path) - local rtp_files = vim.api.nvim_get_runtime_file("*/*" .. extension, true) - for _, name in ipairs(rtp_files) do - -- Do not include paths that match exclude_paths: this would lead to reconverting - -- the same snippets in consecutive runs if the paths are also set as output paths - -- Name can either be a directory or a file name so make sure it is a file - if name:match(rt_path_pattern) and not match_any(name, exclude_paths) and io.file_exists(name) then - add_location(matching_snippet_files, source_format, name) - end - end - else - local files = io.scan_dir(vim.fn.expand(source_path), extension, { - -- Should probably be made configurable - recursive = source_format == "yasnippet", - }) - for _, file in ipairs(files) do - add_location(matching_snippet_files, source_format, file) +local find_matching_snippet_files = function( + matching_snippet_files, + source_format, + source_path, + exclude_paths +) + local extension = snippet_engines[source_format].extension + -- ./ indicates to look for files in the runtimepath + local rt_path = source_path:match("%./(.*)") + if rt_path then + -- Turn path into Lua pattern + local rt_path_pattern = vim.pesc(rt_path) + local rtp_files = vim.api.nvim_get_runtime_file("*/*" .. extension, true) + for _, name in ipairs(rtp_files) do + -- Do not include paths that match exclude_paths: this would lead to reconverting + -- the same snippets in consecutive runs if the paths are also set as output paths + -- Name can either be a directory or a file name so make sure it is a file + if name:match(rt_path_pattern) and not match_any(name, exclude_paths) and io.file_exists(name) then + add_location(matching_snippet_files, source_format, name) end end + else + local files = io.scan_dir(vim.fn.expand(source_path), extension, { + -- Should probably be made configurable + recursive = source_format == "yasnippet", + }) + for _, file in ipairs(files) do + add_location(matching_snippet_files, source_format, file) + end end +end -- Searches for a set of snippet files on the user's system with a given extension -- that matches the source format. diff --git a/lua/snippet_converter/init.lua b/lua/snippet_converter/init.lua index e565527..2e544af 100644 --- a/lua/snippet_converter/init.lua +++ b/lua/snippet_converter/init.lua @@ -308,4 +308,4 @@ end M.version = "1.4.2" -return M \ No newline at end of file +return M