|
| 1 | +name: 'MindSpore Unit Tests' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + workflow_dispatch: |
| 6 | + workflow_run: |
| 7 | + workflows: ["Code Quality"] |
| 8 | + types: [completed] |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + statuses: write |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + test-mindspore: |
| 20 | + name: Unit Tests on Ascend with MindSpore |
| 21 | + runs-on: [self-hosted, Linux, ARM64, 910b4] |
| 22 | + timeout-minutes: 30 |
| 23 | + |
| 24 | + environment: |
| 25 | + name: 910b-hardware |
| 26 | + |
| 27 | + if: > |
| 28 | + github.event_name != 'workflow_run' || |
| 29 | + github.event.workflow_run.conclusion == 'success' |
| 30 | +
|
| 31 | + container: |
| 32 | + image: hub.oepkgs.net/oedeploy/openeuler/aarch64/intelligence_boom:0.2.0-aarch64-800I-A2-mindspore2.7.1.post1-openeuler24.03-lts-sp2-20260116 |
| 33 | + env: |
| 34 | + SOC_VERSION: Ascend910B3 |
| 35 | + USE_MINDSPORE: 1 |
| 36 | + PIP_INDEX_URL: https://mirrors.aliyun.com/pypi/simple |
| 37 | + PIP_NO_CACHE_DIR: 1 |
| 38 | + LMCACHE_TRACK_USAGE: false |
| 39 | + NO_CUDA_EXT: 1 |
| 40 | + NODE_EXTRA_CA_CERTS: /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem |
| 41 | + LMCACHE_LOG_LEVEL: INFO |
| 42 | + PYTHONHASHSEED: 0 |
| 43 | + |
| 44 | + options: >- |
| 45 | + --label owner=ci-test-runner |
| 46 | + --add-host=host.docker.internal:192.168.1.1 |
| 47 | + --device /dev/davinci0 |
| 48 | + --device /dev/davinci1 |
| 49 | + --device /dev/davinci_manager |
| 50 | + --device /dev/devmm_svm |
| 51 | + --device /dev/hisi_hdc |
| 52 | + -v /usr/local/Ascend/driver:/usr/local/Ascend/driver:ro |
| 53 | + -v /usr/local/dcmi:/usr/local/dcmi:ro |
| 54 | + -v /etc/pki/ca-trust:/etc/pki/ca-trust:ro |
| 55 | + -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi:ro |
| 56 | + --user root |
| 57 | + --cap-add=SYS_PTRACE |
| 58 | +
|
| 59 | + |
| 60 | + steps: |
| 61 | + - name: 🔧 Fix Proxy Configuration |
| 62 | + run: | |
| 63 | + echo "Overwriting Runner Proxy Settings..." |
| 64 | + echo "http_proxy=http://host.docker.internal:3128" >> $GITHUB_ENV |
| 65 | + echo "https_proxy=http://host.docker.internal:3128" >> $GITHUB_ENV |
| 66 | + echo "HTTP_PROXY=http://host.docker.internal:3128" >> $GITHUB_ENV |
| 67 | + echo "HTTPS_PROXY=http://host.docker.internal:3128" >> $GITHUB_ENV |
| 68 | +
|
| 69 | + - name: Checkout (Workflow Run) |
| 70 | + if: github.event_name == 'workflow_run' |
| 71 | + uses: actions/checkout@v4 |
| 72 | + with: |
| 73 | + repository: ${{ github.event.workflow_run.head_repository.full_name }} |
| 74 | + ref: ${{ github.event.workflow_run.head_sha }} |
| 75 | + fetch-depth: 0 |
| 76 | + submodules: true |
| 77 | + |
| 78 | + - name: Checkout (Dispatch or Call) |
| 79 | + if: github.event_name != 'workflow_run' |
| 80 | + uses: actions/checkout@v4 |
| 81 | + with: |
| 82 | + fetch-depth: 0 |
| 83 | + submodules: true |
| 84 | + |
| 85 | + - name: 🟡 Set Status to Running |
| 86 | + uses: actions/github-script@v7 |
| 87 | + with: |
| 88 | + script: | |
| 89 | + const { owner, repo } = context.repo; |
| 90 | + |
| 91 | + const sha = (context.payload.workflow_run && context.payload.workflow_run.head_sha) || |
| 92 | + (context.payload.pull_request && context.payload.pull_request.head.sha) || |
| 93 | + context.sha; |
| 94 | +
|
| 95 | + const target_url = `https://github.com/${owner}/${repo}/actions/runs/${context.runId}`; |
| 96 | + |
| 97 | + await github.rest.repos.createCommitStatus({ |
| 98 | + owner, |
| 99 | + repo, |
| 100 | + sha, |
| 101 | + state: 'pending', |
| 102 | + description: 'Running MindSpore tests... (Click Details to watch)', |
| 103 | + context: 'MindSpore Unit Tests Status', |
| 104 | + target_url: target_url |
| 105 | + }); |
| 106 | +
|
| 107 | + - name: 🔧 Fix Git Safe Directory |
| 108 | + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" |
| 109 | + |
| 110 | + - name: 📦 Install System Dependencies |
| 111 | + run: | |
| 112 | + echo ">>> Installing System Dependencies..." |
| 113 | + yum install -y numactl-devel |
| 114 | +
|
| 115 | + - name: 📦 Install LMCache & Build Project with MindSpore |
| 116 | + run: | |
| 117 | + |
| 118 | + echo ">>> Installing LMCache Core..." |
| 119 | + pip install lmcache==0.3.7 --no-deps |
| 120 | +
|
| 121 | + echo ">>> Building LMCache-Ascend with MindSpore..." |
| 122 | + export CPLUS_INCLUDE_PATH=/usr/include/c++/12:/usr/include/c++/12/backward:/usr/include/c++/12/`uname -i`-openEuler-linux/:$CPLUS_INCLUDE_PATH |
| 123 | + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/Ascend/ascend-toolkit/latest/$(uname -i)-linux/devlib |
| 124 | + |
| 125 | + # Install in editable mode (-e) for testing with MindSpore support |
| 126 | + pip install --no-build-isolation -v -r requirement_ms.txt -e . |
| 127 | + |
| 128 | + - name: Install Pytest Dependencies |
| 129 | + run: | |
| 130 | + pip install pytest pytest-benchmark pytest-cov |
| 131 | + |
| 132 | + - name: 🧪 Run MindSpore Unit Tests |
| 133 | + id: test-step |
| 134 | + shell: bash |
| 135 | + run: | |
| 136 | + # 1. Setup Env |
| 137 | + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/Ascend/ascend-toolkit/latest/$(uname -i)-linux/devlib |
| 138 | + |
| 139 | + # 2. Disable Exit on Error (Manual Handling) |
| 140 | + set +e |
| 141 | + |
| 142 | + echo ">>> Starting Pytest for MindSpore..." |
| 143 | + echo " - Console: Errors Only (Clean)" |
| 144 | + echo " - File: Debug Logs (Verbose)" |
| 145 | + |
| 146 | + # 3. RUN PYTEST |
| 147 | + # -W ignore:... : Suppress console spam from asyncio cleanup |
| 148 | + # --log-cli-level=CRITICAL : Keep Console Quiet (Only real errors) |
| 149 | + # --log-file=debug_logs.txt : Save Logs to File |
| 150 | + python3 -u -m pytest -v tests/mindspore/v1 \ |
| 151 | + -W "ignore:coroutine 'AsyncPQThreadPoolExecutor._worker' was never awaited" \ |
| 152 | + -W "ignore:coroutine 'AsyncPQExecutor._worker' was never awaited" \ |
| 153 | + -W "ignore:Task was destroyed but it is pending!" \ |
| 154 | + -W "ignore:Exception ignored in" \ |
| 155 | + --tb=short \ |
| 156 | + --junit-xml=test-results.xml \ |
| 157 | + --log-cli-level=CRITICAL \ |
| 158 | + --log-file=debug_logs.txt \ |
| 159 | + --log-file-level=INFO |
| 160 | + |
| 161 | + # Capture Exit Code |
| 162 | + EXIT_CODE=$? |
| 163 | + |
| 164 | + # 4. Re-enable Exit on Error |
| 165 | + set -e |
| 166 | + |
| 167 | + echo "" |
| 168 | + echo "============= TEST SUMMARY =============" |
| 169 | + echo "Final Exit Code: $EXIT_CODE" |
| 170 | + |
| 171 | + # 5. Fail if needed |
| 172 | + if [ $EXIT_CODE -ne 0 ]; then |
| 173 | + echo "❌ Tests Failed." |
| 174 | + exit $EXIT_CODE |
| 175 | + else |
| 176 | + echo "✅ Tests Passed." |
| 177 | + exit 0 |
| 178 | + fi |
| 179 | +
|
| 180 | + - name: 🧾 Publish Test Summary |
| 181 | + if: always() |
| 182 | + uses: ./.github/actions/junit-summary |
| 183 | + with: |
| 184 | + junit-path: test-results.xml |
| 185 | + |
| 186 | + # 📤 ARTIFACT 1: The Verbose Logs (For Debugging) |
| 187 | + - name: 📤 Upload Debug Logs |
| 188 | + if: always() |
| 189 | + uses: actions/upload-artifact@v4 |
| 190 | + with: |
| 191 | + name: debug-logs-mindspore |
| 192 | + path: debug_logs.txt |
| 193 | + |
| 194 | + # 📤 ARTIFACT 2: The XML Summary (For Tools) |
| 195 | + - name: 📤 Upload Test Results XML |
| 196 | + if: always() |
| 197 | + uses: actions/upload-artifact@v4 |
| 198 | + with: |
| 199 | + name: test-results-xml-${{ github.job }}-${{ strategy.job-index || 0}} |
| 200 | + path: test-results.xml |
| 201 | + |
| 202 | + - name: 🟢🔴 Update MindSpore Test Status |
| 203 | + if: always() |
| 204 | + uses: actions/github-script@v7 |
| 205 | + with: |
| 206 | + script: | |
| 207 | + const { owner, repo } = context.repo; |
| 208 | + const sha = (context.payload.workflow_run && context.payload.workflow_run.head_sha) || |
| 209 | + (context.payload.pull_request && context.payload.pull_request.head.sha) || |
| 210 | + context.sha; |
| 211 | + const state = '${{ job.status }}' === 'success' ? 'success' : 'failure'; |
| 212 | + const target_url = `https://github.com/${owner}/${repo}/actions/runs/${context.runId}`; |
| 213 | + await github.rest.repos.createCommitStatus({ |
| 214 | + owner, |
| 215 | + repo, |
| 216 | + sha, |
| 217 | + state: state, |
| 218 | + target_url: target_url, |
| 219 | + description: state === 'success' ? 'Tests Passed' : 'Tests Failed', |
| 220 | + context: 'MindSpore Unit Tests Status' |
| 221 | + }); |
0 commit comments