@@ -13,64 +13,121 @@ permissions:
1313
1414jobs :
1515 wheel :
16- runs-on : ubuntu-22.04
16+ name : Build (${{ matrix.arch }}, py${{ matrix.python }})
17+ timeout-minutes : 360
18+ continue-on-error : ${{ matrix.experimental }}
19+
20+ concurrency :
21+ group : buddy-mlir-manylinux-${{ matrix.arch }}-py${{ matrix.python }}
22+ cancel-in-progress : true
23+
1724 strategy :
1825 fail-fast : false
1926 matrix :
27+ arch : [x64, riscv64]
2028 python : ["3.10", "3.11", "3.12", "3.13"]
21- torch_version : ["2.8"] # placeholder; not used in build, keeps matrix extensible
29+ include :
30+ - arch : x64
31+ target_arch : x86_64
32+ experimental : false
33+ - arch : riscv64
34+ target_arch : riscv64
35+ experimental : true
36+
37+ runs-on :
38+ - self-hosted
39+ - ${{ matrix.arch }}
40+
2241 steps :
23- - name : Checkout
42+ - name : Checkout repository (x64)
43+ if : matrix.arch == 'x64'
2444 uses : actions/checkout@v4
2545 with :
26- submodules : true
46+ submodules : false
47+
48+ - name : Checkout from local Gitea (riscv64)
49+ if : matrix.arch == 'riscv64'
50+ run : |
51+ # Self-hosted workspaces are dirty; reset remotes and force the exact GitHub SHA.
52+ git remote remove origin || true
53+ git remote remove github || true
54+ git remote add origin https://community-ci.openruyi.cn/RuyiAI-Stack/buddy-mlir
55+ git remote add github https://github.com/buddy-compiler/buddy-mlir.git
56+ git fetch --depth=1 origin
57+ git fetch github ${{ github.sha }}
58+ git checkout --force ${{ github.sha }}
59+ git clean -fdx
2760
28- - name : Record LLVM submodule commit
29- id : llvm_rev
30- run : echo "sha=$(git -C llvm rev-parse HEAD)" >> "$GITHUB_OUTPUT"
61+ - name : Prepare variables
62+ id : vars
63+ run : |
64+ set -euo pipefail
65+ PY_VER="${{ matrix.python }}"
66+ PY_NODOT="${PY_VER//./}"
67+ PY_TAG="cp${PY_NODOT}-cp${PY_NODOT}"
68+ echo "py_tag=${PY_TAG}" >> "$GITHUB_OUTPUT"
69+ echo "llvm_sha=$(git rev-parse HEAD:llvm)" >> "$GITHUB_OUTPUT"
3170
3271 - name : Cache LLVM build tree
3372 id : cache-llvm-build
3473 uses : actions/cache@v4
3574 with :
36- path : llvm/build.docker
37- key : llvm-${{ runner.os }}-${{ matrix.python }}-${{ steps.llvm_rev.outputs.sha }}
75+ path : llvm/build-docker/${{ matrix.target_arch }}/${{ steps.vars.outputs.py_tag }}
76+ key : llvm-${{ runner.os }}-${{ matrix.target_arch }}-${{ matrix.python }}-${{ steps.vars.outputs.llvm_sha }}
77+
78+ - name : Prepare LLVM source
79+ id : llvm
80+ run : |
81+ set -euo pipefail
82+ LLVM_BUILD_DIR="llvm/build-docker/${{ matrix.target_arch }}/${{ steps.vars.outputs.py_tag }}"
83+ if [ "${{ steps.cache-llvm-build.outputs.cache-hit }}" = "true" ] && \
84+ [ -f "${LLVM_BUILD_DIR}/.manylinux-llvm-ready" ]; then
85+ echo "cache_hit=true" >> "$GITHUB_OUTPUT"
86+ else
87+ rm -rf "${LLVM_BUILD_DIR}"
88+ git submodule update --init --recursive llvm
89+ echo "cache_hit=false" >> "$GITHUB_OUTPUT"
90+ fi
91+
92+ - name : Clean package output
93+ run : |
94+ set -euo pipefail
95+ # Keep the cached LLVM install tree; only clear the previous buddy outputs.
96+ rm -rf "build-docker/${{ matrix.target_arch }}/${{ steps.vars.outputs.py_tag }}/dist"
97+ rm -rf "build-docker/${{ matrix.target_arch }}/${{ steps.vars.outputs.py_tag }}/target"
3898
3999 - name : Build manylinux wheel in container
40100 run : |
41101 set -euo pipefail
42- PY_VER="${{ matrix.python }}"
43- PY_NODOT="${PY_VER//./}"
44- PY_TAG="cp${PY_NODOT}-cp${PY_NODOT}"
45- export TORCH_VERSION="${{ matrix.torch_version }}"
46- export LLVM_CACHE_HIT="${{ steps.cache-llvm-build.outputs.cache-hit }}"
47- ./scripts/release_wheel_manylinux.sh "${PY_TAG}"
102+ export LLVM_CACHE_HIT="${{ steps.llvm.outputs.cache_hit }}"
103+ ./scripts/release_wheel_manylinux.sh "${{ steps.vars.outputs.py_tag }}" "${{ matrix.target_arch }}"
48104
49- - name : Upload wheels
105+ - name : Upload build artifacts
50106 uses : actions/upload-artifact@v4
51107 with :
52- name : wheels-py${{ matrix.python }}-torch${{ matrix.torch_version }}
53- path : build.docker/dist/*.whl
108+ name : wheels-${{ matrix.target_arch }}-py${{ matrix.python }}
109+ path : |
110+ build-docker/${{ matrix.target_arch }}/${{ steps.vars.outputs.py_tag }}/target/*manylinux*.whl
111+ build-docker/${{ matrix.target_arch }}/${{ steps.vars.outputs.py_tag }}/target/*.tar.gz
54112
55113 release :
56114 needs : wheel
57115 runs-on : ubuntu-22.04
58116 steps :
59- - name : Checkout
60- uses : actions/checkout@v4
61-
62117 - name : Download wheels
63118 uses : actions/download-artifact@v4
64119 with :
65120 pattern : wheels-*
66- path : dist
121+ path : dist/wheels
67122 merge-multiple : true
68123
69124 - name : Upload assets
70125 uses : softprops/action-gh-release@v2
71126 with :
72127 tag_name : ${{ inputs.version }}
73128 overwrite_files : true
74- files : dist/*manylinux*.whl
129+ files : |
130+ dist/wheels/*manylinux*.whl
131+ dist/wheels/*.tar.gz
75132 env :
76133 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments