From 4b784419449f67f5430948e7301198beb3b4b7f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?AoMe=20=C2=B7=20=E9=9D=92=E7=9B=AE?= <71392160+AlejandroSuero@users.noreply.github.com> Date: Wed, 15 May 2024 01:31:32 +0200 Subject: [PATCH] ci: improved actions and fixed some bugs (#5) * ci(test): added `golang` setup to test `go install` command * fix(ci): added check for windows to export `PATH` correctly * fix: changed it to powershell * fix: yaml variables * ci(docs): added paths to `README.md` to ensure only that file * ci(lint): modified lint to only run on `lua` and `tests` directories * fix(ci): setting `PATH` correctly * feat: added `Windows support` SHA commit Thanks to @hishamhm for this commit SHA d7d707a. * fix: command for `rm` updated for Windows * fix: luarocks conditional * ci(docs): added only pushes on `README.md` * feat: removed `Windows` support on CI * ci(lint): lint only in paths `lua/` and `tests/` --- .github/workflows/docs.yml | 4 ++++ .github/workflows/lint.yml | 14 +++++++++++++- .github/workflows/test.yml | 10 ++++++++-- lua/freeze-code/init.lua | 9 ++++++--- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7944e1d..c81c81e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -4,9 +4,13 @@ on: push: branches-ignore: - main + paths: + - "README.md" pull_request: branches: - main + paths: + - "README.md" jobs: docs: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bfcf5bb..9b39f77 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,18 @@ name: lint -on: ["push", "pull_request"] +on: + push: + branches: + - main + paths: + - "lua/**" + - "tests/**" + pull_request: + branches: + - main + paths: + - "lua/**" + - "tests/**" jobs: lint: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 11064a5..f2be028 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,17 +12,23 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest] rev: [nightly, v0.9.0, stable] steps: - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + name: Set up Go + with: + go-version: ~1.21 - uses: rhysd/action-setup-vim@v1 + name: Set up Neovim with: neovim: true version: ${{ matrix.rev }} - - name: Run tests with NeoVim + - name: Run tests with Neovim + shell: bash run: | export PATH="${PWD}/_neovim/bin:${PATH}" export VIM="${PWD}/_neovim/share/nvim/runtime" diff --git a/lua/freeze-code/init.lua b/lua/freeze-code/init.lua index ded3f32..feb5d57 100644 --- a/lua/freeze-code/init.lua +++ b/lua/freeze-code/init.lua @@ -178,15 +178,18 @@ freeze_code.agnostic_install_freeze = function(opts) return end - local install_path = opts.install_path + local install_path = vim.fn.expand(opts.install_path) if install_path == "" then - install_path = "~/.local/bin" + install_path = vim.fn.expand("~/.local/bin") end local output_filename = "freeze.tar.gz" local download_command = { "curl", "-sL", "-o", output_filename, release_url } local extract_command = { "tar", "-zxf", output_filename, "-C", install_path } + -- vim.loop.spawn("rm", { args = { "-rf", install_path .. "/" .. get_freeze_filename() } }) + local rm_command_args = { "-rf", install_path .. "/" .. get_freeze_filename() } if os_name == "Windows" then extract_command = { "Expand-Archive", output_filename, install_path } + rm_command_args = { "-r", "-Force", install_path .. "/" .. get_freeze_filename() } end local binary_path = vim.fn.expand(table.concat({ install_path, get_freeze_filename() .. "/freeze" }, "/")) @@ -236,7 +239,7 @@ freeze_code.agnostic_install_freeze = function(opts) opts._installed = true opts.install_path = install_path freeze_code.setup(opts) - vim.loop.spawn("rm", { args = { "-rf", install_path .. "/" .. get_freeze_filename() } }) + vim.loop.spawn("rm", { args = rm_command_args }) logger.warn_fmt("[freeze-code] `freeze` binary installed in installed in path=%s", freeze_code.config.freeze_path) freeze_code.setup(opts) create_autocmds()