Skip to content

Commit 92b3acf

Browse files
committed
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.
1 parent 63a0250 commit 92b3acf

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

.github/workflows/test.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,27 @@ jobs:
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
python-version: ['3.12', '3.11', '3.10', '3.9', '3.8', '3.7']
31-
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
32-
exclude:
33-
- os: 'ubuntu-latest'
34-
python-version: '3.7'
35-
- os: 'macos-latest'
36-
python-version: '3.7'
37-
- os: 'macos-latest'
38-
python-version: '3.8'
39-
- os: 'macos-latest'
40-
python-version: '3.9'
41-
include:
42-
- os: 'ubuntu-20.04'
43-
python-version: '3.7'
44-
- os: 'macos-12'
45-
python-version: '3.7'
46-
- os: 'macos-12'
47-
python-version: '3.8'
48-
- os: 'macos-12'
49-
python-version: '3.9'
30+
config: [
31+
{ python-version: '3.12' },
32+
{ python-version: '3.11' },
33+
{ python-version: '3.10' },
34+
# for python 3.7~3.9, use older version of OS (ubuntu-20.04 and macos-12)
35+
{ python-version: '3.9', ubuntu: '20.04', macos: '13' },
36+
{ python-version: '3.8', ubuntu: '20.04', macos: '13' },
37+
{ python-version: '3.7', ubuntu: '20.04', macos: '13' },
38+
]
39+
os: ['ubuntu', 'macos', 'windows']
5040

51-
name: "test (python ${{ matrix.python-version }}, ${{ matrix.os }})"
52-
runs-on: ${{ matrix.os }}
41+
runs-on: ${{ matrix.os }}-${{ matrix.config[matrix.os] || 'latest' }}
42+
name:
43+
test (python ${{ matrix.config.python-version }},
44+
${{ matrix.os }}-${{ matrix.config[matrix.os] || 'latest' }})
5345
steps:
5446
- uses: actions/checkout@v3
5547
- uses: actions/setup-python@v4
5648
with:
5749
cache: 'pip'
58-
python-version: ${{ matrix.python-version }}
50+
python-version: ${{ matrix.config.python-version }}
5951

6052
- name: install neovim (Linux/macOS)
6153
if: runner.os != 'Windows'

0 commit comments

Comments
 (0)