Skip to content

Commit a8ef8cf

Browse files
authored
[Format] Setup YAML formatter and format current code (mlc-ai#119)
This PR setups the yaml formatter. It also formats current code that is not formatted well.
1 parent a110a2f commit a8ef8cf

31 files changed

+424
-426
lines changed

.github/workflows/documentation.yaml

+22-22
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v2
18-
with:
19-
submodules: recursive
17+
- uses: actions/checkout@v2
18+
with:
19+
submodules: recursive
2020

21-
- name: Configuring build Environment
22-
run: |
23-
sudo apt-get update
24-
python -m pip install -U pip wheel
21+
- name: Configuring build Environment
22+
run: |
23+
sudo apt-get update
24+
python -m pip install -U pip wheel
2525
26-
- name: Setup Ruby
27-
uses: ruby/setup-ruby@v1
28-
with:
29-
ruby-version: '3.0'
26+
- name: Setup Ruby
27+
uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: '3.0'
3030

31-
- name: Installing dependencies
32-
run: |
33-
python -m pip install -r docs/requirements.txt
34-
gem install jekyll jekyll-remote-theme
31+
- name: Installing dependencies
32+
run: |
33+
python -m pip install -r docs/requirements.txt
34+
gem install jekyll jekyll-remote-theme
3535
36-
- name: Deploying on GitHub Pages
37-
if: github.ref == 'refs/heads/main'
38-
run: |
39-
git remote set-url origin https://x-access-token:${{ secrets.MLC_GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
40-
git config --global user.email "mlc-gh-actions-bot@nomail"
41-
git config --global user.name "mlc-gh-actions-bot"
42-
./scripts/gh_deploy_site.sh
36+
- name: Deploying on GitHub Pages
37+
if: github.ref == 'refs/heads/main'
38+
run: |
39+
git remote set-url origin https://x-access-token:${{ secrets.MLC_GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
40+
git config --global user.email "mlc-gh-actions-bot@nomail"
41+
git config --global user.name "mlc-gh-actions-bot"
42+
./scripts/gh_deploy_site.sh

.github/workflows/wheel_mac.yaml

+108-108
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Wheel-Mac
44
on:
55
push:
66
tags:
7-
- '*' # Push events to every tag not containing /
7+
- '*' # Push events to every tag not containing /
88

99
jobs:
1010
Build:
@@ -18,121 +18,121 @@ jobs:
1818
shell: 'bash -l {0}'
1919

2020
steps:
21-
- uses: actions/checkout@v3
22-
with:
23-
submodules: 'recursive'
24-
- name: Checkout source
25-
run: |
26-
git clone https://github.com/mlc-ai/package package --recursive
27-
- name: Setup script env
28-
run: |
29-
mv scripts/build-environment.yaml package/3rdparty/tlcpack/conda/build-environment.yaml
30-
rm -rf conda
31-
ln -s package/3rdparty/tlcpack/conda conda
32-
- name: Sync XGrammar Package
33-
run: |
34-
python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }}
35-
# Build wheel for different python versions
36-
- name: Setup@Py39
37-
uses: conda-incubator/setup-miniconda@v3
38-
with:
39-
activate-environment: build-Py39
40-
channel-priority: strict
41-
environment-file: conda/build-environment.yaml
42-
python-version: 3.9
43-
auto-activate-base: false
44-
- name: XGrammar-Build@Py39
45-
run: >-
46-
scripts/build_xgrammar_lib_osx.sh ${{ matrix.platform == 'macos-13' && '10.15' || '13.02' }}
47-
- name: Wheel-Build@Py39
48-
run: |
49-
python --version
50-
python -m pip install setuptools Cython wheel
51-
cd python
52-
python setup.py bdist_wheel
53-
rm -rf xgrammar/*.so
54-
- name: Setup@Py310
55-
uses: conda-incubator/setup-miniconda@v3
56-
with:
57-
activate-environment: build-Py310
58-
channel-priority: strict
59-
environment-file: conda/build-environment.yaml
60-
python-version: '3.10'
61-
auto-activate-base: false
62-
- name: XGrammar-Build@Py310
63-
run: >-
64-
scripts/build_xgrammar_lib_osx.sh ${{ matrix.platform == 'macos-13' && '10.15' || '13.02' }}
65-
- name: Wheel-Build@Py310
66-
run: |
67-
python --version
68-
python -m pip install setuptools Cython wheel
69-
cd python
70-
python setup.py bdist_wheel
71-
rm -rf xgrammar/*.so
72-
- name: Setup@Py311
73-
uses: conda-incubator/setup-miniconda@v3
74-
with:
75-
activate-environment: build-Py311
76-
channel-priority: strict
77-
environment-file: conda/build-environment.yaml
78-
python-version: '3.11'
79-
auto-activate-base: false
80-
- name: XGrammar-Build@Py311
81-
run: >-
82-
scripts/build_xgrammar_lib_osx.sh ${{ matrix.platform == 'macos-13' && '10.15' || '13.02' }}
83-
- name: Wheel-Build@Py311
84-
run: |
85-
python --version
86-
python -m pip install setuptools Cython wheel
87-
cd python
88-
python setup.py bdist_wheel
89-
rm -rf xgrammar/*.so
90-
- name: Setup@Py312
91-
uses: conda-incubator/setup-miniconda@v3
92-
with:
93-
activate-environment: build-Py312
94-
channel-priority: strict
95-
environment-file: conda/build-environment.yaml
96-
python-version: '3.12'
97-
auto-activate-base: false
98-
- name: XGrammar-Build@Py312
99-
run: >-
100-
scripts/build_xgrammar_lib_osx.sh ${{ matrix.platform == 'macos-13' && '10.15' || '13.02' }}
101-
- name: Wheel-Build@Py312
102-
run: |
103-
python --version
104-
python -m pip install setuptools Cython wheel
105-
cd python
106-
python setup.py bdist_wheel
107-
rm -rf xgrammar/*.so
108-
- uses: actions/upload-artifact@v4
109-
with:
110-
name: xgrammar-wheel-${{ github.ref_name }}-${{ matrix.platform }}
111-
path: python/dist/
112-
retention-days: 3
113-
overwrite: true
21+
- uses: actions/checkout@v3
22+
with:
23+
submodules: 'recursive'
24+
- name: Checkout source
25+
run: |
26+
git clone https://github.com/mlc-ai/package package --recursive
27+
- name: Setup script env
28+
run: |
29+
mv scripts/build-environment.yaml package/3rdparty/tlcpack/conda/build-environment.yaml
30+
rm -rf conda
31+
ln -s package/3rdparty/tlcpack/conda conda
32+
- name: Sync XGrammar Package
33+
run: |
34+
python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }}
35+
# Build wheel for different python versions
36+
- name: Setup@Py39
37+
uses: conda-incubator/setup-miniconda@v3
38+
with:
39+
activate-environment: build-Py39
40+
channel-priority: strict
41+
environment-file: conda/build-environment.yaml
42+
python-version: 3.9
43+
auto-activate-base: false
44+
- name: XGrammar-Build@Py39
45+
run: >-
46+
scripts/build_xgrammar_lib_osx.sh ${{ matrix.platform == 'macos-13' && '10.15' || '13.02' }}
47+
- name: Wheel-Build@Py39
48+
run: |
49+
python --version
50+
python -m pip install setuptools Cython wheel
51+
cd python
52+
python setup.py bdist_wheel
53+
rm -rf xgrammar/*.so
54+
- name: Setup@Py310
55+
uses: conda-incubator/setup-miniconda@v3
56+
with:
57+
activate-environment: build-Py310
58+
channel-priority: strict
59+
environment-file: conda/build-environment.yaml
60+
python-version: '3.10'
61+
auto-activate-base: false
62+
- name: XGrammar-Build@Py310
63+
run: >-
64+
scripts/build_xgrammar_lib_osx.sh ${{ matrix.platform == 'macos-13' && '10.15' || '13.02' }}
65+
- name: Wheel-Build@Py310
66+
run: |
67+
python --version
68+
python -m pip install setuptools Cython wheel
69+
cd python
70+
python setup.py bdist_wheel
71+
rm -rf xgrammar/*.so
72+
- name: Setup@Py311
73+
uses: conda-incubator/setup-miniconda@v3
74+
with:
75+
activate-environment: build-Py311
76+
channel-priority: strict
77+
environment-file: conda/build-environment.yaml
78+
python-version: '3.11'
79+
auto-activate-base: false
80+
- name: XGrammar-Build@Py311
81+
run: >-
82+
scripts/build_xgrammar_lib_osx.sh ${{ matrix.platform == 'macos-13' && '10.15' || '13.02' }}
83+
- name: Wheel-Build@Py311
84+
run: |
85+
python --version
86+
python -m pip install setuptools Cython wheel
87+
cd python
88+
python setup.py bdist_wheel
89+
rm -rf xgrammar/*.so
90+
- name: Setup@Py312
91+
uses: conda-incubator/setup-miniconda@v3
92+
with:
93+
activate-environment: build-Py312
94+
channel-priority: strict
95+
environment-file: conda/build-environment.yaml
96+
python-version: '3.12'
97+
auto-activate-base: false
98+
- name: XGrammar-Build@Py312
99+
run: >-
100+
scripts/build_xgrammar_lib_osx.sh ${{ matrix.platform == 'macos-13' && '10.15' || '13.02' }}
101+
- name: Wheel-Build@Py312
102+
run: |
103+
python --version
104+
python -m pip install setuptools Cython wheel
105+
cd python
106+
python setup.py bdist_wheel
107+
rm -rf xgrammar/*.so
108+
- uses: actions/upload-artifact@v4
109+
with:
110+
name: xgrammar-wheel-${{ github.ref_name }}-${{ matrix.platform }}
111+
path: python/dist/
112+
retention-days: 3
113+
overwrite: true
114114

115115
Publish-to-PyPI:
116116
needs:
117-
- Build
117+
- Build
118118
runs-on: ubuntu-latest
119119

120120
environment:
121121
name: pypi
122122
url: https://pypi.org/p/xgrammar
123123
permissions:
124-
id-token: write # IMPORTANT: mandatory for trusted publishing
124+
id-token: write # IMPORTANT: mandatory for trusted publishing
125125

126126
steps:
127-
- name: Download all the wheels
128-
uses: actions/download-artifact@v4
129-
with:
130-
pattern: xgrammar-wheel-${{ github.ref_name }}-macos-*
131-
path: python/dist/
132-
merge-multiple: true
133-
- name: Publish package distributions to PyPI
134-
uses: pypa/gh-action-pypi-publish@release/v1
135-
with:
136-
packages_dir: python/dist
137-
skip_existing: true
138-
verbose: true
127+
- name: Download all the wheels
128+
uses: actions/download-artifact@v4
129+
with:
130+
pattern: xgrammar-wheel-${{ github.ref_name }}-macos-*
131+
path: python/dist/
132+
merge-multiple: true
133+
- name: Publish package distributions to PyPI
134+
uses: pypa/gh-action-pypi-publish@release/v1
135+
with:
136+
packages_dir: python/dist
137+
skip_existing: true
138+
verbose: true
+29-30
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# GH actions.
22
name: Wheel-Manylinux
33

4-
54
on:
65
push:
76
tags:
8-
- '*' # Push events to every tag not containing /
7+
- '*' # Push events to every tag not containing /
98

109
jobs:
1110
Build:
@@ -19,33 +18,33 @@ jobs:
1918
name: pypi
2019
url: https://pypi.org/p/xgrammar
2120
permissions:
22-
id-token: write # IMPORTANT: mandatory for trusted publishing
21+
id-token: write # IMPORTANT: mandatory for trusted publishing
2322

2423
steps:
25-
- name: Reclaim disk space
26-
run: |
27-
df -h
28-
sudo rm -rf /usr/local/lib/android
29-
sudo rm -rf /opt/hostedtoolcache/CodeQL
30-
sudo rm -rf /usr/local/.ghcup
31-
df -h
32-
- uses: actions/checkout@v3
33-
with:
34-
submodules: 'recursive'
35-
- name: Checkout source
36-
run: |
37-
git clone https://github.com/mlc-ai/package package --recursive
38-
- name: Sync XGrammar Package
39-
run: |
40-
python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }}
41-
- name: Build XGrammar
42-
env:
43-
IMAGE: ${{ matrix.config.image }}
44-
run: |
45-
scripts/docker/bash.sh --no-gpu $IMAGE ./scripts/build_xgrammar_wheel_manylinux.sh
46-
- name: Publish package distributions to PyPI
47-
uses: pypa/gh-action-pypi-publish@release/v1
48-
with:
49-
packages_dir: python/repaired_wheels
50-
skip_existing: true
51-
verbose: true
24+
- name: Reclaim disk space
25+
run: |
26+
df -h
27+
sudo rm -rf /usr/local/lib/android
28+
sudo rm -rf /opt/hostedtoolcache/CodeQL
29+
sudo rm -rf /usr/local/.ghcup
30+
df -h
31+
- uses: actions/checkout@v3
32+
with:
33+
submodules: 'recursive'
34+
- name: Checkout source
35+
run: |
36+
git clone https://github.com/mlc-ai/package package --recursive
37+
- name: Sync XGrammar Package
38+
run: |
39+
python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }}
40+
- name: Build XGrammar
41+
env:
42+
IMAGE: ${{ matrix.config.image }}
43+
run: |
44+
scripts/docker/bash.sh --no-gpu $IMAGE ./scripts/build_xgrammar_wheel_manylinux.sh
45+
- name: Publish package distributions to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1
47+
with:
48+
packages_dir: python/repaired_wheels
49+
skip_existing: true
50+
verbose: true

0 commit comments

Comments
 (0)