Skip to content

Commit d6ce016

Browse files
authored
Merge pull request #1243 from bact/fix-pypi-test-workflow
Fix pypi-test workflow
2 parents 610c219 + 2a21db1 commit d6ce016

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

.github/workflows/pypi-test.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# SPDX-FileCopyrightText: 2016-2026 PyThaiNLP Project
22
# SPDX-License-Identifier: CC0-1.0
33

4-
name: PyPI Unit test
4+
# Check that the package can be installed from PyPI and run tests
5+
6+
name: Test package installed from PyPI
57

68
on:
79
schedule:
@@ -13,7 +15,8 @@ jobs:
1315
runs-on: ubuntu-latest
1416
strategy:
1517
matrix:
16-
python-version: ["3.12"]
18+
# Ideally, this is the minimum supported version, as in requires-python in pyproject.toml
19+
python-version: ["3.9"]
1720

1821
steps:
1922
- uses: actions/checkout@v6
@@ -30,17 +33,20 @@ jobs:
3033
python -m nltk.downloader omw-1.4
3134
- name: Test
3235
run: |
33-
mkdir pythainlp_test
36+
set -euo pipefail
37+
mkdir -p pythainlp_test
3438
cd pythainlp_test
39+
# Download sdist from PyPI (the binary distribution does not contain tests)
3540
pip download --no-binary=:all: --no-dependencies pythainlp
36-
file="find . -name *.tar.gz"
37-
file=$(eval "$file")
38-
tar -xvzf $file --one-top-level
39-
second="/"
40-
path=${file//.tar.gz/$second}
41-
cd $path
42-
ls
43-
cd tests
44-
mkdir tests
45-
mv data tests/
46-
python -m unittest discover
41+
archive=$(ls -1 *.tar.gz | head -n1)
42+
echo "Found archive: $archive"
43+
# Determine top-level folder inside archive, extract and cd into it
44+
topdir=$(tar -tf "$archive" | head -n1 | cut -f1 -d"/")
45+
tar -xzf "$archive"
46+
cd "$topdir"
47+
ls -la
48+
# If test data is at package root and a tests dir exists, move it into tests
49+
if [ -d data ] && [ -d tests ]; then
50+
mv data tests/
51+
fi
52+
python -m unittest discover -v

0 commit comments

Comments
 (0)