From 92b3acfa5b0348e942c33a3fd52b5828a9bb36eb Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Sun, 5 Jan 2025 18:15:37 -0500 Subject: [PATCH 1/3] ci: improve build matrix configuration Problem 1: Dynamic matrix configuration using matrix.{include,exclude} is complicated, making it difficult to add a few additional matrix configurations. For example, if we wanted to add a new axis in the matrix configuration that should be enabled only for specific configs (e.g., neovim stable vs. nightly only for python-version='3.12'), we would need to write long lines of include or exclude rules, which are quite difficult to read. Solution 1: Avoid using matrix.include and matrix.exclude, and specify runner OS version paired with python-version. The runner OS version can be simply determined by reading the associative array `matrix.config` with the platform-specific key. Problem 2: macos-12 has been deprecated and can no longer be run. Solution 2: Switch to macos-13 runner for old python versions. --- .github/workflows/test.yml | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4241e6b8..644f1ce7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,35 +27,27 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.12', '3.11', '3.10', '3.9', '3.8', '3.7'] - os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - exclude: - - os: 'ubuntu-latest' - python-version: '3.7' - - os: 'macos-latest' - python-version: '3.7' - - os: 'macos-latest' - python-version: '3.8' - - os: 'macos-latest' - python-version: '3.9' - include: - - os: 'ubuntu-20.04' - python-version: '3.7' - - os: 'macos-12' - python-version: '3.7' - - os: 'macos-12' - python-version: '3.8' - - os: 'macos-12' - python-version: '3.9' + config: [ + { python-version: '3.12' }, + { python-version: '3.11' }, + { python-version: '3.10' }, + # for python 3.7~3.9, use older version of OS (ubuntu-20.04 and macos-12) + { python-version: '3.9', ubuntu: '20.04', macos: '13' }, + { python-version: '3.8', ubuntu: '20.04', macos: '13' }, + { python-version: '3.7', ubuntu: '20.04', macos: '13' }, + ] + os: ['ubuntu', 'macos', 'windows'] - name: "test (python ${{ matrix.python-version }}, ${{ matrix.os }})" - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.os }}-${{ matrix.config[matrix.os] || 'latest' }} + name: + test (python ${{ matrix.config.python-version }}, + ${{ matrix.os }}-${{ matrix.config[matrix.os] || 'latest' }}) steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: cache: 'pip' - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.config.python-version }} - name: install neovim (Linux/macOS) if: runner.os != 'Windows' From 3a4b6700751fd17f07b0201c44106a3388106df1 Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Sun, 5 Jan 2025 19:05:30 -0500 Subject: [PATCH 2/3] ci: add more configurations (python3.13, neovim-version='stable') - Test with python=3.13 - Test with neovim-version='stable' for python=3.12 in addition to neovim-version='nightly'. --- .github/workflows/test.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 644f1ce7..6f09ffab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,9 @@ jobs: fail-fast: false matrix: config: [ - { python-version: '3.12' }, + { python-version: '3.13', neovim-version: 'nightly' }, + { python-version: '3.12', neovim-version: 'nightly' }, + { python-version: '3.12', neovim-version: 'stable' }, { python-version: '3.11' }, { python-version: '3.10' }, # for python 3.7~3.9, use older version of OS (ubuntu-20.04 and macos-12) @@ -38,10 +40,11 @@ jobs: ] os: ['ubuntu', 'macos', 'windows'] - runs-on: ${{ matrix.os }}-${{ matrix.config[matrix.os] || 'latest' }} name: test (python ${{ matrix.config.python-version }}, + ${{ matrix.config.neovim-version || 'nightly' }}, ${{ matrix.os }}-${{ matrix.config[matrix.os] || 'latest' }}) + runs-on: ${{ matrix.os }}-${{ matrix.config[matrix.os] || 'latest' }} steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 @@ -62,7 +65,7 @@ jobs: echo "$RUNNER_OS not supported"; exit 1; fi - curl -LO "https://github.com/neovim/neovim/releases/download/nightly/${BASE}.tar.gz" + curl -LO "https://github.com/neovim/neovim/releases/download/${{ matrix.config.neovim-version || 'nightly' }}/${BASE}.tar.gz" tar xzf "${BASE}.tar.gz" echo "RUNNER_OS = $RUNNER_OS" $BASE/bin/nvim --version From c3fe99344d1c3f788b160fffc9e019f6b7bf3eca Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Sun, 5 Jan 2025 22:20:38 -0500 Subject: [PATCH 3/3] fix(tests): skip failing test_broadcast on neovim < 0.11 The fix made in #570 actually works for Nvim 0.11+, depending on the behavior change neovim/neovim#28487. We should just skip test_broadcast on older Nvim versions (see #585). --- test/test_events.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/test_events.py b/test/test_events.py index c978293d..ee481d95 100644 --- a/test/test_events.py +++ b/test/test_events.py @@ -1,4 +1,5 @@ -# -*- coding: utf-8 -*- +import pytest + from pynvim.api import Nvim @@ -37,6 +38,10 @@ def test_async_error(vim: Nvim) -> None: def test_broadcast(vim: Nvim) -> None: + if (vim.version.major, vim.version.minor) < (0, 11): + # see #570, neovim/neovim#28487 + pytest.skip("neovim/neovim#28487") + vim.command('call rpcnotify(0, "event1", 1, 2, 3)') vim.command('call rpcnotify(0, "event2", 4, 5, 6)') vim.command('call rpcnotify(0, "event2", 7, 8, 9)')