Skip to content

[Format] Rename two testing functions to expose them. #830

[Format] Rename two testing functions to expose them.

[Format] Rename two testing functions to expose them. #830

Workflow file for this run

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
jobs:
pre_check:
name: Pre-check on Ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
- name: Pre-commit
uses: pre-commit/[email protected]
- name: Ruff check
uses: astral-sh/ruff-action@v3
run_unit_test:
needs: [pre_check]
name: Run unit tests on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-14, macos-13]
python: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
exclude:
- os: macos-13
python: '3.13'
# The reason for the exclusion is that pytorch distribution
# can't be found by pip on macos-13 with python 3.13.
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Cache huggingface
uses: actions/cache@v4
with:
path: |
~/.cache/huggingface
key: huggingface-${{ matrix.os }}-python-${{ matrix.python }}
- name: Build xgrammar from source
run: |
echo "set(XGRAMMAR_BUILD_CXX_TESTS ON)" >> cmake/config.cmake
echo "set(XGRAMMAR_ENABLE_INTERNAL_CHECK ON)" >> cmake/config.cmake
python -m pip install --upgrade pip
pip install -v ".[test]"
- name: Run C++ tests
run: |
ctest --test-dir build -V --timeout 30 --stop-on-failure
- name: Run Python tests
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_HUB_DOWNLOAD_TIMEOUT: 60
if: env.HF_TOKEN != ''
run: |
pytest
- name: Run Python tests without HF_TOKEN
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
if: env.HF_TOKEN == ''
run: |
pytest -m "not hf_token_required"