[Feature] Add format check in CI. #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
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@v3 | |
- name: Pre-commit | |
uses: pre-commit/action@v3.0.1 | |
- 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: | |
include: | |
- {os: ubuntu-latest, arch: x86_64} | |
- {os: ubuntu-24.04-arm, arch: aarch64} | |
- {os: windows-latest, arch: AMD64} | |
- {os: macos-14, arch: arm64} | |
- {os: macos-13, arch: x86_64,} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Build xgrammar from source | |
run: | | |
echo "set(XGRAMMAR_BUILD_CXX_TESTS ON)" >> cmake/config.cmake | |
python -m pip install --upgrade pip | |
pip install -e . | |
- name: Run C++ tests | |
run: | | |
ctest --test-dir build | |
- name: Run Python tests | |
env: | |
HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
if: env.HF_TOKEN != '' | |
run: | | |
pip install pytest | |
pytest | |
- name: Run Python tests without HF_TOKEN | |
env: | |
HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
if: env.HF_TOKEN == '' | |
run: | | |
pip install pytest | |
pytest -m "not hf_token_required" |