diff options
-rw-r--r-- | .github/workflows/labeler.yml | 90 | ||||
-rw-r--r-- | .github/workflows/reviews.yml | 99 | ||||
-rw-r--r-- | ci/common/build.sh | 7 | ||||
-rw-r--r-- | ci/common/suite.sh | 18 | ||||
-rw-r--r-- | ci/common/test.sh | 9 | ||||
-rwxr-xr-x | ci/run_tests.sh | 24 | ||||
-rw-r--r-- | runtime/autoload/health.vim | 9 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 6 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 25 | ||||
-rw-r--r-- | test/functional/fixtures/lua/test_plug/submodule_empty/health.lua | 7 | ||||
-rw-r--r-- | test/functional/plugin/health_spec.lua | 14 |
11 files changed, 169 insertions, 139 deletions
diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 4940d6bb58..3de0c453a5 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -32,93 +32,3 @@ jobs: - name: "Extract commit scope and add as label" continue-on-error: true run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+\((.+)\)!?:.*|\1|')" - - add-reviewer: - runs-on: ubuntu-latest - needs: ["triage", "type-scope"] - permissions: - pull-requests: write - steps: - - uses: actions/github-script@v5 - with: - script: | - const reviewers = [] - - const { data: { labels } } = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.issue.number - }) - const label_names = labels.map(label => label.name) - - if (label_names.includes('api')) { - reviewers.push("bfredl") - reviewers.push("gpanders") - reviewers.push("muniter") - } - - if (label_names.includes('ci')) { - reviewers.push("jamessan") - } - - if (label_names.includes('diagnostic')) { - reviewers.push("gpanders") - } - - if (label_names.includes('distribution')) { - reviewers.push("jamessan") - } - - if (label_names.includes('documentation')) { - reviewers.push("clason") - } - - if (label_names.includes('extmarks')) { - reviewers.push("bfredl") - } - - if (label_names.includes('filetype')) { - reviewers.push("clason") - reviewers.push("gpanders") - } - - if (label_names.includes('gui')) { - reviewers.push("glacambre") - reviewers.push("smolck") - } - - if (label_names.includes('lsp')) { - reviewers.push("mfussenegger") - reviewers.push("mjlbach") - } - - if (label_names.includes('treesitter')) { - reviewers.push("bfredl") - reviewers.push("vigoux") - } - - if (label_names.includes('typo')) { - reviewers.push("dundargoc") - } - - if (label_names.includes('ui')) { - reviewers.push("bfredl") - } - - if (label_names.includes('vim-patch')) { - reviewers.push("janlazo") - reviewers.push("seandewar") - reviewers.push("zeertzjq") - } - - const index = reviewers.indexOf(context.actor); - if (index > -1) { - reviewers.splice(index, 1); - } - - github.rest.pulls.requestReviewers({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.issue.number, - reviewers: reviewers - }); diff --git a/.github/workflows/reviews.yml b/.github/workflows/reviews.yml new file mode 100644 index 0000000000..1491482b98 --- /dev/null +++ b/.github/workflows/reviews.yml @@ -0,0 +1,99 @@ +name: "Request reviews" +on: + pull_request_target: + types: [labeled] + workflow_run: + workflows: [Pull Request Labeler] + types: [completed] +jobs: + request-reviewer: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/github-script@v5 + with: + script: | + // The number of the pull request that triggered this run. If label + // was added manually by a person the number will be stored in current + // context, otherwise the number will be stored in the payload. + const pr_number = context.issue.number || context.payload.workflow_run.pull_requests[0].number + + const pr_data = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr_number + }) + const labels = pr_data.data.labels.map(e => e.name) + + const reviewers = new Set() + if (labels.includes('api')) { + reviewers.add("bfredl") + reviewers.add("gpanders") + reviewers.add("muniter") + } + + if (labels.includes('ci')) { + reviewers.add("jamessan") + } + + if (labels.includes('diagnostic')) { + reviewers.add("gpanders") + } + + if (labels.includes('distribution')) { + reviewers.add("jamessan") + } + + if (labels.includes('documentation')) { + reviewers.add("clason") + } + + if (labels.includes('extmarks')) { + reviewers.add("bfredl") + } + + if (labels.includes('filetype')) { + reviewers.add("clason") + reviewers.add("gpanders") + } + + if (labels.includes('gui')) { + reviewers.add("glacambre") + reviewers.add("smolck") + } + + if (labels.includes('lsp')) { + reviewers.add("mfussenegger") + reviewers.add("mjlbach") + } + + if (labels.includes('treesitter')) { + reviewers.add("bfredl") + reviewers.add("vigoux") + } + + if (labels.includes('typo')) { + reviewers.add("dundargoc") + } + + if (labels.includes('ui')) { + reviewers.add("bfredl") + } + + if (labels.includes('vim-patch')) { + reviewers.add("janlazo") + reviewers.add("seandewar") + reviewers.add("zeertzjq") + } + + // Remove person that opened the PR since they can't review themselves + const pr_opener = pr_data.data.user.login + reviewers.delete(pr_opener) + + github.rest.pulls.requestReviewers({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr_number, + reviewers: Array.from(reviewers) + }); diff --git a/ci/common/build.sh b/ci/common/build.sh index c44c234274..b8bbff0b16 100644 --- a/ci/common/build.sh +++ b/ci/common/build.sh @@ -44,7 +44,9 @@ build_deps() { cd "${CI_BUILD_DIR}" } -prepare_build() { +build_nvim() { + check_core_dumps --delete quiet + if test -n "${CLANG_SANITIZER}" ; then CMAKE_FLAGS="${CMAKE_FLAGS} -DCLANG_${CLANG_SANITIZER}=ON" fi @@ -53,9 +55,8 @@ prepare_build() { cd "${BUILD_DIR}" echo "Configuring with '${CMAKE_FLAGS} $@'." cmake -G Ninja ${CMAKE_FLAGS} "$@" "${CI_BUILD_DIR}" -} -build_nvim() { + echo "Building nvim." if ! top_make nvim ; then exit 1 diff --git a/ci/common/suite.sh b/ci/common/suite.sh index f6a8c22d21..8f6d81e264 100644 --- a/ci/common/suite.sh +++ b/ci/common/suite.sh @@ -47,13 +47,7 @@ exit_suite() { ci_fold "end" "" fi export NVIM_TEST_CURRENT_SUITE="${NVIM_TEST_CURRENT_SUITE%/*}" - if test "$1" != "--continue" ; then - exit $FAILED - else - local saved_failed=$FAILED - FAILED=0 - return $saved_failed - fi + FAILED=0 } fail() { @@ -71,12 +65,6 @@ fail() { FAILED=1 } -run_test() { - local cmd="$1" - local test_name="$2" - eval "$cmd" || fail "$test_name" -} - ended_successfully() { if test -f "${FAIL_SUMMARY_FILE}" ; then echo 'Test failed, complete summary:' @@ -100,7 +88,7 @@ run_suite() { local suite_name="$2" enter_suite "$suite_name" - run_test "$command" "$suite_name" - exit_suite --continue + eval "$command" || fail "$suite_name" + exit_suite } diff --git a/ci/common/test.sh b/ci/common/test.sh index 798f2926c6..c5f67edd2c 100644 --- a/ci/common/test.sh +++ b/ci/common/test.sh @@ -87,18 +87,15 @@ check_sanitizer() { } run_unittests() {( - enter_suite unittests ulimit -c unlimited || true if ! build_make unittest ; then fail 'unittests' F 'Unit tests failed' fi submit_coverage unittest check_core_dumps "$(command -v luajit)" - exit_suite )} run_functionaltests() {( - enter_suite functionaltests ulimit -c unlimited || true if ! build_make ${FUNCTIONALTEST}; then fail 'functionaltests' F 'Functional tests failed' @@ -107,11 +104,9 @@ run_functionaltests() {( check_sanitizer "${LOG_DIR}" valgrind_check "${LOG_DIR}" check_core_dumps - exit_suite )} run_oldtests() {( - enter_suite oldtests ulimit -c unlimited || true if ! make oldtest; then reset @@ -121,7 +116,6 @@ run_oldtests() {( check_sanitizer "${LOG_DIR}" valgrind_check "${LOG_DIR}" check_core_dumps - exit_suite )} check_runtime_files() {( @@ -146,7 +140,6 @@ check_runtime_files() {( )} install_nvim() {( - enter_suite 'install_nvim' if ! build_make install ; then fail 'install' E 'make install failed' exit_suite @@ -179,6 +172,4 @@ install_nvim() {( if ! grep -q "$gpat" "${INSTALL_PREFIX}/share/nvim/runtime/$genvimsynf" ; then fail 'funcnames' F "It appears that $genvimsynf does not contain $gpat." fi - - exit_suite )} diff --git a/ci/run_tests.sh b/ci/run_tests.sh index 6c310ccc76..1baeb090a8 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -8,29 +8,17 @@ source "${CI_DIR}/common/build.sh" source "${CI_DIR}/common/test.sh" source "${CI_DIR}/common/suite.sh" -enter_suite build +run_suite 'build_nvim' 'build' -check_core_dumps --delete quiet - -prepare_build -build_nvim - -exit_suite --continue - -enter_suite tests - -if test "$CLANG_SANITIZER" != "TSAN" ; then +if test "$CLANG_SANITIZER" != "TSAN"; then # Additional threads are only created when the builtin UI starts, which # doesn't happen in the unit/functional tests if test "${FUNCTIONALTEST}" != "functionaltest-lua"; then - run_test run_unittests unittests + run_suite run_unittests unittests fi - run_test run_functionaltests functionaltests + run_suite run_functionaltests functionaltests fi -run_test run_oldtests oldtests - -run_test install_nvim install_nvim - -exit_suite --continue +run_suite run_oldtests oldtests +run_suite install_nvim install_nvim end_tests diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim index 1d462ad02c..ec030adf04 100644 --- a/runtime/autoload/health.vim +++ b/runtime/autoload/health.vim @@ -21,10 +21,17 @@ function! health#check(plugin_names) abort throw 'healthcheck_not_found' endif eval type == 'v' ? call(func, []) : luaeval(func) + " in the event the healthcheck doesn't return anything + " (the plugin author should avoid this possibility) + if len(s:output) == 0 + throw 'healthcheck_no_return_value' + endif catch let s:output = [] " Clear the output if v:exception =~# 'healthcheck_not_found' call health#report_error('No healthcheck found for "'.name.'" plugin.') + elseif v:exception =~# 'healthcheck_no_return_value' + call health#report_error('The healthcheck report for "'.name.'" plugin is empty.') else call health#report_error(printf( \ "Failed to run healthcheck for \"%s\" plugin. Exception:\n%s\n%s", @@ -127,7 +134,7 @@ endfunction " }}} " From a path return a list [{name}, {func}, {type}] representing a healthcheck function! s:filepath_to_healthcheck(path) abort - if a:path =~# 'vim$' + if a:path =~# 'vim$' let name = matchstr(a:path, '\zs[^\/]*\ze\.vim$') let func = 'health#'.name.'#check' let type = 'v' diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index ada041bab2..f7c55344f5 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -31,6 +31,7 @@ #include "nvim/file_search.h" #include "nvim/fileio.h" #include "nvim/getchar.h" +#include "nvim/globals.h" #include "nvim/highlight.h" #include "nvim/highlight_defs.h" #include "nvim/lua/executor.h" @@ -545,20 +546,19 @@ void nvim_set_current_dir(String dir, Error *err) return; } - char string[MAXPATHL]; + char_u string[MAXPATHL]; memcpy(string, dir.data, dir.size); string[dir.size] = NUL; try_start(); - if (vim_chdir((char_u *)string)) { + if (!changedir_func(string, kCdScopeGlobal)) { if (!try_end(err)) { api_set_error(err, kErrorTypeException, "Failed to change directory"); } return; } - post_chdir(kCdScopeGlobal, true); try_end(err); } diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 937b6559de..ccf3e81b22 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -536,6 +536,31 @@ describe('API', function() end) end) + describe('nvim_set_current_dir', function() + local start_dir + + before_each(function() + clear() + funcs.mkdir("Xtestdir") + start_dir = funcs.getcwd() + end) + + after_each(function() + helpers.rmdir("Xtestdir") + end) + + it('works', function() + meths.set_current_dir("Xtestdir") + eq(funcs.getcwd(), start_dir .. helpers.get_pathsep() .. "Xtestdir") + end) + + it('sets previous directory', function() + meths.set_current_dir("Xtestdir") + meths.exec('cd -', false) + eq(funcs.getcwd(), start_dir) + end) + end) + describe('nvim_exec_lua', function() it('works', function() meths.exec_lua('vim.api.nvim_set_var("test", 3)', {}) diff --git a/test/functional/fixtures/lua/test_plug/submodule_empty/health.lua b/test/functional/fixtures/lua/test_plug/submodule_empty/health.lua new file mode 100644 index 0000000000..d2cf86e4f0 --- /dev/null +++ b/test/functional/fixtures/lua/test_plug/submodule_empty/health.lua @@ -0,0 +1,7 @@ +local M = {} + +M.check = function() + return {} +end + +return M diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index f7c2dbdb43..a9bd76ce24 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -153,6 +153,10 @@ describe('health.vim', function() ## report 2 - OK: nothing to see here + test_plug.submodule_empty: require("test_plug.submodule_empty.health").check() + ======================================================================== + - ERROR: The healthcheck report for "test_plug.submodule_empty" plugin is empty. + test_plug.submodule_failed: require("test_plug.submodule_failed.health").check() ======================================================================== - ERROR: Failed to run healthcheck for "test_plug.submodule_failed" plugin. Exception: @@ -172,6 +176,16 @@ describe('health.vim', function() ]]) end) + it("... including empty reports", function() + command("checkhealth test_plug.submodule_empty") + helpers.expect([[ + + test_plug.submodule_empty: require("test_plug.submodule_empty.health").check() + ======================================================================== + - ERROR: The healthcheck report for "test_plug.submodule_empty" plugin is empty. + ]]) + end) + it("gracefully handles broken lua healthcheck", function() command("checkhealth test_plug.submodule_failed") local buf_lines = helpers.curbuf('get_lines', 0, -1, true) |