docs: Update projects #4
This file contains hidden or 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
| # SPDX-FileCopyrightText: 2026 The RISE Project | |
| # SPDX-License-Identifier: MIT | |
| --- | |
| # This workflow is based on: https://gitlab.arm.com/tosa/tosa-tools/-/blob/v2026.08.0/ci/templates/python_wheels.yml | |
| name: Build tosa-tools wheels (riscv64) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version glob to (re)build; empty builds every version of docs/packages/tosa-tools.yaml not released yet' | |
| required: false | |
| default: '' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - '.github/workflows/build-tosa-tools.yml' | |
| - 'docs/packages/tosa-tools.yaml' | |
| push: | |
| branches: [main] | |
| paths: | |
| - '.github/workflows/build-tosa-tools.yml' | |
| - 'docs/packages/tosa-tools.yaml' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 | |
| jobs: | |
| setup: | |
| uses: $/.github/workflows/_setup.yml | |
| with: | |
| package: tosa-tools | |
| version: ${{ inputs.version }} | |
| build_wheels: | |
| needs: [setup] | |
| if: needs.setup.outputs.versions != '[]' | |
| name: Build tosa-tools ${{ matrix.version }} manylinux_riscv64 | |
| runs-on: ubuntu-24.04-riscv | |
| timeout-minutes: 1440 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: ${{ fromJSON(needs.setup.outputs.versions) }} | |
| env: | |
| TOSA_TOOLS_VERSION: ${{ matrix.version }} | |
| steps: | |
| # Upstream zero-pads the month in its tags (v2026.08.0), not in the wheel version. | |
| - id: tag | |
| run: | | |
| IFS=. read -r year month patch <<< "${TOSA_TOOLS_VERSION}" | |
| printf 'ref=v%s.%02d.%s\n' "${year}" "${month}" "${patch}" >> "$GITHUB_OUTPUT" | |
| - name: Checkout tosa-tools ${{ steps.tag.outputs.ref }} | |
| run: | | |
| git clone --depth 1 --branch "${{ steps.tag.outputs.ref }}" https://gitlab.arm.com/tosa/tosa-tools.git tosa-tools | |
| echo "LLVM_COMMIT=$(sed -n 's/^ *value: "\([0-9a-f]*\)".*/\1/p' tosa-tools/ci/vars/llvm-sha.yml)" >> "$GITHUB_ENV" | |
| # The wheel links LLVM/MLIR, FlatBuffers, googletest, pybind11, nlohmann/json, cxxopts | |
| # and musl-derived libm code; upstream's wheel ships none of their notices. | |
| - name: Stage the bundled dependencies' licences | |
| working-directory: tosa-tools | |
| run: | | |
| set -euo pipefail | |
| curl -fsSL --retry 5 "https://raw.githubusercontent.com/llvm/llvm-project/${LLVM_COMMIT}/mlir/LICENSE.TXT" -o LICENSE.llvm | |
| curl -fsSL --retry 5 https://raw.githubusercontent.com/google/flatbuffers/v25.2.10/LICENSE -o LICENSE.flatbuffers | |
| curl -fsSL --retry 5 https://raw.githubusercontent.com/google/googletest/v1.14.0/LICENSE -o LICENSE.googletest | |
| curl -fsSL --retry 5 https://raw.githubusercontent.com/pybind/pybind11/v3.0.4/LICENSE -o LICENSE.pybind11 | |
| curl -fsSL --retry 5 https://raw.githubusercontent.com/nlohmann/json/v3.11.3/LICENSE.MIT -o LICENSE.nlohmann-json | |
| curl -fsSL --retry 5 https://raw.githubusercontent.com/jarro2783/cxxopts/v3.3.1/LICENSE -o LICENSE.cxxopts | |
| cp reference_model/reference_model/src/ops/math/COPYRIGHT LICENSE.musl | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 | |
| with: | |
| package-dir: tosa-tools | |
| output-dir: wheelhouse | |
| env: | |
| CIBW_BUILD: cp312-manylinux_riscv64 cp313-manylinux_riscv64 cp314-manylinux_riscv64 | |
| CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} | |
| CIBW_ENVIRONMENT_PASS_LINUX: LLVM_COMMIT | |
| # Upstream's cmdflow.py builds all of LLVM/MLIR for every backend. Build only the | |
| # libraries tosa-opt links (its CMake LIBS, closed over their link interfaces), for | |
| # the host backend, to fit the riscv64 runner; no zstd, as upstream's tosa-opt has none. | |
| CIBW_BEFORE_ALL_LINUX: | | |
| set -euxo pipefail | |
| manylinux-install-clang -v v22.1.6.0 | |
| rm -rf /var/cache/dnf /project/llvm-project | |
| curl -fL --retry 5 --retry-all-errors --retry-delay 10 -o /tmp/llvm.tar.gz "https://codeload.github.com/llvm/llvm-project/tar.gz/${LLVM_COMMIT}" | |
| tar -xzf /tmp/llvm.tar.gz -C /project | |
| rm /tmp/llvm.tar.gz | |
| mv /project/llvm-project-* /project/llvm-project | |
| cd /project/llvm-project | |
| cmake -S llvm -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release \ | |
| -DLLVM_APPEND_VC_REV=OFF -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_ENABLE_ASSERTIONS=ON \ | |
| -DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_ZSTD=OFF | |
| targets="$(/opt/python/cp312-cp312/bin/python - MLIRParser MLIRSupport MLIRIR MLIROptLib MLIRPass MLIRTosaDialect MLIRTosaTransforms MLIRFuncDialect <<'EOF' | |
| import re, sys | |
| text = open("build/lib/cmake/llvm/LLVMExports.cmake").read() + open("build/lib/cmake/mlir/MLIRTargets.cmake").read() | |
| kind = dict(re.findall(r"^add_library\((\S+) (\S+) IMPORTED\)", text, re.M)) | |
| deps = dict(re.findall(r'set_target_properties\((\S+) PROPERTIES\n INTERFACE_LINK_LIBRARIES "([^"]*)"', text)) | |
| todo, seen = sys.argv[1:], set() | |
| while todo: | |
| name = todo.pop() | |
| if name in kind and name not in seen: | |
| seen.add(name) | |
| todo += re.findall(r"[\w-]+", deps.get(name, "")) | |
| print(" ".join(sorted(n for n in seen if kind[n] != "INTERFACE"))) | |
| EOF | |
| )" | |
| cmake --build build -j "$(nproc)" --target mlir-headers mlir-tblgen ${targets} | |
| CIBW_CONFIG_SETTINGS: >- | |
| cmake.define.TOSA_ENABLE_PROJECTS=serialization,reference_model,mlir_translator | |
| cmake.define.MLIR_TOSA_OPT=ON | |
| cmake.define.MLIR_DIR=/project/llvm-project/build/lib/cmake/mlir | |
| cmake.define.LLVM_DIR=/project/llvm-project/build/lib/cmake/llvm | |
| CIBW_ENVIRONMENT: >- | |
| SETUPTOOLS_SCM_PRETEND_VERSION_FOR_TOSA_TOOLS=${{ env.TOSA_TOOLS_VERSION }} | |
| SKBUILD_WHEEL_LICENSE_FILES="LICENSES/Apache-2.0.txt;LICENSE.*" | |
| PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ | |
| CIBW_TEST_COMMAND: 'python -c "import tosa_reference_model, tosa_serializer; print(tosa_reference_model.__file__); print(tosa_serializer.__file__)"' | |
| - name: Check wheel contents | |
| run: | | |
| python3 - wheelhouse/*.whl <<'EOF' | |
| import sys, zipfile | |
| assert len(sys.argv) == 4, sys.argv | |
| for whl in sys.argv[1:]: | |
| names = zipfile.ZipFile(whl).namelist() | |
| for tool in ("tosa-opt", "tosa_reference_model", "tosa_verify", "flatc"): | |
| assert f"bin/{tool}" in names, (whl, tool) | |
| licences = {n.split(".dist-info/licenses/", 1)[1] for n in names | |
| if ".dist-info/licenses/" in n and not n.endswith("/")} | |
| assert licences == {"LICENSES/Apache-2.0.txt", "LICENSE.cxxopts", "LICENSE.flatbuffers", | |
| "LICENSE.googletest", "LICENSE.llvm", "LICENSE.musl", | |
| "LICENSE.nlohmann-json", "LICENSE.pybind11"}, (whl, licences) | |
| EOF | |
| - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: tosa-tools-${{ env.TOSA_TOOLS_VERSION }}-cibw-wheels-manylinux_riscv64 | |
| path: wheelhouse/*.whl | |
| if-no-files-found: error | |
| test_wheels: | |
| needs: [setup, build_wheels] | |
| if: needs.setup.outputs.versions != '[]' | |
| name: Test tosa-tools ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 | |
| runs-on: ubuntu-24.04-riscv | |
| timeout-minutes: 120 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: ${{ fromJSON(needs.setup.outputs.versions) }} | |
| python: ["3.12", "3.13", "3.14"] | |
| env: | |
| TOSA_TOOLS_VERSION: ${{ matrix.version }} | |
| PIP_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/ | |
| steps: | |
| - id: tag | |
| run: | | |
| IFS=. read -r year month patch <<< "${TOSA_TOOLS_VERSION}" | |
| printf 'ref=v%s.%02d.%s\n' "${year}" "${month}" "${patch}" >> "$GITHUB_OUTPUT" | |
| - name: Checkout tosa-tools ${{ steps.tag.outputs.ref }} | |
| run: git clone --depth 1 --branch "${{ steps.tag.outputs.ref }}" https://gitlab.arm.com/tosa/tosa-tools.git tosa-tools | |
| - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: tosa-tools-${{ env.TOSA_TOOLS_VERSION }}-cibw-wheels-manylinux_riscv64 | |
| path: wheelhouse | |
| - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| activate-environment: true | |
| enable-cache: false | |
| - name: Out-of-box test | |
| run: | | |
| python tosa-tools/ci/python/tools/python_wheels_oobt.py \ | |
| --version "${TOSA_TOOLS_VERSION}" \ | |
| --wheel-dir wheelhouse \ | |
| --python-version "${{ matrix.python }}" \ | |
| --platform-label linux-riscv64 \ | |
| --output-dir oobt-results | |
| # oobt-results has thousands of small files, which upload-artifact can crash on | |
| # (source.copy is not a function); this artifact is diagnostic-only and nothing | |
| # downstream depends on it, so don't fail the job over it. | |
| - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| if: always() | |
| continue-on-error: true | |
| with: | |
| name: tosa-tools-${{ env.TOSA_TOOLS_VERSION }}-${{ matrix.python }}-oobt-results | |
| path: oobt-results | |
| if-no-files-found: ignore | |
| publish: | |
| name: Publish tosa-tools ${{ matrix.version }} | |
| needs: [setup, build_wheels, test_wheels] | |
| if: needs.setup.outputs.versions != '[]' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: ${{ fromJSON(needs.setup.outputs.versions) }} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| uses: $/.github/workflows/_publish-wheel.yml | |
| secrets: | |
| app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} | |
| with: | |
| artifact-pattern: tosa-tools-${{ matrix.version }}-*-manylinux_riscv64 |