Skip to content

PyThaiNLP v5.1.0-beta1 #361

PyThaiNLP v5.1.0-beta1

PyThaiNLP v5.1.0-beta1 #361

Workflow file for this run

# SPDX-FileCopyrightText: 2016-2024 PyThaiNLP Project
# SPDX-License-Identifier: CC0-1.0
name: Unit test
on:
push:
paths-ignore:
- '**.md'
- 'docs/**'
pull_request:
branches:
- dev
paths-ignore:
- '**.md'
- 'docs/**'
jobs:
unittest:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
python-version: ["3.13", "3.12", "3.11", "3.10", "3.9"]
runs-on: ${{ matrix.os }}
env:
PYICU_WIN_VER: 2.14
INSTALL_TORCH: false
INSTALL_FULL_DEPS: false
PYTHON_VERSION_LATEST: "3.13"
PYTHON_VERSION_LATEST_2: "3.12"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install build tools
run: |
pip install --upgrade "pip<24.1" "setuptools>=65.0.2,<=73.0.1"
pip install coverage coveralls
# pip<24.1 because https://github.com/omry/omegaconf/pull/1195
# setuptools>=65.0.2 because https://github.com/pypa/setuptools/commit/d03da04e024ad4289342077eef6de40013630a44#diff-9ea6e1e3dde6d4a7e08c7c88eceed69ca745d0d2c779f8f85219b22266efff7fR1
# setuptools<=73.0.1 because https://github.com/pypa/setuptools/issues/4620
- name: Install ICU (macOS)
if: startsWith(matrix.os, 'macos-')
run: |
brew install icu4c
PKG_CONFIG_PATH=$(brew --prefix)/opt/icu4c/lib/pkgconfig
echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> "${GITHUB_ENV}"
ICU_VER=$(pkg-config --modversion icu-i18n)
echo "ICU_VER=${ICU_VER}"
echo "ICU_VER=${ICU_VER}" >> "${GITHUB_ENV}"
- name: Install PyICU (Windows)
if: startsWith(matrix.os, 'windows-') && (matrix.python-version == '3.12' || matrix.python-version == '3.13')
shell: powershell
run: |
$PYTHON_WIN_VER = "${{ matrix.python-version }}"
$CP_VER = "cp" + $PYTHON_WIN_VER.Replace(".", "")
$WHEEL_URL = "https://github.com/cgohlke/pyicu-build/releases/download/v${{ env.PYICU_WIN_VER }}/PyICU-${{ env.PYICU_WIN_VER }}-${CP_VER}-${CP_VER}-win_amd64.whl"
pip install "$WHEEL_URL"
# Get wheel URL from https://github.com/cgohlke/pyicu-build/releases
- name: Install PyTorch
if: env.INSTALL_TORCH == 'true'
run: pip install torch
# If torch for the platform is not available in PyPI, use this command:
# pip install "<torch_wheel_url>"
# Get wheel URL from http://download.pytorch.org/whl/torch/
- name: Install dependencies from docker_requirements.txt
if: env.INSTALL_FULL_DEPS == 'true'
env:
SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL: True
run: pip install -r docker_requirements.txt
- name: Install PyThaiNLP + dependencies (minimum)
if: matrix.python-version != env.PYTHON_VERSION_LATEST && matrix.python-version != env.PYTHON_VERSION_LATEST_2
run: pip install .
- name: Install PyThaiNLP + dependencies (compact)
if: matrix.python-version == env.PYTHON_VERSION_LATEST || matrix.python-version == env.PYTHON_VERSION_LATEST_2
run: pip install ".[compact]"
# If you want to install a safe small set of optional dependencies, use:
# pip install ".[compact]"
# We can gradually run more test cases by installing more optional
# dependencies. But we should also consider to reduce the number
# of dependencies to avoid the conflict between dependencies.
# See: https://github.com/PyThaiNLP/pythainlp/issues/935
- name: Unit test (core)
if: matrix.python-version != env.PYTHON_VERSION_LATEST && matrix.python-version != env.PYTHON_VERSION_LATEST_2
env:
PYTHONIOENCODING: utf-8
run: coverage run -m unittest tests.core
- name: Unit test (core + compact)
if: matrix.python-version == env.PYTHON_VERSION_LATEST || matrix.python-version == env.PYTHON_VERSION_LATEST_2
env:
PYTHONIOENCODING: utf-8
run: coverage run -m unittest tests.core tests.compact
# Only test "compact" set with the latest two stable Python versions.
# Use 'unittest <test_module>' instead of 'unittest discover' to avoid
# loading tests with dependencies more than expected.
# Test cases loaded is defined in __init__.py in the tests directory.
# See also tests/README.md
- name: Coverage report
if: matrix.os == 'ubuntu-latest' && matrix.python-version == env.PYTHON_VERSION_LATEST
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_SERVICE_NAME: github
run: coveralls
# Only submit a report from the latest Python version on ubuntu-latest.