summaryrefslogtreecommitdiff
path: root/mac/.config/LunarVim/utils/ci
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-08-23 12:42:37 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-08-23 12:42:37 +0900
commit07d294425a98ee5d1e22d03e2b24ae2c76e487c0 (patch)
treea6818f0d64438c5fdb88b00a35d944f80c056213 /mac/.config/LunarVim/utils/ci
parent6fc28cdb3529ca8ee864cb5c41674cb0a4af72a1 (diff)
updates
Diffstat (limited to 'mac/.config/LunarVim/utils/ci')
-rw-r--r--mac/.config/LunarVim/utils/ci/generate_new_lockfile.lua125
-rw-r--r--mac/.config/LunarVim/utils/ci/generate_new_lockfile.sh19
-rw-r--r--mac/.config/LunarVim/utils/ci/run_commitlint.sh10
-rw-r--r--mac/.config/LunarVim/utils/ci/run_test.sh25
-rw-r--r--mac/.config/LunarVim/utils/ci/update_changelog.sh15
-rw-r--r--mac/.config/LunarVim/utils/ci/verify_plugins.lua147
-rw-r--r--mac/.config/LunarVim/utils/ci/verify_plugins.sh10
7 files changed, 351 insertions, 0 deletions
diff --git a/mac/.config/LunarVim/utils/ci/generate_new_lockfile.lua b/mac/.config/LunarVim/utils/ci/generate_new_lockfile.lua
new file mode 100644
index 0000000..2677b20
--- /dev/null
+++ b/mac/.config/LunarVim/utils/ci/generate_new_lockfile.lua
@@ -0,0 +1,125 @@
+local sp = os.getenv "SNAPSHOT_PATH"
+
+local function call_proc(process, opts, cb)
+ local output, error_output = "", ""
+ local handle_stdout = function(err, chunk)
+ assert(not err, err)
+ if chunk then
+ output = output .. chunk
+ end
+ end
+
+ local handle_stderr = function(err, chunk)
+ assert(not err, err)
+ if chunk then
+ error_output = error_output .. chunk
+ end
+ end
+
+ local uv = vim.loop
+ local handle
+
+ local stdout = uv.new_pipe(false)
+ local stderr = uv.new_pipe(false)
+
+ local stdio = { nil, stdout, stderr }
+
+ handle = uv.spawn(
+ process,
+ { args = opts.args, cwd = opts.cwd or uv.cwd(), stdio = stdio },
+ vim.schedule_wrap(function(code)
+ if code ~= 0 then
+ stdout:read_stop()
+ stderr:read_stop()
+ end
+
+ local check = uv.new_check()
+ check:start(function()
+ for _, pipe in ipairs(stdio) do
+ if pipe and not pipe:is_closing() then
+ return
+ end
+ end
+ check:stop()
+ handle:close()
+ cb(code, output, error_output)
+ end)
+ end)
+ )
+
+ uv.read_start(stdout, handle_stdout)
+ uv.read_start(stderr, handle_stderr)
+
+ return handle
+end
+
+local plugins_list = {}
+
+local completed = 0
+
+local function write_lockfile(verbose)
+ local default_plugins = {}
+ local active_jobs = {}
+
+ local core_plugins = require "lvim.plugins"
+ for _, plugin in pairs(core_plugins) do
+ local name = plugin[1]:match "/(%S*)"
+ local url = "https://github.com/" .. plugin[1]
+ local commit = ""
+ table.insert(default_plugins, {
+ name = name,
+ url = url,
+ commit = commit,
+ branch = plugin.branch or "HEAD",
+ tag = plugin.tag,
+ })
+ end
+
+ table.sort(default_plugins, function(a, b)
+ return a.name < b.name
+ end)
+
+ for _, entry in pairs(default_plugins) do
+ local on_done = function(success, result, errors)
+ completed = completed + 1
+ if not success then
+ print("error: " .. errors)
+ return
+ end
+ local latest_sha = result:gsub("\tHEAD\n", ""):sub(1, 7)
+ if entry.tag then
+ local dereferenced_commit = result:match("\n(.*)\trefs/tags/" .. entry.tag .. "%^{}\n")
+ if dereferenced_commit then
+ latest_sha = dereferenced_commit:sub(1, 7)
+ end
+ end
+ plugins_list[entry.name] = {
+ commit = latest_sha,
+ }
+ end
+
+ local handle = call_proc("git", {
+ args = { "ls-remote", entry.url, entry.tag and entry.tag .. "*" or entry.branch },
+ }, on_done)
+ assert(handle)
+ table.insert(active_jobs, handle)
+ end
+
+ print("active: " .. #active_jobs)
+ print("plugins: " .. #default_plugins)
+
+ vim.wait(#active_jobs * 60 * 1000, function()
+ return completed == #active_jobs
+ end)
+
+ if verbose then
+ print(vim.inspect(plugins_list))
+ end
+
+ local fd = assert(io.open(sp, "w"))
+ fd:write(vim.json.encode(plugins_list), "\n")
+ fd:flush()
+end
+
+write_lockfile()
+vim.cmd "q"
diff --git a/mac/.config/LunarVim/utils/ci/generate_new_lockfile.sh b/mac/.config/LunarVim/utils/ci/generate_new_lockfile.sh
new file mode 100644
index 0000000..ebd71b3
--- /dev/null
+++ b/mac/.config/LunarVim/utils/ci/generate_new_lockfile.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+set -e
+
+REPO_DIR=$(git rev-parse --show-toplevel)
+
+export SNAPSHOT_NAME="default.json"
+export SNAPSHOT_DIR="${REPO_DIR}/snapshots"
+
+mkdir -p "${SNAPSHOT_DIR}"
+
+export SNAPSHOT_PATH="${REPO_DIR}/snapshots/${SNAPSHOT_NAME}"
+
+time lvim --headless \
+ -c "source ./utils/ci/generate_new_lockfile.lua"
+
+temp=$(mktemp)
+
+jq --sort-keys . "${SNAPSHOT_PATH}" >"${temp}"
+mv "${temp}" "${SNAPSHOT_PATH}"
diff --git a/mac/.config/LunarVim/utils/ci/run_commitlint.sh b/mac/.config/LunarVim/utils/ci/run_commitlint.sh
new file mode 100644
index 0000000..b752956
--- /dev/null
+++ b/mac/.config/LunarVim/utils/ci/run_commitlint.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+set -eo pipefail
+
+REPO_DIR="$(git rev-parse --show-toplevel)"
+HELP_URL="https://github.com/LunarVim/LunarVim/blob/rolling/CONTRIBUTING.md#commit-messages"
+CONFIG="$REPO_DIR/.github/workflows/commitlint.config.js"
+
+if ! npx commitlint --edit --verbose --help-url "$HELP_URL" --config "$CONFIG"; then
+ exit 1
+fi
diff --git a/mac/.config/LunarVim/utils/ci/run_test.sh b/mac/.config/LunarVim/utils/ci/run_test.sh
new file mode 100644
index 0000000..3e1bcf1
--- /dev/null
+++ b/mac/.config/LunarVim/utils/ci/run_test.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+set -e
+
+export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$HOME/.local/share/lunarvim"}"
+export LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-"$LUNARVIM_RUNTIME_DIR/lvim"}"
+
+export LVIM_TEST_ENV=true
+
+# we should start with an empty configuration
+LUNARVIM_CONFIG_DIR="$(mktemp -d)"
+LUNARVIM_CACHE_DIR="$(mktemp -d)"
+
+export LUNARVIM_CONFIG_DIR LUNARVIM_CACHE_DIR
+
+printf "cache_dir: %s\nconfig_dir: %s\n" "$LUNARVIM_CACHE_DIR" "$LUNARVIM_CONFIG_DIR"
+
+lvim() {
+ nvim -u "$LUNARVIM_BASE_DIR/tests/minimal_init.lua" --cmd "set runtimepath+=$LUNARVIM_BASE_DIR" "$@"
+}
+
+if [ -n "$1" ]; then
+ lvim --headless -c "lua require('plenary.busted').run('$1')"
+else
+ lvim --headless -c "PlenaryBustedDirectory tests/specs { minimal_init = './tests/minimal_init.lua' }"
+fi
diff --git a/mac/.config/LunarVim/utils/ci/update_changelog.sh b/mac/.config/LunarVim/utils/ci/update_changelog.sh
new file mode 100644
index 0000000..49dae53
--- /dev/null
+++ b/mac/.config/LunarVim/utils/ci/update_changelog.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+set -eo pipefail
+
+BRANCH="$(git rev-parse --abbrev-ref HEAD)"
+
+if [ "$BRANCH" != "master" ]; then
+ exit 0
+fi
+
+REPO_DIR="$(git rev-parse --show-toplevel)"
+LATEST_TAG="$(git describe --tags --abbrev=0)"
+CONFIG_FILE="$REPO_DIR/.github/workflows/cliff.toml"
+CHANGELOG="$REPO_DIR/CHANGELOG.md"
+
+git -C "$REPO_DIR" cliff "$LATEST_TAG"..HEAD -u -c "$CONFIG_FILE" -p "$CHANGELOG"
diff --git a/mac/.config/LunarVim/utils/ci/verify_plugins.lua b/mac/.config/LunarVim/utils/ci/verify_plugins.lua
new file mode 100644
index 0000000..95d98a1
--- /dev/null
+++ b/mac/.config/LunarVim/utils/ci/verify_plugins.lua
@@ -0,0 +1,147 @@
+local completed = 0
+local collection = {}
+local active_jobs = {}
+
+local fmt = string.format
+local core_plugins = require "lvim.plugins"
+
+local default_snapshot_path = join_paths(get_lvim_base_dir(), "snapshots", "default.json")
+local fd = io.open(default_snapshot_path, "rb")
+local content
+if fd then
+ content = fd:read "*a"
+end
+local default_sha1 = vim.json.decode(content)
+
+local get_short_name = function(spec)
+ return spec[1]:match "/(%S*)"
+end
+
+local get_default_sha1 = function(spec)
+ local short_name, _ = get_short_name(spec)
+ assert(default_sha1[short_name])
+ return default_sha1[short_name].commit
+end
+
+local is_directory = require("lvim.utils").is_directory
+local lazydir = join_paths(get_runtime_dir(), "site", "pack", "lazy")
+
+local verify_lazy = function()
+ if not is_directory(lazydir) then
+ io.write "Lazy.nvim not installed!"
+ os.exit(1)
+ end
+ local status_ok, lazy = pcall(require, "lazy")
+ if status_ok and lazy then
+ return
+ end
+ io.write "Lazy.nvim not installed!"
+ os.exit(1)
+end
+
+local get_install_path = function(spec)
+ local prefix = join_paths(lazydir, "opt")
+ local path = join_paths(prefix, get_short_name(spec))
+ return is_directory(path) and path
+end
+
+local function call_proc(process, opts, cb)
+ local output, error_output = "", ""
+ local handle_stdout = function(err, chunk)
+ assert(not err, err)
+ if chunk then
+ output = output .. chunk
+ end
+ end
+
+ local handle_stderr = function(err, chunk)
+ assert(not err, err)
+ if chunk then
+ error_output = error_output .. chunk
+ end
+ end
+
+ local uv = vim.loop
+ local handle
+
+ local stdout = uv.new_pipe(false)
+ local stderr = uv.new_pipe(false)
+
+ local stdio = { nil, stdout, stderr }
+
+ handle = uv.spawn(
+ process,
+ { args = opts.args, cwd = opts.cwd or uv.cwd(), stdio = stdio },
+ vim.schedule_wrap(function(code)
+ if code ~= 0 then
+ ---@diagnostic disable-next-line: undefined-field
+ stdout:read_stop()
+ ---@diagnostic disable-next-line: undefined-field
+ stderr:read_stop()
+ end
+
+ local check = uv.new_check()
+ check:start(function()
+ for _, pipe in ipairs(stdio) do
+ if pipe and not pipe:is_closing() then
+ return
+ end
+ end
+ check:stop()
+ handle:close()
+ cb(code, output, error_output)
+ end)
+ end)
+ )
+
+ uv.read_start(stdout, handle_stdout)
+ uv.read_start(stderr, handle_stderr)
+
+ return handle
+end
+
+local function verify_core_plugins(verbose)
+ for _, spec in pairs(core_plugins) do
+ local path = get_install_path(spec)
+ if spec.enabled or spec.enabled == nil and path then
+ table.insert(collection, {
+ name = get_short_name(spec),
+ commit = get_default_sha1(spec),
+ path = path,
+ })
+ end
+ end
+
+ for _, entry in pairs(collection) do
+ local on_done = function(code, result, errors)
+ completed = completed + 1
+ if code ~= 0 then
+ io.write(errors .. "\n")
+ -- os.exit(code)
+ else
+ if verbose then
+ io.write(fmt("verified [%s]\n", entry.name))
+ end
+ end
+ local current_commit = result:gsub("\n", ""):gsub([[']], [[]]):sub(1, 7)
+ -- just in case there are some extra qutoes or it's a longer commit hash
+ if current_commit ~= entry.commit then
+ io.write(fmt("mismatch at [%s]: expected [%s], got [%s]\n", entry.name, entry.commit, current_commit))
+ os.exit(1)
+ end
+ end
+
+ local handle = call_proc("git", { args = { "rev-parse", "--short", "HEAD" }, cwd = entry.path }, on_done)
+ assert(handle)
+ table.insert(active_jobs, handle)
+ end
+
+ vim.wait(#active_jobs * 60 * 1000, function()
+ ---@diagnostic disable-next-line: redundant-return-value
+ return completed == #active_jobs
+ end)
+end
+
+verify_lazy()
+verify_core_plugins()
+vim.cmd "q"
diff --git a/mac/.config/LunarVim/utils/ci/verify_plugins.sh b/mac/.config/LunarVim/utils/ci/verify_plugins.sh
new file mode 100644
index 0000000..48ed12f
--- /dev/null
+++ b/mac/.config/LunarVim/utils/ci/verify_plugins.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+set -e
+
+BASEDIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
+BASEDIR="$(dirname -- "$(dirname -- "$BASEDIR")")"
+
+LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-"$BASEDIR"}"
+
+lvim --headless \
+ -c "luafile ${LUNARVIM_BASE_DIR}/utils/ci/verify_plugins.lua"