Skip to content

add test for sdist

add test for sdist #51

name: Python Packages Test
on:
push:
branches: [ pre/v* ]
jobs:
build-wheels:
name: build wheels using cibuildwheel
runs-on: ${{ format('{0}-latest', matrix.os) }}
strategy:
fail-fast: false
matrix:
include:
- os: "ubuntu"
platform: "linux"
arch: "x86_64"
- os: "macos"
arch: "universal2"
- os: "windows"
arch: "AMD64"
env:
build-sdist: ${{ matrix.os == 'ubuntu' && matrix.arch == 'x86_64' }}
steps:
- uses: actions/checkout@v4
- name: setup python for sdist and cibuildwheel
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools setuptools-rust build cibuildwheel packaging
- name: download dictionary for PGO
if: ${{ matrix.os == 'ubuntu' }}
run: bash fetch_dictionary.sh "20220519" "core"
- name: Add aarch64/x86 target for macos
if: ${{ matrix.os == 'macos' }}
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Modify version for TestPyPI upload
run: python ./python/modify_version_for_testpypi.py
- name: build sdist
if: ${{ env.build-sdist == 'true' }}
working-directory: ./python
run: bash build-sdist.sh
- name: cibuildwheel ${{ matrix.platform || matrix.os }}
env:
# most configuration are in python/pyproject.toml
CIBW_PLATFORM: ${{ matrix.platform || matrix.os }}
CIBW_ARCHS: ${{ matrix.arch }}
run: cibuildwheel python/ --output-dir python/dist/
- uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.os }}
path: |
./python/dist/*.whl
./python/dist/*.tar.gz
upload-to-testpypi: # run only if all have succeeded
needs: [ build-wheels ]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: artifact-*
path: dist/
merge-multiple: true
- name: List files to upload
run: ls -R dist/
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PYPI_TEST_USERNAME }}
password: ${{ secrets.PYPI_TEST_PASSWORD }}
repository_url: https://test.pypi.org/legacy/
verbose: true
install-and-test:
needs: [ upload-to-testpypi ]
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macOS-latest ]
target: [ "3.9", "3.10", "3.11", "3.12", "3.13", "3.13t" ]
include:
- os: "ubuntu-latest"
target: "sdist"
python-version: "3.13"
exclude:
- os: "windows-latest"
target: "3.13t"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: Quansight-Labs/setup-python@v5
with:
python-version: ${{ matrix.python-version || matrix.target }}
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Show compatible tags
run: python -m pip debug --verbose
- name: Install dependencies (test)
run: python -m pip install sudachidict_core
- name: Install dependencies (test pretokenizer)
# tokenizers for py3.13t is not provided yet
if: ${{ matrix.target != '3.13t' }}
run: python -m pip install tokenizers
- name: Install dependencies (build sdist)
if: ${{ matrix.target == 'sdist' }}
run: python -m pip install -U setuptools setuptools-rust
- name: Install our module from TestPyPi
if: ${{ matrix.target != 'sdist' }}
run: python -m pip -vvvv install --pre -U -i https://test.pypi.org/simple/ SudachiPy
- name: Install our module from sdist
if: ${{ matrix.target == 'sdist' }}
run: |
python -m pip -vvvv install --pre -U -i https://test.pypi.org/simple/ --no-build-isolation --no-binary SudachiPy SudachiPy
- name: Run test
if: ${{ matrix.target != '3.13t' }}
working-directory: ./python
run: python -m unittest
- name: Run test (skip pretokenizer test)
# tokenizers for py3.13t is not provided yet
if: ${{ matrix.target == '3.13t' }}
working-directory: ./python
run: ls tests/test_*.py | grep -v pretokenizer | xargs -I{} python -m unittest {}
- name: Check that binary works (C mode)
run: |
sudachipy .github/data/input.txt -o result-c.txt
git diff --color=always --no-index -- result-c.txt .github/data/expected-c.txt
- name: Check that binary works (A mode)
run: |
sudachipy .github/data/input.txt -m A -o result-a.txt
git diff --color=always --no-index -- result-a.txt .github/data/expected-a.txt