1- name : Unit test and coverage
1+ name : Unit test
22
33on :
44 push :
2323 runs-on : ${{ matrix.os }}
2424 env :
2525 PYICU_WIN_VER : 2.14
26- INSTALL_PYICU_WIN : false
2726 INSTALL_TORCH : false
2827 INSTALL_FULL_DEPS : false
28+ PYTHON_VERSION_LATEST : " 3.13"
29+ PYTHON_VERSION_LATEST_2 : " 3.12"
2930
3031 steps :
3132 - name : Checkout
5253 echo "ICU_VER=${ICU_VER}"
5354 echo "ICU_VER=${ICU_VER}" >> "${GITHUB_ENV}"
5455 - name : Install PyICU (Windows)
55- if : startsWith(matrix.os, 'windows-') && env.INSTALL_PYICU_WIN == 'true'
56+ if : startsWith(matrix.os, 'windows-') && (matrix.python-version == '3.12' || matrix.python-version == '3.13')
5657 shell : powershell
5758 run : |
5859 $PYTHON_WIN_VER = "${{ matrix.python-version }}"
@@ -66,29 +67,42 @@ jobs:
6667 # If torch for the platform is not available in PyPI, use this command:
6768 # pip install "<torch_wheel_url>"
6869 # Get wheel URL from http://download.pytorch.org/whl/torch/
69- - name : Install dependencies
70+ - name : Install dependencies from docker_requirements.txt
7071 if : env.INSTALL_FULL_DEPS == 'true'
7172 env :
7273 SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL : True
7374 run : pip install -r docker_requirements.txt
74- - name : Install PyThaiNLP
75- env :
76- PYTHONIOENCODING : utf-8
75+ - name : Install PyThaiNLP + dependencies (minimum)
76+ if : matrix.python-version != env.PYTHON_VERSION_LATEST && matrix.python-version != env.PYTHON_VERSION_LATEST_2
7777 run : pip install .
78+ - name : Install PyThaiNLP + dependencies (compact)
79+ if : matrix.python-version == env.PYTHON_VERSION_LATEST || matrix.python-version == env.PYTHON_VERSION_LATEST_2
80+ run : pip install ".[compact]"
7881 # If you want to install a safe small set of optional dependencies, use:
79- # pip install .[compact]
80- # "compact" includes numpy, pyicu, and python-crfsuite.
82+ # pip install ".[compact]"
8183 # We can gradually run more test cases by installing more optional
8284 # dependencies. But we should also consider to reduce the number
8385 # of dependencies to avoid the conflict between dependencies.
8486 # See: https://github.com/PyThaiNLP/pythainlp/issues/935
85- - name : Unit test and code coverage
86- run : coverage run -m unittest tests
87- # Use 'unittest tests' instead of 'unittest discover' to avoid loading
88- # tests with external imports.
87+ - name : Unit test (core)
88+ if : matrix.python-version != env.PYTHON_VERSION_LATEST && matrix.python-version != env.PYTHON_VERSION_LATEST_2
89+ env :
90+ PYTHONIOENCODING : utf-8
91+ run : coverage run -m unittest tests.core
92+ - name : Unit test (core + compact)
93+ if : matrix.python-version == env.PYTHON_VERSION_LATEST || matrix.python-version == env.PYTHON_VERSION_LATEST_2
94+ env :
95+ PYTHONIOENCODING : utf-8
96+ run : coverage run -m unittest tests.core tests.compact
97+ # Only test "compact" set with the latest two stable Python versions.
98+ # Use 'unittest <test_module>' instead of 'unittest discover' to avoid
99+ # loading tests with dependencies more than expected.
89100 # Test cases loaded is defined in __init__.py in the tests directory.
101+ # See also tests/README.md
90102 - name : Coverage report
103+ if : matrix.python-version == env.PYTHON_VERSION_LATEST
91104 env :
92105 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
93106 COVERALLS_SERVICE_NAME : github
94107 run : coveralls
108+ # Only submit a report from the latest Python version
0 commit comments