|
| 1 | +name: CD-Ascend-triton_v3.2.x |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + WHL_VER: |
| 10 | + description: '0.5.0.dev1 < 0.5.0a1 < 0.5.0b1 < 0.5.0rc1 < 0.5.0 < 0.5.0.post1' |
| 11 | + required: true |
| 12 | + default: '0.5.0' |
| 13 | + PYTHON_VER: |
| 14 | + required: true |
| 15 | + default: '3.11' |
| 16 | + PLATFORM: |
| 17 | + required: true |
| 18 | + default: 'aarch64' |
| 19 | + workflow_call: |
| 20 | + inputs: |
| 21 | + WHL_VER: |
| 22 | + type: string |
| 23 | + required: true |
| 24 | + default: '0.5.0' |
| 25 | + PYTHON_VER: |
| 26 | + type: string |
| 27 | + required: true |
| 28 | + default: '3.11' |
| 29 | + PLATFORM: |
| 30 | + type: string |
| 31 | + required: true |
| 32 | + default: 'aarch64' |
| 33 | + |
| 34 | +concurrency: |
| 35 | + group: ${{ github.workflow }}-${{ inputs.WHL_VER }}-${{ inputs.PYTHON_VER }}-${{ inputs.PLATFORM }} |
| 36 | + cancel-in-progress: true |
| 37 | + |
| 38 | +jobs: |
| 39 | + ascend-cd: |
| 40 | + runs-on: ascend-cd |
| 41 | + if: ${{ github.repository == 'FlagTree/flagtree' || github.repository == 'flagos-ai/flagtree' }} |
| 42 | + steps: |
| 43 | + - name: Check branch |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + TARGET_BRANCH="${{ github.ref_name }}" |
| 47 | + if [[ ! "$TARGET_BRANCH" =~ ^(triton_v3\.2\.x)$ ]]; then |
| 48 | + echo "❌ This workflow must be run from branch 'triton_v3.2.x', but got '${TARGET_BRANCH}'" |
| 49 | + exit 1 |
| 50 | + fi |
| 51 | + echo "TARGET_BRANCH=$TARGET_BRANCH" >> $GITHUB_ENV |
| 52 | + echo "✅ Branch check passed: ${TARGET_BRANCH}" |
| 53 | +
|
| 54 | + - name: Setup environment |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + source ~/env.sh |
| 58 | + env | grep -E '^(http_proxy|https_proxy|all_proxy|no_proxy)=' >> $GITHUB_ENV || true |
| 59 | +
|
| 60 | + - name: Smart Checkout |
| 61 | + uses: flagos-ai/FlagTree/.github/actions/smart-checkout@main |
| 62 | + with: |
| 63 | + checkout_version: 'v6' |
| 64 | + |
| 65 | + - name: FlagTree bdist_wheel on Ascend (triton_v3.2.x branch) |
| 66 | + if: ${{ env.TARGET_BRANCH == 'triton_v3.2.x' }} |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + set -x |
| 70 | + TRITON_VER="3.2" |
| 71 | + CHIP="" |
| 72 | + export FLAGTREE_BACKEND=ascend |
| 73 | + WHL_VER=${{ inputs.WHL_VER }} |
| 74 | + PYTHON_VER=${{ inputs.PYTHON_VER }} |
| 75 | + export FLAGTREE_WHEEL_VERSION="${WHL_VER}+${CHIP}${FLAGTREE_BACKEND}${TRITON_VER}" |
| 76 | +
|
| 77 | + RES="--index-url=https://resource.flagos.net/repository/flagos-pypi-hosted/simple --trusted-host=https://resource.flagos.net" |
| 78 | + if python${PYTHON_VER} -m pip download --no-deps "flagtree==${FLAGTREE_WHEEL_VERSION}" -d . $RES >/dev/null 2>&1; then |
| 79 | + echo "❌ flagtree==${FLAGTREE_WHEEL_VERSION} already exists!" |
| 80 | + exit 1 |
| 81 | + else |
| 82 | + echo "✅ flagtree==${FLAGTREE_WHEEL_VERSION} does not exist, proceed to build" |
| 83 | + fi |
| 84 | +
|
| 85 | + cd python |
| 86 | + rm -rf ./build ./*.egg-info |
| 87 | + MAX_JOBS=32 python${PYTHON_VER} setup.py bdist_wheel -d ~/dist-flagtree |
| 88 | + env | grep -E '^(FLAGTREE_WHEEL_VERSION)=' >> $GITHUB_ENV || true |
| 89 | +
|
| 90 | + - name: FlagTree upload whl |
| 91 | + shell: bash |
| 92 | + run: | |
| 93 | + set -x |
| 94 | + PLATFORM=${{ inputs.PLATFORM }} |
| 95 | + PYTHON_VER=${{ inputs.PYTHON_VER }} |
| 96 | + CP_VER=$(printf '%s' "$PYTHON_VER" | tr -d '.') |
| 97 | + FLAGTREE_WHL="flagtree-${FLAGTREE_WHEEL_VERSION}-cp${CP_VER}-cp${CP_VER}-linux_${PLATFORM}.whl" |
| 98 | + pushd ~/dist-flagtree |
| 99 | + twine check ${FLAGTREE_WHL} |
| 100 | + echo "Upload ${FLAGTREE_WHL}" |
| 101 | + bash upload_flagtree_whl.sh "${FLAGTREE_WHL}" |
| 102 | + popd |
| 103 | +
|
| 104 | + - name: FlagTree push tag |
| 105 | + shell: bash |
| 106 | + env: |
| 107 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 108 | + run: | |
| 109 | + set -x |
| 110 | + git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git |
| 111 | + TAG="${FLAGTREE_WHEEL_VERSION}" |
| 112 | + git config user.name "flagtree-bot" |
| 113 | + git config user.email "flagtree_ai@163.com" |
| 114 | + if git rev-parse "${TAG}" >/dev/null 2>&1; then |
| 115 | + echo "⚠️ Tag '${TAG}' already exists, force moving to current commit" |
| 116 | + git tag -f -a "${TAG}" -m "pypi ${TAG}" |
| 117 | + else |
| 118 | + git tag -a "${TAG}" -m "pypi ${TAG}" |
| 119 | + fi |
| 120 | + MAX_RETRY=100 |
| 121 | + RETRY_INTERVAL=10 |
| 122 | + success=false |
| 123 | + for i in $(seq 1 $MAX_RETRY); do |
| 124 | + echo "Attempt ${i}/${MAX_RETRY}:" |
| 125 | + if git push --force origin "${TAG}"; then |
| 126 | + success=true |
| 127 | + break |
| 128 | + fi |
| 129 | + echo "Push failed, retrying in ${RETRY_INTERVAL}s..." |
| 130 | + sleep $RETRY_INTERVAL |
| 131 | + done |
| 132 | + if [ "$success" != "true" ]; then |
| 133 | + echo "git push failed after $MAX_RETRY attempts" |
| 134 | + exit 1 |
| 135 | + fi |
0 commit comments