Skip to content

Commit 8c01db9

Browse files
Copilotwannaphong
andcommitted
Add GitHub Actions workflow for Python bindings testing
- Add python-bindings-test job with Python 3.7-3.12 support - Test on ubuntu-latest, macos-latest, and windows-latest - Run Python tests, examples, and import checks - Upload build logs on failure for debugging Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
1 parent 95e4e6d commit 8c01db9

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/test.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,52 @@ jobs:
5656
build/
5757
lib/
5858
retention-days: 5
59+
60+
python-bindings-test:
61+
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
62+
runs-on: ${{ matrix.os }}
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
os: [ubuntu-latest, macos-latest, windows-latest]
67+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
68+
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
73+
- name: Set up Python ${{ matrix.python-version }}
74+
uses: actions/setup-python@v5
75+
with:
76+
python-version: ${{ matrix.python-version }}
77+
78+
- name: Display Python version
79+
run: |
80+
python --version
81+
pip --version
82+
83+
- name: Install package
84+
run: |
85+
pip install -e .
86+
87+
- name: Run Python tests
88+
run: |
89+
python tests/python/test_tokenize.py
90+
91+
- name: Run Python example
92+
run: |
93+
python examples/python/example_basic.py
94+
95+
- name: Test import and basic functionality
96+
run: |
97+
python -c "from cthainlp import word_tokenize; print('Import successful'); tokens = word_tokenize('ฉันไปโรงเรียน'); print('Tokens:', tokens); assert len(tokens) > 0, 'Tokenization failed'"
98+
99+
- name: Upload build logs
100+
if: failure()
101+
uses: actions/upload-artifact@v4
102+
with:
103+
name: python-build-logs-${{ matrix.os }}-py${{ matrix.python-version }}
104+
path: |
105+
build/
106+
*.log
107+
retention-days: 5

0 commit comments

Comments
 (0)