@@ -131,9 +131,33 @@ jobs:
131131 fi
132132 echo "PATH=$PATH" >> $GITHUB_ENV
133133 echo "Python: $(which python3) ($(python3 --version 2>&1))"
134+
135+ - name : Environment Setup Cuda-specific
136+ if : steps.should_run.outputs.should_run == 'true' && inputs.platform == 'cuda'
137+ run : |
138+ set -euo pipefail
134139
135- - name : Environment Setup
136- if : steps.should_run.outputs.should_run == 'true'
140+ echo "===== Step 0: Activate Python environment ====="
141+ source /opt/miniconda3/etc/profile.d/conda.sh
142+ conda activate flagscale-train
143+ echo "PATH=$PATH" >> $GITHUB_ENV
144+ echo "Python: $(which python3) ($(python3 --version 2>&1))"
145+
146+ echo "===== Step 1: Remove Existing TransformerEngine ====="
147+ pip uninstall transformer_engine transformer_engine_torch -y || true
148+
149+ echo "===== Step 2: Build & Install TransformerEngine ====="
150+ cd $GITHUB_WORKSPACE
151+ pip install nvdlfw-inspect --no-deps
152+ pip install --no-build-isolation . -v --no-deps
153+
154+ echo "===== Step 3: Verify Installation ====="
155+ python3 tests/pytorch/test_sanity_import.py
156+
157+ echo "===== Environment Setup Complete ===== "
158+
159+ - name : Environment Setup Metax-specific
160+ if : steps.should_run.outputs.should_run == 'true' && inputs.platform == 'metax'
137161 run : |
138162 set -euo pipefail
139163
@@ -239,14 +263,57 @@ jobs:
239263 bash ${{ matrix.test_group.path }}
240264 timeout-minutes : 60
241265
266+ - name : Generate coverage report
267+ if : inputs.upload_coverage && always()
268+ working-directory : ${{ github.workspace }}
269+ env :
270+ PLATFORM : ${{ inputs.platform }}
271+ DEVICE : ${{ inputs.device }}
272+ run : |
273+ # Install coverage (may already be present)
274+ pip3 install coverage pytest-cov 2>/dev/null || true
275+
276+ # Merge all .coverage* files produced by sub-processes (torchrun spawns workers)
277+ python3 -m coverage combine --keep 2>/dev/null || true
278+ # Generate JSON coverage report (requires .coverage data from pytest --cov)
279+ python3 -m coverage json -o "coverage-${PLATFORM}-${DEVICE}.json" \
280+ --include="transformer_engine/*" 2>/dev/null || echo "WARNING: No coverage data found, skipping coverage-${PLATFORM}-${DEVICE}.json"
281+
282+ # Generate a JSON test report from JUnit XML logs
283+ python3 - <<'PYEOF'
284+ import json, glob, os, xml.etree.ElementTree as ET
285+ platform = os.environ["PLATFORM"]
286+ device = os.environ["DEVICE"]
287+ results = {"platform": platform, "device": device, "test_suites": []}
288+ for xml_file in sorted(glob.glob("/logs/**/*.xml", recursive=True)):
289+ try:
290+ tree = ET.parse(xml_file)
291+ root = tree.getroot()
292+ suite = {
293+ "name": root.get("name", os.path.basename(xml_file)),
294+ "tests": int(root.get("tests", 0)),
295+ "errors": int(root.get("errors", 0)),
296+ "failures": int(root.get("failures", 0)),
297+ "skipped": int(root.get("skipped", 0)),
298+ "time": float(root.get("time", 0)),
299+ }
300+ results["test_suites"].append(suite)
301+ except Exception as e:
302+ print(f"WARNING: Failed to parse {xml_file}: {e}")
303+ with open(f"report-{platform}-{device}.json", "w") as f:
304+ json.dump(results, f, indent=2)
305+ print(f"Generated report-{platform}-{device}.json with {len(results['test_suites'])} suites")
306+ PYEOF
307+ continue-on-error : true
308+
242309 - name : Upload coverage report
243310 if : inputs.upload_coverage && always()
244311 uses : actions/upload-artifact@v4
245312 with :
246- name : coverage-${{ inputs.platform }}
313+ name : coverage-${{ inputs.platform }}-${{ inputs.device }}
247314 path : |
248- coverage-${{ inputs.platform }}.json
249- report-${{ inputs.platform }}.json
315+ coverage-${{ inputs.platform }}-${{ inputs.device }} .json
316+ report-${{ inputs.platform }}-${{ inputs.device }} .json
250317
251318 - name : Upload coverage report to FlagCICD
252319 if : inputs.upload_coverage && always()
@@ -255,7 +322,7 @@ jobs:
255322 with :
256323 backend_url : ' http://flagcicd-inner.flagos.net:8000/metrics/'
257324 user_id : ' 000000000000000000'
258- report_path : ' coverage-${{ inputs.platform }}.json'
325+ report_path : ' coverage-${{ inputs.platform }}-${{ inputs.device }} .json'
259326 fail_on_error : ' false'
260327
261328 # - name: Debug - keep container alive on failure
0 commit comments