-
Notifications
You must be signed in to change notification settings - Fork 53
74 lines (63 loc) · 1.73 KB
/
unit_test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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"