-
Notifications
You must be signed in to change notification settings - Fork 84
243 lines (225 loc) · 8.71 KB
/
Copy pathci_test.yml
File metadata and controls
243 lines (225 loc) · 8.71 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
# dev branch is used for testing purposes
- dev
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
outputs:
should_skip_ci_commit: ${{ steps.detect.outputs.should_skip_ci_commit }}
should_skip_ci_docs_only: ${{ steps.detect.outputs.should_skip_ci_docs_only }}
cpp_changed: ${{ steps.cpp_files.outputs.changed }}
cpp_files: ${{ steps.cpp_files.outputs.files }}
orcjit_changed: ${{ steps.orcjit_files.outputs.changed }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Detect skip ci and docs changes
id: detect
uses: ./.github/actions/detect-skip-ci
with:
github_event_name: ${{ github.event_name }}
pr_base_ref: ${{ github.event.pull_request.base.ref || '' }}
pr_head_sha: ${{ github.event.pull_request.head.sha || '' }}
- name: Get changed C++ files
id: cpp_files
run: |
FILES=$(git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }}...HEAD -- \
src/ tests/ | grep -E '\.(c|cc|cpp|cxx)$' | tr '\n' ' ')
echo "files=$FILES" >> $GITHUB_OUTPUT
[ -n "$FILES" ] && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT
- name: Get changed OrcJIT files
id: orcjit_files
run: |
FILES=$(git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }}...HEAD -- \
addons/tvm_ffi_orcjit/ .github/actions/build-orcjit-wheel/ | tr '\n' ' ')
echo "files=$FILES" >> $GITHUB_OUTPUT
[ -n "$FILES" ] && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT
lint:
needs: [prepare]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- name: Set up Python environment
run: uv sync --group dev --no-install-project
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
clang-tidy:
needs: [prepare]
if: needs.prepare.outputs.cpp_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: recursive
fetch-depth: 0
fetch-tags: true
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
python-version: 3.13
- uses: ./.github/actions/detect-env-vars
id: env_vars
- name: Run clang-tidy
run: |
uv run --no-project --with "clang-tidy==21.1.1" \
python tests/lint/clang_tidy_precommit.py \
--build-dir=build-pre-commit \
--jobs=${{ steps.env_vars.outputs.cpu_count }} \
${{ needs.prepare.outputs.cpp_files }}
doc:
needs: [lint, prepare]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: recursive
fetch-depth: 0
fetch-tags: true
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
python-version: 3.13
- name: Generate docs
run: |
sudo apt install doxygen
BUILD_CPP_DOCS=1 uv run --group docs sphinx-build -W --keep-going -b html docs docs/_build/html
test:
needs: [lint, prepare]
if: >
needs.prepare.outputs.should_skip_ci_commit != 'true' &&
needs.prepare.outputs.should_skip_ci_docs_only != 'true'
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- {os: ubuntu-latest, arch: x86_64, python_version: '3.14t'}
- {os: ubuntu-24.04-arm, arch: aarch64, python_version: '3.14'}
- {os: windows-latest, arch: AMD64, python_version: '3.9'}
- {os: macos-14, arch: arm64, python_version: '3.13'}
steps:
- uses: actions/checkout@v5
with:
submodules: recursive
fetch-depth: 0
fetch-tags: true
- name: Print current commit
run: git log -1 --oneline
# Detect CPU count
- uses: ./.github/actions/detect-env-vars
id: env_vars
- name: Print CPU count
run: |
echo "CPU count: ${{ steps.env_vars.outputs.cpu_count }}"
# Run C++ tests
- name: Run cpp tests
if: ${{ matrix.os != 'windows-latest' }}
env:
CMAKE_BUILD_PARALLEL_LEVEL: ${{ steps.env_vars.outputs.cpu_count }}
run: |
cmake . -B build_test -DTVM_FFI_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug
cmake --build build_test --clean-first --config Debug --target tvm_ffi_tests
ctest -V -C Debug --test-dir build_test --output-on-failure
- name: Run cpp tests[windows]
if: ${{ matrix.os == 'windows-latest' }}
shell: cmd
env:
CMAKE_BUILD_PARALLEL_LEVEL: ${{ steps.env_vars.outputs.cpu_count }}
run: >
cmake . -B build_test -DTVM_FFI_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug &&
cmake --build build_test --clean-first --config Debug --target tvm_ffi_tests &&
ctest -V -C Debug --test-dir build_test --output-on-failure
- name: Locate and Set VsDevCmd Path [windows]
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
# Captures the output (path) from your Python script
$vsPath = python .github/workflows/utils/locate_vsdevcmd_bat.py
# Sets an environment variable for all subsequent steps in this job
"VS_DEV_CMD_PATH=$vsPath" | Out-File -FilePath $env:GITHUB_ENV -Append
# Run Python tests
- name: Setup Python ${{ matrix.python_version }}
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
python-version: ${{ matrix.python_version }}
activate-environment: true
- name: Build and install python package
env:
CMAKE_BUILD_PARALLEL_LEVEL: ${{ steps.env_vars.outputs.cpu_count }}
run: |
uv pip install --reinstall --verbose --group test -e .
- name: Run python tests
if: ${{ matrix.os != 'windows-latest' }}
run: |
pytest -vvs tests/python
- name: Run python tests [windows]
if: ${{ matrix.os == 'windows-latest' }}
shell: cmd
run: |
call "%VS_DEV_CMD_PATH%"
pytest -vvs tests/python
# Run Rust tests, must happen after installing the pip package.
- name: Run rust tests
working-directory: rust
run: |
cargo test
orcjit:
needs: [lint, prepare]
if: >
needs.prepare.outputs.orcjit_changed == 'true' &&
needs.prepare.outputs.should_skip_ci_commit != 'true' &&
needs.prepare.outputs.should_skip_ci_docs_only != 'true'
name: orcjit ${{ matrix.os }} (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {os: ubuntu-latest, arch: x86_64, build: "cp312-manylinux_x86_64"}
- {os: ubuntu-24.04-arm, arch: aarch64, build: "cp312-manylinux_aarch64"}
- {os: macos-14, arch: arm64, build: "cp312-macosx_arm64"}
- {os: windows-latest, arch: AMD64, build: "cp312-win_amd64"}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 1
- name: Build OrcJIT wheel
uses: ./.github/actions/build-orcjit-wheel
with:
arch: ${{ matrix.arch }}
build: ${{ matrix.build }}
checkout_ref: ${{ github.sha }}
- uses: actions/upload-artifact@v4
with:
name: cibw-orcjit-wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ strategy.job-index }}
path: wheelhouse/*.whl