This is an automated email from the ASF dual-hosted git repository.

junrushao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git


The following commit(s) were added to refs/heads/main by this push:
     new 639cc63  chore(ci): Run wheel testing per-mainline-commit (#337)
639cc63 is described below

commit 639cc63dee4321d0a01e0f1009e952bc0355daa2
Author: Junru Shao <[email protected]>
AuthorDate: Fri Dec 12 11:26:17 2025 -0800

    chore(ci): Run wheel testing per-mainline-commit (#337)
    
    Currently mainline's wheel building test is run nightly, which could be
    costly for days that don't have new commits, and inaccurate for days
    when there're multiple commits. This PR switches it to run on per-commit
    basis on mainline
---
 .github/actions/build-wheel-for-publish/action.yml | 114 +++++++++++++++++++++
 .github/workflows/ci_mainline_only.yml             |  30 ++++++
 .github/workflows/publish_wheel.yml                | 103 +++++--------------
 .gitignore                                         |   4 +
 4 files changed, 172 insertions(+), 79 deletions(-)

diff --git a/.github/actions/build-wheel-for-publish/action.yml 
b/.github/actions/build-wheel-for-publish/action.yml
new file mode 100644
index 0000000..60047f6
--- /dev/null
+++ b/.github/actions/build-wheel-for-publish/action.yml
@@ -0,0 +1,114 @@
+# 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: Build Wheel For Publish
+description: >
+  Build and test wheels (and optionally sdists) for a given 
OS/architecture/manylinux combination,
+  suitable for both validation and publish workflows.
+
+inputs:
+  os:
+    description: "Runner operating system (e.g., ubuntu-latest, macos-14, 
windows-latest)"
+    required: true
+  arch:
+    description: "Target architecture for cibuildwheel (e.g., x86_64, aarch64, 
arm64, AMD64)"
+    required: true
+  linux_image:
+    description: "Manylinux image tag to use on Linux runners (empty string 
for non-Linux runners)"
+    required: true
+  checkout_ref:
+    description: "Branch, tag, or SHA to check out before building"
+    required: true
+  build_wheels:
+    description: "Set to false to skip wheel builds (useful for sdist-only 
runs)"
+    default: "true"
+    required: false
+  build_sdist:
+    description: "Set to true to build a source distribution and run metadata 
checks"
+    default: "false"
+    required: false
+
+runs:
+  using: "composite"
+  steps:
+    # Special handling for macOS arm64 + python 3.8.
+    # Install Python 3.8 from `actions/setup-python`, which is an arm64 build.
+    - name: Install Python 3.8 for macOS arm64
+      if: runner.os == 'macOS' && inputs.arch == 'arm64'
+      uses: actions/setup-python@v5
+      with:
+        python-version: 3.8
+
+    - name: Set up uv
+      uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4  # 
v6.7.0
+
+    - name: Check out source
+      uses: actions/checkout@v5
+      with:
+        ref: ${{ inputs.checkout_ref }}
+        submodules: recursive
+        fetch-depth: 0
+        fetch-tags: true
+
+    - uses: ./.github/actions/detect-env-vars
+      id: env_vars
+
+    - name: Print current commit
+      shell: bash
+      run: git log -1 --oneline
+
+    - name: Run cpp tests
+      if: runner.os != 'Windows'
+      env:
+        CMAKE_BUILD_PARALLEL_LEVEL: ${{ steps.env_vars.outputs.cpu_count }}
+      shell: bash
+      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: ${{ runner.os == 'Windows' }}
+      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: Build wheels
+      if: ${{ inputs.build_wheels == 'true' }}
+      uses: pypa/[email protected]
+      env:
+        CIBW_ARCHS_MACOS: ${{ inputs.arch }}
+        CIBW_ARCHS_LINUX: ${{ inputs.arch }}
+        CIBW_ARCHS_WINDOWS: ${{ inputs.arch }}
+        CIBW_MANYLINUX_X86_64_IMAGE: ${{ inputs.linux_image }}
+        CIBW_MANYLINUX_AARCH64_IMAGE: ${{ inputs.linux_image }}
+        CIBW_BUILD_VERBOSITY: 1
+        CMAKE_BUILD_PARALLEL_LEVEL: ${{ steps.env_vars.outputs.cpu_count }}
+      with:
+        package-dir: .
+        output-dir: wheelhouse
+
+    - name: Build sdist
+      if: ${{ inputs.build_sdist == 'true' }}
+      shell: bash
+      run: |
+        pipx run build --sdist --outdir dist .
+        pipx run twine check dist/*
diff --git a/.github/workflows/ci_mainline_only.yml 
b/.github/workflows/ci_mainline_only.yml
index e5e24fa..c45a973 100644
--- a/.github/workflows/ci_mainline_only.yml
+++ b/.github/workflows/ci_mainline_only.yml
@@ -60,3 +60,33 @@ jobs:
               --build-dir=build-pre-commit                    \
               --jobs=${{ steps.env_vars.outputs.cpu_count }}  \
               ./src/ ./include ./tests
+
+  build-wheels:
+    name: Build wheels
+    needs: [prepare]
+    runs-on: ${{ matrix.os }}
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - {os: ubuntu-latest, arch: x86_64, linux_image: manylinux2014, 
build_sdist: "true"}
+          - {os: ubuntu-latest, arch: x86_64, linux_image: manylinux_2_28, 
build_sdist: "false"}
+          - {os: ubuntu-24.04-arm, arch: aarch64, linux_image: manylinux2014, 
build_sdist: "false"}
+          - {os: ubuntu-24.04-arm, arch: aarch64, linux_image: manylinux_2_28, 
build_sdist: "false"}
+          - {os: windows-latest, arch: AMD64, linux_image: "", build_sdist: 
"false"}
+          - {os: macos-14, arch: arm64, linux_image: "", build_sdist: "false"}
+
+    steps:
+      - name: Checkout repository (for local composite action)
+        uses: actions/checkout@v5
+        with:
+          fetch-depth: 1
+
+      - name: Build wheel
+        uses: ./.github/actions/build-wheel-for-publish
+        with:
+          os: ${{ matrix.os }}
+          arch: ${{ matrix.arch }}
+          linux_image: ${{ matrix.linux_image }}
+          checkout_ref: ${{ github.sha }}
+          build_sdist: ${{ matrix.build_sdist }}
diff --git a/.github/workflows/publish_wheel.yml 
b/.github/workflows/publish_wheel.yml
index f337834..4ee2b96 100644
--- a/.github/workflows/publish_wheel.yml
+++ b/.github/workflows/publish_wheel.yml
@@ -18,12 +18,10 @@
 name: Publish wheel
 
 on:
-  schedule:
-    - cron: '0 9 * * *'  # every day at 9am UTC
   workflow_dispatch:
     inputs:
-      branch:
-        description: "Branch or tag to publish (manual run)"
+      tag:
+        description: "Tag to publish (manual run)"
         required: true
 
 jobs:
@@ -33,94 +31,41 @@ jobs:
       fail-fast: false
       matrix:
         include:
-          - {os: ubuntu-latest, arch: x86_64, linux_image: manylinux2014}
-          - {os: ubuntu-latest, arch: x86_64, linux_image: manylinux_2_28}
-          - {os: ubuntu-24.04-arm, arch: aarch64, linux_image: manylinux2014}
-          - {os: ubuntu-24.04-arm, arch: aarch64, linux_image: manylinux_2_28}
-          - {os: windows-latest, arch: AMD64, linux_image: ""}
-          - {os: macos-14, arch: arm64, linux_image: ""}
+          - {os: ubuntu-latest, arch: x86_64, linux_image: manylinux2014, 
build_sdist: "true"}
+          - {os: ubuntu-latest, arch: x86_64, linux_image: manylinux_2_28, 
build_sdist: "false"}
+          - {os: ubuntu-24.04-arm, arch: aarch64, linux_image: manylinux2014, 
build_sdist: "false"}
+          - {os: ubuntu-24.04-arm, arch: aarch64, linux_image: manylinux_2_28, 
build_sdist: "false"}
+          - {os: windows-latest, arch: AMD64, linux_image: "", build_sdist: 
"false"}
+          - {os: macos-14, arch: arm64, linux_image: "", build_sdist: "false"}
 
     steps:
-      # Special handling for macOS arm64 + python 3.8.
-      # Install Python 3.8 from `actions/setup-python`, which is an arm64 
build;
-      # N.B. Don't use `astral-sh/setup-uv` here as it provides an x86_64 
build instead.
-      # See also: 
https://cibuildwheel.pypa.io/en/stable/faq/#macos-building-cpython-38-wheels-on-arm64
-      - uses: actions/setup-python@v5
+      - name: Checkout repository (for local composite action)
+        uses: actions/checkout@v5
         with:
-          python-version: 3.8
-        if: runner.os == 'macOS' && runner.arch == 'ARM64'
-      - uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4
-        if: matrix.os != 'macOS' || matrix.arch != 'arm64'
+          fetch-depth: 1
 
-      - uses: actions/checkout@v5
+      - name: Build wheel
+        uses: ./.github/actions/build-wheel-for-publish
         with:
-          # Use the input only for manual runs; otherwise use the triggering 
ref
-          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch 
|| github.ref }}
-          submodules: recursive
-          fetch-depth: 0
-          fetch-tags: true
-
-      - uses: ./.github/actions/detect-env-vars
-        id: env_vars
-
-      - name: Print current commit
-        run: git log -1 --oneline
-
-      - 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: Build wheels
-        uses: pypa/[email protected]
-        env:
-          CIBW_ARCHS_MACOS: ${{ matrix.arch }}
-          CIBW_ARCHS_LINUX: ${{ matrix.arch }}
-          CIBW_ARCHS_WINDOWS: ${{ matrix.arch }}
-          CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.linux_image }}
-          CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.linux_image }}
-          CIBW_BUILD_VERBOSITY: 1
-          CMAKE_BUILD_PARALLEL_LEVEL: ${{ steps.env_vars.outputs.cpu_count }}
-
-        with:
-          package-dir: .
-          output-dir: wheelhouse
-
-      - uses: actions/upload-artifact@v4
+          os: ${{ matrix.os }}
+          arch: ${{ matrix.arch }}
+          linux_image: ${{ matrix.linux_image }}
+          checkout_ref: ${{ inputs.tag }}
+          build_sdist: ${{ matrix.build_sdist }}
+      - name: Upload wheels
+        uses: actions/upload-artifact@v4
         with:
           name: cibw-wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ 
strategy.job-index }}
           path: ./wheelhouse/*.whl
-
-  build_sdist:
-    name: Build source distribution
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v5
-        with:
-          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch 
|| github.ref }}
-          submodules: recursive
-          fetch-depth: 0
-          fetch-tags: true
-
-      - uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4  # 
v6.7.0
-
-      - name: Build sdist
-        run: pipx run build --sdist --outdir dist .
-
-      - name: Check metadata
-        run: pipx run twine check dist/*
-
-      - uses: actions/upload-artifact@v4
+      - name: Upload sdist
+        if: ${{ matrix.build_sdist == 'true' }}
+        uses: actions/upload-artifact@v4
         with:
           name: cibw-sdist
           path: dist/*.tar.gz
 
   upload_pypi:
-    needs: [build_wheels, build_sdist]
+    needs: [build_wheels]
     runs-on: ubuntu-latest
     environment: pypi
     permissions:
diff --git a/.gitignore b/.gitignore
index 8f3e896..23e35b9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -118,6 +118,10 @@ __pypackages__/
 
 # Celery stuff
 celerybeat-schedule
+
+# Allow composite actions under .github/actions despite build-* ignore pattern
+!.github/actions/build-wheel-for-publish/
+!.github/actions/build-wheel-for-publish/action.yml
 celerybeat.pid
 
 # SageMath parsed files

Reply via email to